Home » Developer & Programmer » Forms » Checking if there is data in the block befor delete_record
Checking if there is data in the block befor delete_record [message #377809] Thu, 25 December 2008 07:27 Go to next message
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 #377994 is a reply to message #377809] Sat, 27 December 2008 11:30 Go to previous messageGo to next message
ric_deen
Messages: 9
Registered: December 2008
Junior Member
any suggestion
Re: Checking if there is data in the block befor delete_record [message #377996 is a reply to message #377994] Sat, 27 December 2008 11:36 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
But, what is the purpose of such a code? Isn't it MORE THAN obvious that - when there are no records in the form - there's really nothing to delete? ./fa/3314/0/
Re: Checking if there is data in the block befor delete_record [message #378011 is a reply to message #377809] Sat, 27 December 2008 14:27 Go to previous messageGo to next message
ric_deen
Messages: 9
Registered: December 2008
Junior Member

I need it in my application in response to a user who might press a "delete" button while there isn't any data.
Re: Checking if there is data in the block befor delete_record [message #378020 is a reply to message #378011] Sat, 27 December 2008 15:53 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Do you think that these people (who will use your application) are THAT stupid that they don't see when there's nothing to delete?
Re: Checking if there is data in the block befor delete_record [message #378028 is a reply to message #377809] Sat, 27 December 2008 22:15 Go to previous messageGo to next message
ric_deen
Messages: 9
Registered: December 2008
Junior Member

Any thing is expected from an end-user. I need to stop this now and welling to have an answer to my original question from those who can help.

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 messageGo to next message
Littlefoot
Messages: 20901
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.
Re: Checking if there is data in the block befor delete_record [message #379784 is a reply to message #378083] Wed, 07 January 2009 23:48 Go to previous message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
You could also check the status of the record. If the status is 'insert' then you could tell them that there is nothing to be deleted.

David
Previous Topic: draw in forms
Next Topic: DML&DDL operations on Data via some DLL file
Goto Forum:
  


Current Time: Sat Dec 10 20:34:52 CST 2016

Total time taken to generate the page: 0.08068 seconds