Checking if there is data in the block befor delete_record [message #377809] |
Thu, 25 December 2008 07:27 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
ric_deen
Messages: 9 Registered: December 2008
|
Junior Member |
|
|
Hi every body
This is my first post
I have a data block and a button that will execute a delete_record(). I want my code to check if there is data befor issuing delete_record. The code should be as follow:-
If there is no data in the block then
message ('nothing to delete');
else
delete_record;
Thanks
|
|
|
|
|
|
|
|
Re: Checking if there is data in the block befor delete_record [message #378083 is a reply to message #378028] |
Sun, 28 December 2008 09:42 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/72104.gif) |
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
ric_deen wrote on Sun, 28 December 2008 05:15 |
Any thing is expected from an end-user ...
| ... as well as (some) developers.
I still believe that this is unnecessary. Deleting an empty record is not an error, will cause no error ... NOTHING will happen, as if it was never deleted.
However, if you insist on it, you might check all block items and - if all of them are NULL, display a message. If it was a block based on Scott's DEPT table, code might look as follows:if :deptno is null and :dname is null and :loc is null then
message('nothing to delete');
raise form_trigger_failure;
else
delete_record;
end if;
If you wish, you may produce a more sophisticated and universal code looping through all block items, using the GET_ITEM_PROPERTY built-in (NEXTITEM property might help), but I'll leave it to you.
|
|
|
|