‎2007 Feb 23 5:15 AM
Hi All,
A program is first deleting some records from a databse table ( assume Table1)
and it is trying to insert the same records back to the table Table1 with the same
primary keys.
This program is defective. It does not check against the table
Table1 to verify that the commit work is completed after the delete,
As a result sometimes when the database performance is slow or the
record is locked by some other user, is it is trying to insert records
into the table with the same primary keys even before the delete work
is committed to the database. The program is unable to insert records
into the table with the same primary keys and hence terminating it and
creating the Short Dump Message.
The delete is committed to the database even after the program is
terminated with a Short Dump Message. This results in the old records
being deleted without the new updated records being inserted into the
table Table1.
Please suggest a solution this problem.
‎2007 Feb 23 5:35 AM
Hi,
You need to create a ENQUEUE Function module for this one, nad before doing the Deletion Lock the table/entries using the above function module and do the deletion and insert the records then write the fucntion moduel DEQUEUE to release the lock
secondly, before inserting the records, why don't you check whehter the record is already there in the table with the same primary keu, if the record is existed with the same primay key then do not insert that record.
Regards
Sudheer
‎2007 Feb 23 5:29 AM
HI,
The solution will be like First LOCK ALL THE RECORDS you want to delete, then do a DATABASE COMMIT, then LOCK ALL THE RECORDS again (You can lock records that does not exist) then INSERT THE RECORDS and do a DATABASE COMMIT.
In your case delete is happening since there is an implicit database commit when ever a program ends.
Regards,
Sesh
‎2007 Feb 23 5:35 AM
Hi,
You need to create a ENQUEUE Function module for this one, nad before doing the Deletion Lock the table/entries using the above function module and do the deletion and insert the records then write the fucntion moduel DEQUEUE to release the lock
secondly, before inserting the records, why don't you check whehter the record is already there in the table with the same primary keu, if the record is existed with the same primay key then do not insert that record.
Regards
Sudheer
‎2007 Feb 23 11:25 AM
Instead of using COMMIT WORK after your delete, use; COMMIT WORK AND WAIT. This will allow the commit to complete before the next process starts (your insert).
MattG
‎2007 Feb 23 2:14 PM