MySQL Forums
Forum List  »  Stored Procedures

Re: Thread_overrun error
Posted by: Rick James
Date: February 07, 2014 10:34AM

> UPDATE jaces_fieldmark SET debt_amount=balance;

Is jaces_fieldmark a temporary table whose sole purpose is to hold debt_amount?
If so, use a variable instead: @debt_amount.

I still don't see what you are trying to accomplish. Please study this to see if it is related:

SELECT
@balance := @balance + amount AS running_sum,
FROM ( SELECT @balance := 0 )
JOIN MyTbl
WHERE ...
ORDER BY ...

It calculates a "running sum" of the column `amount`.
It does it _without_ a cursor.
The subquery is to initialize @balance without having to issue a second SELECT or SET. (This is a minor issue.)

Rule of Thumb: Cursors can usually be turned into single statements. Always try to do so. The code will run much faster; the code will (ultimately) be simpler.

Options: ReplyQuote


Subject
Views
Written By
Posted
2245
February 05, 2014 03:56PM
1124
February 05, 2014 04:24PM
975
February 05, 2014 04:30PM
1053
February 05, 2014 05:34PM
987
February 05, 2014 05:39PM
1193
February 06, 2014 11:35PM
1114
February 07, 2014 03:27AM
1186
February 07, 2014 03:29AM
Re: Thread_overrun error
1117
February 07, 2014 10:34AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.