Home » Developer & Programmer » Forms » execute_query after a delete error. (merged)
execute_query after a delete error. (merged) [message #139877] Thu, 29 September 2005 22:52 Go to next message
renecum
Messages: 5
Registered: September 2005
Location: Guatemala
Junior Member
I have a problem with deleting records from a table that is referenced by other, because the referential integrity.

When I delete a record with the smart bar, it works fine, but when use the save button, it gives me a message saying that can't delete the record.

So i tried to catch the error and change the message by my own, and it works fine.

But, i don't know how to get back the record that I deleted, I tried to use execute_query with a timer (because it is restricted) but always ask me save changes (yes/no/cancel) and I don't want to get that dialog, i just want to get back the data like nothing had happened.

Can somebody help me?
execute_query after a delete error. [message #139878 is a reply to message #139877] Thu, 29 September 2005 22:54 Go to previous messageGo to next message
renecum
Messages: 5
Registered: September 2005
Location: Guatemala
Junior Member
I have a problem with deleting records from a table that is referenced by other, because the referential integrity.

When I delete a record with the smart bar, it works fine, but when use the save button, it gives me a message saying that can't delete the record.

So i tried to catch the error and change the message by my own, and it works fine.

But, i don't know how to get back the record that I deleted, I tried to use execute_query with a timer (because it is restricted) but always ask me save changes (yes/no/cancel) and I don't want to get that dialog, i just want to get back the data like nothing had happened.

Can somebody help me?
Re: execute_query after a delete error. [message #139887 is a reply to message #139878] Fri, 30 September 2005 00:08 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
I think you need to do a bit more reading and testing of master-detail relationships, and the use of 'deferred' and 'Masterless Operation' on the 'relation' that joins the two blocks.

These facilities will enable you to delete a master level record and the subordinate entries will be deleted automatically for you.

David
Re: execute_query after a delete error. [message #139893 is a reply to message #139887] Fri, 30 September 2005 00:37 Go to previous messageGo to next message
renecum
Messages: 5
Registered: September 2005
Location: Guatemala
Junior Member
djmartin wrote on Fri, 30 September 2005 00:08

I think you need to do a bit more reading and testing of master-detail relationships, and the use of 'deferred' and 'Masterless Operation' on the 'relation' that joins the two blocks.


The problem is that I'm no using master-detail blocks, (there is just one block).

I need to delete just the records that are not referenced, example:

table employee, table department

Employee references department and i want to delete department 1 that is referenced in the other table. When I use the delete button in the smart bar works fine, because i haven not committed, but when I save the message appear.

I just want a message saying that i can't delete that record because the reference, and I need that after the message appears, the record that was deleted shows again.

It is difficult to me to explain this, because my English, but i tried to do it, the best I can.
Re: execute_query after a delete error. [message #139909 is a reply to message #139893] Fri, 30 September 2005 01:38 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Your second explanation IS clearer. Okay, we have a couple of choices. We can add a key-delrec trigger to your block and in it we can use a 'select' statement to see if the 'key' is in use. If it is in use then 'raise form_trigger_failure' and that should stop the record from disappearing from your screen.

Alternatively, after you trap the error (search 'error' in this forum) you could do a 'rollback'. Unfortunately, if you have also done an insert then it will also be removed.

The first opinion is the normal one.

David
Re: execute_query after a delete error. [message #139912 is a reply to message #139893] Fri, 30 September 2005 01:44 Go to previous message
aurigian
Messages: 9
Registered: September 2005
Location: pakistan
Junior Member

i think u r not selecting check "enforce data integrity" during ur form creation if u check this so ur user restrict through smart bar and received message "Cannot delete master record when matching detail records exist." and u r also chnage this mesage through blocklevel trigger key-delrec and u don't need to execute_query again or n e timer
Previous Topic: ORA-40508??????
Next Topic: ....... Issue clear the concepts plz
Goto Forum:
  


Current Time: Fri Sep 20 03:41:14 CDT 2024