Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Referencing a cursor variable IN SP
Message
From
29/09/2003 13:03:58
 
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00833171
Message ID:
00833214
Views:
19
>Which is:
>DECLARE CURSOR
>DECLARE FETCH INTO variables
>
>OPEN CURSOR
>FETCH CURSOR ÌNTO variables
>WHILE @@FETCH_STATUS
>BEGIN
> IF variable1 ....
> ...
> ...
> FETCH
>END
>
>CLOSE CURSOR
>DEALLOCATE CURSOR

This is how it's done. The question that you should be asking yourself is: "Self - do I really need to use a cursor??" <bg>

-Mike

>In Oracle I can reference a cursor rowset using the following syntax:
>
>DECLARE C_CUSOR AS
>SELECT NAME,SALARY,...
> FROM A_TABLE
>
>FOR M_CURSOR IN C_CURSOR
>LOOP
> IF M_CURSOR.SALARY > 50000 THEN
> ....
> ....
> END IF
>END LOOP
>
>
>
>NOTES:
>1- I do not have to declare M_CURSOR it's declare implicitely with the FOR...
>2- I do not need to OPEN, FETCH, CLOSE AND DEALLOCATE the cursor, done automatically.
>3- There is no need to declare a variable to store the fetched row..
>
>
>I'm far from 'bitching' against SQL Server, there is a little voice in me that says that there should be a more clever way of doing what I'm doing in SQL Server right now...
>
>Which is:
>DECLARE CURSOR
>DECLARE FETCH INTO variables
>
>OPEN CURSOR
>FETCH CURSOR ÌNTO variables
>WHILE @@FETCH_STATUS
>BEGIN
> IF variable1 ....
> ...
> ...
> FETCH
>END
>
>CLOSE CURSOR
>DEALLOCATE CURSOR
>
>Thanks!
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform