Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Can a CURSOR be populated by firing a stored procedure? Expand / Collapse
Author
Message
Posted Thursday, May 9, 2013 10:35 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 10:01 PM
Points: 22,980, Visits: 31,456
Eugene Elutin (5/9/2013)
Lynn Pettis (5/9/2013)
Eugene Elutin (5/9/2013)
Lynn Pettis (5/8/2013)
Eugene Elutin (5/8/2013)
Actually you can, if you really want or need to!
You should use cursor datatype in output parameter of your procedure. Here you will find a sample:

http://msdn.microsoft.com/en-GB/library/ms175498(v=sql.105).aspx

Should, also mention that this technique is not used very often...


Unless you are working with Oracle, then reference cursors are the only way to return data from a stored procedure.


Sorry, what do you mean by that?
I know at least four ways of returning result(s) (data) from stored procedure in T-SQL.


Yes, T-SQL is nice in that way. I had the opportunity to work with Oracle for a year, and the methods we can use in T-SQL (MS SQL Server) don't work in Oracle. You use reference cursors to return data, which you can also use in T-SQL by returning a cursor as an outout parameter.



I'm not an Oracle expert, but I remember that it has few ways of getting back data too. Have you used pipelined functions?



Nope and where I work now I don't have to worry about writing PL/SQL either. I like T-SQL, it just seems right.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1451260
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse