COMMIT TRANSACTION does not work?

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
robleer
Posts: 286
Joined: Wed Jul 14, 2010 7:01 pm

COMMIT TRANSACTION does not work?

Post by robleer »

Hi,

I trying to implement the Reorder functionality of a Query and made a process to store the new ordervalues in the database like this:
IF ThatCBTQuestion.OrderNr > ThisCBTQuestion.OrderNr then
ThatCBTQuestion.OrderNr = ThisCBTQuestion.OrderNr -1
else
IF ThatCBTQuestion.OrderNr < ThisCBTQuestion.OrderNr then
ThatCBTQuestion.OrderNr = ThisCBTQuestion.OrderNr +1
This works fine, but immediately after this, I have to recalculate the rest of the table in a certain order.
This is not possible via AwareIM because AIM does not follow the right order when updating.

So, I wrote a stored procedure in my database what does this job.

When I perform the processes one-by-one it works fine (first Reorder the records in my grid, then call the stored procedure with a separate process)

But when I call the stored procedure in the same proces (directly after performing the reordering action), I found out that the data is not commited to the database yet and my stored procedure gives the wrong results (it works with the old data).

So to fix this, I've added a 'COMMIT TRANSACTION' action before I call the stored procedure so the stored procedure works with the actual, commited data, but this does not work and my stored procedure still give the wrong results. I did it like this:
IF ThatCBTQuestion.OrderNr > ThisCBTQuestion.OrderNr then
ThatCBTQuestion.OrderNr = ThisCBTQuestion.OrderNr -1
else
IF ThatCBTQuestion.OrderNr < ThisCBTQuestion.OrderNr then
ThatCBTQuestion.OrderNr = ThisCBTQuestion.OrderNr +1

COMMIT TRANSACTION

EXEC_SP 'UpdateOrderNr'

But it looks like the COMMIT TRANSACTION is doing nothing?

I'm really pulling my hair out to get this reordering functionality working and I hope somebody can help me with this.

Tia, Rob
Using 8.7 Professional 3025 on MySQL/Windows
Jaymer
Posts: 2475
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: COMMIT TRANSACTION does not work?

Post by Jaymer »

I have done this exact thing.
Along with the stored procedure to re-order/renumber the lines.
Will check.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
BLOMASKY
Posts: 1476
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Re: COMMIT TRANSACTION does not work?

Post by BLOMASKY »

I use a lot of stored procedures and use COMMIT TRANSACTION a lot. It seems to work fine for me. You do know, after you commit, and then call a stored procedure, you have to RE-READ the record to get any changes.

Bruce
Post Reply