on 08-13-2013 9:29 PM
I recently came over to Sybase ASE SQL from Microsoft SQL Server. In SQL Server I would often create stored procedures with a nested cursor in which the SELECT statement for the inner cursor contains a WHERE clause with a variable fetched by the outer cursor. I know that in Sybase the DECLARE CURSOR statement needs to be in a separate batch, so I’m not sure how this can be done. Any ideas? Thanks.
P. S. I know that cursors aren't ideal but in some situations they're a good solution.
There is a subtle difference between ASE cursors declared inside a stored procedure ("server cursors") and cursors declared in ad-hoc SQL ("language cursors").
In ASE, you can declare as many cursors as you like inside a stored procedure. By definition, this is one batch since it all sits inside the CREATE PROCEDURE statement.
For a language cursor in ad-hoc SQL, you must indeed put the DECLARE...CURSOR statement in aseparate batch.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.