PDA

View Full Version : Really simple example of stored procedure with cursor?


quadrant6
11-24-2009, 03:40 AM
I'm trying to learn about stored procedures and cursors by example but can't find any really simple ones.

Could anyone please offer a very basic example, using this table as a reference?

person
------------------
person_id
date_registered
email
password
first_name
last_name
organisation
address
country

Old Pedant
11-24-2009, 07:09 AM
Well, *MOST* of the time you should find a way to avoid them.

I discovered recently that a self join, even though it required a special index to make it efficient, was roughly 4 times more efficient than doing the equivalent with a cursor!

Quite frankly, I can't conceive of any query involving a table that looks like that one that would need a cursor.

Give me an example of something you want to do with that data and I'll try, but I'll bet the right answer will *not* involve a cursor.