sqlstored-procedurescursor

Returning a Cursor from a stored procedure


Hi i need to return a CURSOR from a STORED PROCEDURE i approached like this

create proc pps @return_cursor cursor VARYING OUTPUT As
DECLARE cursor_name CURSOR FOR
SELECT id FROM table_name

Now my problem is to capture the return Cursor

DECLARE cur_ret  CURSOR 

cur_ret = exec pps

but execute approach give an error

My problem is How to Return a CURSOR from a Stored procedure and capture it


Solution

  • I have figured out it can be do like this

    create proc pps @ret_cur cursor VARYING OUTPUT As DECLARE @CURx CURSOR SET @CURx= CURSOR FOR SELECT id FROM users1

    DECLARE @CrsrVar CURSOR;

    EXEC PPS @ret_cur=@CrsrVar OUTPUT