sqldynprep() — Prepare a Dynamic SQL Statement
Prepare a dynamic SQL statement. This function supports the dynamic EXEC SQL PREPARE... statement.
This function returns normalized values. For more information, see the function return values in the "General Diagnostics" section in this chapter:
sqln
The address of a pointer to the request handle value associated with and returned for the statement being prepared. If the function returns successfully, you can use
sqln
for subsequent calls to ESQL-LIB to refer to this statement. For more information on request handles, see the "SQL Request Handles" section.prequest
A pointer to the text of the SQL statement being prepared.
pstmtid
A pointer to a NULL-terminated string that contains the SQL statement identifier (limited to 18 characters). If you use the preprocessor, it supplies this value. Otherwise, it can be NULL. If you set it to NULL,
sqlgetrqhdl()
cannot return the request handle corresponding to the statement identifier.NOTES
EXAMPLE
- This function prepares a dynamic ESQL statement for execution and associates the result with a request handle (
sqln
). ESQL-LIB makes all future references to this statement usingsqln
. For example, the application can execute and re-execute the prepared statement by callingsqldynexec()
until the application freessqln
with a call tosqldynclose
(sqln
, SQL_STMTDROP) or until the application reinitializessqln
with a subsequent call tosqldynprep()
orsqldynrq()
.- Once the statement is prepared, the application can request information about the statement with calls to
sqldynncols()
,sqldynnparms()
,sqldyndesc()
, orsqldyndescinp()
.- You can prepare a statement once and execute it repeatedly using
sqldynexec()
with new parameter marker values. For more information on using dynamic parameter markers, see Programming with ESQL."- If you prepare a statement using a request handle currently associated with a previously prepared statement, the previous statement is dropped and any associated cursor is closed before preparing the specified statement.
- Dynamic request strings cannot contain the following:
- DECLARE CURSOR, OPEN, FETCH, or CLOSE statements used to manage cursor specifications.
- References to embedded host variable names.
- SQL comments.
- dynamic parameters in a context that prevents the data type of the surrounding expression from being inferred.
For more information and additional restrictions in the request string, see Programming with ESQL."
This example prepares the dynamic ESQL cursor specification in the character string request:
SEE ALSO
sqldyndesc() — Get Dynamic Column Descriptions, sqldynexec() — Execute a Dynamic SQL Statement, sqldynncols() — Get the Number of Columns in a Result Set, sqldynnparms() — Get the Number of Parameter Markers
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |