Cursors will be used in DB2 SQL PL stored procedures to perform a complex logic on a row-by-row basis. There are four basic SQL PL statements for working with cursors:
- the DECLARE CURSOR statement to define a cursor
- the OPEN statement to adjust the cursor
- the FETCH statement to retrieve the next row of the cursor
- the CLOSE statement to deactivate the cursor
- the OPEN statement to adjust the cursor
- the FETCH statement to retrieve the next row of the cursor
- the CLOSE statement to deactivate the cursor
we can find out last row using cursor with some logic but we can do it without cursor also by using following logic...
db2 "select * from schema_name.table_name order by column_name desc fetch first 1 rows only "
Enjoy The simplicity...
No comments :
Post a Comment