Informix FETCH FIRST, FETCH PRIOR, and FETCH LAST
In addition to the conventional FETCH NEXT, the Informix interface
supports FETCH FIRST, FETCH PRIOR, and FETCH LAST statements.

If you only enter FETCH, PowerBuilder assumes FETCH NEXT.
Example
This cursor example illustrates how you can loop through a
result set. Assume the default transaction object (SQLCA) has been
assigned valid values and a successful CONNECT has been executed.
The statements retrieve rows from the employee table and then
display a message box with the employee name in each row that is
found.
1 |
// Declare the emp_curs <br>DECLARE emp_curs CURSOR FOR<br> SELECT emp_name FROM EMPLOYEE <br> WHERE emp_state = :sle_1.text;<br> <br>// Declare a destination variable for employee<br>// names.<br>string emp_name_var <br> <br>// Get current value of sle_1.text.<br>OPEN emp_curs;<br> <br>// Fetch the first row from the result set.<br>FETCH emp_curs INTO :emp_name_var;<br> <br>// Loop through result set until exhausted<br>DO WHILE SQLCA.sqlcode = 0<br> <br>// Pop up a message box with the employee name<br> MessageBox("Found an employee!",emp_name_var)<br> <br>// Fetch the next row from the result set<br> FETCH emp_curs INTO :emp_name_var;<br> <br>LOOP<br> <br>// All done, so close the cursor<br>CLOSE emp_curs; |

Although you should test the SQLCode after every SQL statement,
these examples show statements to test the SQLCode only to illustrate
a specific point.
Document get from Powerbuilder help
Thank you for watching.
Subscribe
Login
0 Comments
Oldest