Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Enqueue/Dequeue

Former Member
0 Likes
1,011

Hi,

There are 2 reports accessing 1 table. I am facing the runtime error with description - "The database system detected a deadlock and avoided it by rolling back your transaction.u201D

Have come across implementing the ENQUEUE and DEQUEUE concept on the table. Please clarify the below queries:

1.Is the above error occuring beacuse the two reports are accessing the table at the same time?

2.Implementing EN/DEQUEUE will solve the problem?

3.If first report is writing the data to table at 12pm(after locking the table), and the second report trying to access the table at 12:10pm to write the data, will this wait in some queue and write the data after the first report releases the table lock?

Regards,

Rajkamal

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
854

Hello Raj,

You should understand the difference between Database Locks & SAP locks.

The database system detected a deadlock and avoided it by rolling back your transaction

1.Is the above error occuring beacuse the two reports are accessing the table at the same time?

Initial look at the statement suggests that this is because of Database Lock collision. You need to check if both the programs were trying to write (INSERT/UPDATE/MODIFY/DELETE) the same data to the DB table.

2. Implementing EN/DEQUEUE will solve the problem?

It should. But make sure you don't lock the entire table, try to lock only the individual records which are being processed(This is a good coding practice, of course you can override it depending on your requirement).

3.If first report is writing the data to table at 12pm(after locking the table), and the second report trying to access the table at 12:10pm to write the data, will this wait in some queue and write the data after the first report releases the table lock?

No, afiak there is no such queue. Alternatively you can put the lock in a iteration(viz., DO loop, WHILE loop) & check when the locks are released.

Hope i'm clear.

BR,

Suhas

1 REPLY 1
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
855

Hello Raj,

You should understand the difference between Database Locks & SAP locks.

The database system detected a deadlock and avoided it by rolling back your transaction

1.Is the above error occuring beacuse the two reports are accessing the table at the same time?

Initial look at the statement suggests that this is because of Database Lock collision. You need to check if both the programs were trying to write (INSERT/UPDATE/MODIFY/DELETE) the same data to the DB table.

2. Implementing EN/DEQUEUE will solve the problem?

It should. But make sure you don't lock the entire table, try to lock only the individual records which are being processed(This is a good coding practice, of course you can override it depending on your requirement).

3.If first report is writing the data to table at 12pm(after locking the table), and the second report trying to access the table at 12:10pm to write the data, will this wait in some queue and write the data after the first report releases the table lock?

No, afiak there is no such queue. Alternatively you can put the lock in a iteration(viz., DO loop, WHILE loop) & check when the locks are released.

Hope i'm clear.

BR,

Suhas