Cursors vs Procedures in SQL
Posted
by CogitoErgoSum
on Stack Overflow
See other posts from Stack Overflow
or by CogitoErgoSum
Published on 2010-06-16T14:21:22Z
Indexed on
2010/06/16
14:32 UTC
Read the original article
Hit count: 259
sql
So, I just learned about CURSORS but still don't exactly grasp them. What is the difference between a cursor and procedure or even a function?
So far from the various examples (DECLARE CURSOR ... SELECT ... FROM ...) It seems at most its a variable to hold a query. Is the data real time, or a snapshot of when the cursor was declared?
i.e. I have a table with one row and one col with a value of 2. I do DECLARE CURSOR ... SELECT * FROM table1 I then insert a new row with a value of 3.
When I run the cursor, would I Just get the one row from before the cursor was declared, or both rows?
Thanks
© Stack Overflow or respective owner