var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: To fetch the last row of a cursor's result set
how could i fetch the last row of a result set returned by a cursor without traversing thru the cursor's result set..
i find some Fetch Last options in DB2 for OS/360. but not able to use it in my environment.. is there any workaround...
My DB2 version : 8.1.3
OS : Windows 2000
Last edited by Shefu; 02-02-06 at 02:30.
I tried to use the following SELECT into statement
select col1 into var1 from table
this worked fine if the result set returned is of single row..
and this stores a null value ie., '-' in var1 if the query returns multiple rows in the result set.
so i tried to use a cursor with the above select query and in case of multiple rows in the result set of the select query i want the var1 to be assigned the value of the last row in the result set.
hence i asked suggestion to the fetch last row value without traversing the cursor's result set in the above post..
hope this makes my requirement clear..
You could use "select col1 into var1 from table fetch first 1 row only" to return a single row. In this case the value of only the first row will be returned.
Order your result set the other way around and fetch the first row.
Originally Posted by Shefu