Home » Developer & Programmer » Forms » DELETE_RECORD in when-validate-item (Forms 11G)
DELETE_RECORD in when-validate-item [message #631524] Wed, 14 January 2015 08:35 Go to next message
RaShi.Raj
Messages: 84
Registered: May 2014
Location: Bangalore
Member
Hi All,

I have a master and details block with a join relation. I have a 'Add' button in detail block. Clicking 'Add' creates a record (CREATE_RECORD) and assign primary key column with a value from a sequence. There is another NOT NULL item say ITEM1 on detail block. Suppose, if user clicks on 'Add' and enters to other blocks without entering any value for ITEM1, I get an oracle error "Unable to insert record - Mandatory column is missing" ( This is becasue we have 'POST'command in Clear_All_Master_Details procedure which fires after this operation). What I'm looking at is 'DELETE' this record if ITEM1 is NULL before it fires post. I don't want user to force entering value for ITEM1 for some reasons.
I cannot use DELETE_RECORD in When-Validate-Trigger (restricted builtin). I even tried to create Timer in WVI and deleting record in WHEN-TIMER-EXPIRED trigger but it isn't working. Any other workaround please?

Thanks,
Rashi
Re: DELETE_RECORD in when-validate-item [message #631527 is a reply to message #631524] Wed, 14 January 2015 09:26 Go to previous messageGo to next message
cookiemonster
Messages: 13921
Registered: September 2008
Location: Rainy Manchester
Senior Member
Personally I'd refrain from populating any items in the detail block until after the user has started entering data themselves.
Re: DELETE_RECORD in when-validate-item [message #631533 is a reply to message #631527] Wed, 14 January 2015 12:51 Go to previous messageGo to next message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
Rashi,
Since you are POSTing data in your Clear-All-Master-Details trigger, couldn't simply execute a ROLLBACK?

If the additional item with a NOT NULL constraint is a problem, wouldn't it be better to set the REQUIRED property to YES for that item so Forms will force the user to either enter a value or clear the record? Since you are Posting data, you would have to actually COMMIT in order to use the DELETE_RECORD anyway. It would be better to issue a ROLLBACK in your When-Clear-Record trigger.

Craig...
Re: DELETE_RECORD in when-validate-item [message #631549 is a reply to message #631533] Thu, 15 January 2015 02:46 Go to previous messageGo to next message
cookiemonster
Messages: 13921
Registered: September 2008
Location: Rainy Manchester
Senior Member
Delete_record works as clear_record if the record hasn't yet been written to the DB.
I'm also pretty sure that delete_record will work as delete_record (send a delete statement to the DB) if you've posted the record.
Once it's posted, clear_record won't delete it.
While the OP may want to rollback in this case they may want to post in others, so you'll need conditional logic for the rollback.

My suggested approach is the simplest solution.
Re: DELETE_RECORD in when-validate-item [message #631561 is a reply to message #631549] Thu, 15 January 2015 06:44 Go to previous messageGo to next message
RaShi.Raj
Messages: 84
Registered: May 2014
Location: Bangalore
Member
Thanks both Smile

Cookiemoster - could you please explain your solution in bit more detail ? can your logic be applied to my case without major changes ?
Re: DELETE_RECORD in when-validate-item [message #631564 is a reply to message #631561] Thu, 15 January 2015 07:15 Go to previous messageGo to next message
cookiemonster
Messages: 13921
Registered: September 2008
Location: Rainy Manchester
Senior Member
Just populate the pk column in pre-insert.
Re: DELETE_RECORD in when-validate-item [message #631612 is a reply to message #631564] Fri, 16 January 2015 07:31 Go to previous message
RaShi.Raj
Messages: 84
Registered: May 2014
Location: Bangalore
Member
Thanks Cooliemonster Smile. applied your solution and I could get rid of lot of unwanted codes and it's working fine now.

I have another problem, not related to this. On the same screen, in master block, I have when-validate-item trigger which is firing twice when I commit the form (It fires becasue user hasn't entered a value for a mandatory field). I removed WVI, made 'Required' property to 'Yes' and I get "Field must be entered" twice again.

When I save it executes "Commit_form" followed by "clear_form". May I know what's happening here and how to avoid it firing 2nd time. It fires just once if I click on any other fields.
Previous Topic: frm-40602
Next Topic: Oracle Forms
Goto Forum:
  


Current Time: Mon May 06 19:38:37 CDT 2024