Updating table while open cursor

In the end the exe copies the final cursor into a dbf but I want it now to put the data into a SQL table.I created the SQL table with the exact columns and data types that the cursor has. By adding quotes, you are saying that it is a literal value, which is not what you want. We've got lots of great SQL Server experts to answer whatever question you can come up with. Hi All I've had a search through the Forums, but can't seem to find a similar problem / solution to the issue I have, so would appreciate any help anyone could offer, as I'm pretty much stuck... We've restricted the ability to create new threads on these forums.

I had several working stored functions that when called from a "fetching" cursor loop didn't work (exited prematurely).

There can be a situation where you have to use a cursor, even though the experts say not to use cursors or to avoid them as much as possible.

But if you look closely, most of the time we use cursors to iterate through a row collection and update the same table.

PDF (US Ltr) - 37.7Mb PDF (A4) - 37.7Mb PDF (RPM) - 37.0Mb HTML Download (TGZ) - 10.2Mb HTML Download (Zip) - 10.3Mb HTML Download (RPM) - 8.9Mb Man Pages (TGZ) - 214.8Kb Man Pages (Zip) - 327.7Kb Info (Gzip) - 3.4Mb Info (Zip) - 3.4Mb My SQL Backup and Recovery My SQL Globalization My SQL Information Schema My SQL Installation Guide My SQL and Linux/Unix My SQL and OS X My SQL Partitioning My SQL Performance Schema My SQL Replication Using the My SQL Yum Repository My SQL Restrictions and Limitations Security in My SQL My SQL and Solaris Building My SQL from Source Starting and Stopping My SQL My SQL Tutorial My SQL and Windows My SQL NDB Cluster 7.5 CREATE PROCEDURE curdemo() BEGIN DECLARE done INT DEFAULT FALSE; DECLARE a CHAR(16); DECLARE b, c INT; DECLARE cur1 CURSOR FOR SELECT id,data FROM test.t1; DECLARE cur2 CURSOR FOR SELECT i FROM test.t2; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; OPEN cur1; OPEN cur2; read_loop: LOOP FETCH cur1 INTO a, b; FETCH cur2 INTO c; IF done THEN LEAVE read_loop; END IF; IF b PDF (US Ltr) - 37.7Mb PDF (A4) - 37.7Mb PDF (RPM) - 37.0Mb HTML Download (TGZ) - 10.2Mb HTML Download (Zip) - 10.3Mb HTML Download (RPM) - 8.9Mb Man Pages (TGZ) - 214.8Kb Man Pages (Zip) - 327.7Kb Info (Gzip) - 3.4Mb Info (Zip) - 3.4Mb My SQL Backup and Recovery My SQL Globalization My SQL Information Schema My SQL Installation Guide My SQL and Linux/Unix My SQL and OS X My SQL Partitioning My SQL Performance Schema My SQL Replication Using the My SQL Yum Repository My SQL Restrictions and Limitations Security in My SQL My SQL and Solaris Building My SQL from Source Starting and Stopping My SQL My SQL Tutorial My SQL and Windows My SQL NDB Cluster 7.5 Hi all, as beat pointed out, LOOP is the only construct that I found useful for traversing cursors. See examples: Nesting cursors is possible, you just need to take care of a few things.

You can either put the inner cursor in it's own BEGIN..

Leave a Reply