SQL_SET_CURRENT_CURSOR_STMT¶
Applies to: ORAFlex SQLFlex MYSQLFlex PGFlex DB2Flex
This command is used to open a cursor to be used for an SQl statement. The cursor must be created using the SQL_OPEN_CURSOR_STMT, but once it has been created, this command can easily switch between cursors as desired. Optionally a different server can be specified for each cursor by passing the server name to this command as well. If no server is specified, the current server will be used. Note that it is important to close all cursors at the end using SQL_CLOSE_CURSOR_STMT.
Syntax
SQL_SET_CURRENT_CURSOR_STMT [of {server}] to {variable}
Parameter |
Description |
---|---|
server |
Name of the server (optional) |
variable |
Cursor handle to use |
Example
SQL_OPEN_CURSOR_STMT to hCursor1
SQL_SET_STMT to "SELECT * FROM CUSTOMER WHERE STATUS = 'Active' "
SQL_PREPARE_STMT
SQL_EXECUTE_STMT
SQL_OPEN_CURSOR_STMT to hCursor2
SQL_SET_STMT to "SELECT * FROM CUSTOMER WHERE STATUS = 'Inactive' "
SQL_PREPARE_STMT
SQL_EXECUTE_STMT
Repeat
SQL_SET_CURRENT_CURSOR_STMT to hCursor1
SQL_FETCH_NEXT_ROW INTO sID sFirstName sLastName
If (Found) Begin
Showln "Active : " sID "- " sFirstName sLastName
End
SQL_SET_CURRENT_CURSOR_STMT to hCursor2
SQL_FETCH_NEXT_ROW into sId sFirstName sLastName
If (Found) Begin
Showln "Inactive : " sID "- " sFirstName sLastName
End
Until (FindErr)
SQL_CLOSE_CURSOR_STMT to hCursor1
SQL_CLOSE_CURSOR_STMT to hCursor2