calvinsinger
Programmer
I want to be able put a check in a SQL stored procedure, to check, if a cursor already exists. It it exists, I want to deallocate it and only then create a new one.
How can I check (how to write the code ?) if a cursor by given name already exists. Thanks
Background...
The reason I get an error telling me that the cursor already exists is because sometimes the stored procedure which creates the cursor and then uses it, aborts mid-way, due to a data error. It then exists before it can reach the code portion which deallocates the the cursor. So the cursor is left allocated.
How can I check (how to write the code ?) if a cursor by given name already exists. Thanks
Background...
The reason I get an error telling me that the cursor already exists is because sometimes the stored procedure which creates the cursor and then uses it, aborts mid-way, due to a data error. It then exists before it can reach the code portion which deallocates the the cursor. So the cursor is left allocated.