FETCH |
Top Previous Next |
Syntax <fetch_cursor> ::= FETCH cursor_name INTO [:]varname [, [:]varname ...];
Used to fetch the data from the columns in an open cursor into one or more variables. You can use ROW_COUNT to see if actual data has been fetched, it returns 0 if there was no data available.
Example In the example below, you can see the cursor "mycursor" used to fetch all data and break away when there's no more data available.
execute udsblock() returns(out_int integer) as declare mycursor cursor for (select v from DUMMY_ROWS_10 order by v desc); begin /* open the cursor result set */ open mycursor;
/* just loop */ while true do begin fetch mycursor into out_int; if (row_count > 0) then suspend; else break; /* break the loop when there's no more data */ end;
/* close the cursor */ close mycursor; end
|