SQLSetStatement() function
- Last UpdatedJun 17, 2024
- 1 minute read
The SQLSetStatement() function starts a SQL statement buffer using the contents of SQLStatement, on the established connection, ConnectionID. There can be one SQL Statement buffer per ConnectionID. Errors are returned in the function return.
Category
SQL
Syntax
[ResultCode=]SQLSetStatement(ConnectionID, SQLStatement);
Arguments
ConnectionID
Name of a memory integer tag that holds the number (ID) assigned by the SQLConnect() function to each database connection.
SQLStatement
Actual SQL statement, see the following examples.
Examples
ResultCode=SQLSetStatement(ConnectionID,"Select LotNo, LotName from LotInfo");
In the following example, the StatementID is set to zero so the statement does not have to call SQLPrepare(Connect_Id, StatementID) before running the statement. Because the StatementID is not created by the SQLPrepare to properly end this select, use the SQLEnd() function instead of the SQLClearStatement() function.
SQLSetStatement( Connect_Id, "Select Speed, Ser_No from tablename where Ser_No =’" + Serial_input + "’");
SQLExecute(Connect_Id,0);
In the following example, the StatementID is created by the SQLPrepareStatement() function and used in the SQLExecute() function. To end this SELECT statement, use the SQLClearStatement() function to free resources and the handle.
SQLSetStatement( Connect_Id, "Select Speed, Ser_No from tablename where Ser_No =’" + Serial_input + "’");
SQLPrepareStatement(Connect_Id,StatementID);
SQLExecute(Connect_Id,StatementID);
SQLSetStatement( Connect_Id, "Select Speed, Ser_No from tablename where Ser_No =’" + Serial_input + "’");
SQLPrepareStatement(Connect_Id,StatementID);
SQLExecute(Connect_Id,StatementID);
See Also
SQLConnect()