472,146 Members | 1,316 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

MYSQL: update where clause ignored in SP

New to Mysql;
I have created a stored procedure. Using a cursor I traverse the first table.
For each row in the cursor I need to determine the correct row in another table to update.
Using a select statement with data from the cursor I identify the primary key to this the target table and update it. I extract row counts from the target table as I go to check that the correct number of rows are being updated (i.e. 1 each time). results here are inconsistent.

I then select the next row from the cursor and continue to the end. immediately before the end I commit and check the number of updated rows.

After the SP completes (i.e. on the next line, no other SQL statements.I do another rowcount on the target table.
However, this updated row count differs completely from the row count obtained from inside the SP.
Effectively all rows are updated on the target table and not just the intended ones. This is not indicated on the debug selects inside the SP.
Also as the cursor progresses through the routine, I get occasional spurious additional rows updated and returned from debug selects inside the cursor.
Any pointers as to where I should be looking to resolve this?
Oct 12 '07 #1
1 2093
5,821 Expert 4TB
Heya, Jason! Welcome to TSDN!

Let's see some code.

Please use CODE tags when posting source code:

MySQL code goes here.
Oct 12 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Reply via newsgroup | last post: by
reply views Thread by Lenz Grimmer | last post: by
5 posts views Thread by princevejita1 | last post: by
6 posts views Thread by Atli | last post: by
reply views Thread by Saiars | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.