SQL_SET_STMT¶
Applies to: ORAFlex SQLFlex MYSQLFlex PGFlex DB2Flex
Use this command to set an SQL statement to be executed on the desired table. The string passed to this command must be a valid SQL expression and must be on a table that has already been opened. Note that when using this command, the SQL_PREPARE_STMT and SQL_EXECUTE_STMT must be used in addition to carry out the expression. The option to pass the file name as an extra parameter is used in cases where the data needs to be fetched directly into the record buffer of the specified file.
Syntax
SQL_SET_STMT [of {file}] to {variable}
Parameter |
Description |
---|---|
file |
Name or number of the file (optional) |
variable |
String containing the SQL statement |
Usage
SQL_SET_STMT of Customer to "SELECT * FROM CUSTOMER WHERE STATUS = 'Active'"
SQL_SET_STMT to "SELECT * FROM CUSTOMER WHERE STATUS = 'Active'"
Example
Open Customer
String sID sFirstName sLastName sDOB
SQL_SET_STMT to "SELECT * FROM CUSTOMER WHERE STATUS = 'Active'"
SQL_PREPARE_STMT
SQL_EXECUTE_STMT
While (Found)
SQL_FETCH_NEXT_ROW into sID sFirstName sLastName sDOB
Showln sID
Showln sFirstName
Showln sLastName
Showln sDOB
Loop
SQL_CANCEL_QUERY_STMT