delete_record [message #151068] |
Tue, 13 December 2005 00:07 |
VSPB
Messages: 27 Registered: August 2005
|
Junior Member |
|
|
Hi,
I have written this code to delete any record in the block: -
DECLARE
alert_id ALERT;
num Number;
BEGIN
alert_id := FIND_ALERT('delete');
Set_Alert_Property(alert_id,title,'Confirmation');
Set_Alert_Property(alert_id, alert_message_text, 'Do you want to delete this record?' );
num := SHOW_ALERT( alert_id );
if num = ALERT_BUTTON1 then
delete_record;
commit_form;
end if;
clear_message;
if error_type='FRM' and error_code=40510 then
alert_id := FIND_ALERT('del_alert');
Set_Alert_Property(alert_id, alert_message_text, 'Cannot delete compartment, it is referred by another record.' );
num := SHOW_ALERT( alert_id );
raise form_trigger_failure;
end if;
clear_message;
End;
It deletes the record if it is not referred by any other record. But if it is referred by any other record, it gives the above message and deletes the record from the screen but not from the table, because when i exit and again open the form the record is there.
How can i stop the record from disappearing from the screen if it cannot be deleted.
Please help...
Thanks
|
|
|
|
Re: delete_record [message #151078 is a reply to message #151075] |
Tue, 13 December 2005 00:50 |
VSPB
Messages: 27 Registered: August 2005
|
Junior Member |
|
|
It is checking for the child record. It also gives proper message. It shows the alert that child record exists and when i click ok button of the alert that particular record just disappears from the screen but it is not deleted. that is fine it should not be deleted if it is referred somewhere, but it should not go from the screen if it is not deleted from the table. It should remain there only.
|
|
|
|
Re: delete_record [message #151766 is a reply to message #151311] |
Mon, 19 December 2005 02:16 |
VSPB
Messages: 27 Registered: August 2005
|
Junior Member |
|
|
Yes that is what i want to do. But that is not my problem. My problem is after i click on delete it gives the message 'do you want to delete the record' when i click yes and if a child record exists for that record then it gives the message 'Cannot delete compartment. It is referred by another record.' and does not delete the record from the table. Till here it is working absolutely fine. But when it shows the alert 'Cannot delete compartment. It is referred by another record.' and i click on ok as in the picture below
it removes the record from screen like this
as you can see the first record disappeared from the screen but it is not deleted.
I want to know how can i avoid this from disappearing.
Please help...
thanks
[Updated on: Mon, 19 December 2005 02:19] Report message to a moderator
|
|
|
Re: delete_record [message #151918 is a reply to message #151766] |
Mon, 19 December 2005 17:53 |
|
djmartin
Messages: 10181 Registered: March 2005 Location: Surges Bay TAS Australia
|
Senior Member Account Moderator |
|
|
I suggest you look to see if there are any child records before you issue your alert, tell the user whether there are child records and ask if they want them deleted as well. Then handle their reply.
But, if there are child records and the user wants to delete the parent then YOU have to decide now before you write the code as to whther it is within the business policy or not and then write code to handle it appropriately. That is, either tell the user 'NO' or delete the children and THEN issue the delete_record.
David
|
|
|