Progress
SQL-92
Guide and Reference
PREPARE Statement
Parses and assigns a name to an ad hoc or dynamically generated SQL-92 statement for execution. You use a PREPARE statement in a series of steps that allows a program to accept or generate SQL-92 statements at run time.
SYNTAX
statement_name
A name for the dynamically generated statement.
DESCRIBE
,EXECUTE
, andDECLARE
CURSOR
statements refer to this statement_name. A statement_name must be unique in a program.statement_string
Specifies the SQL-92 statement to be prepared for dynamic execution. You can use either the name of a C Language string variable containing the SQL-92 statement, or you can specify the SQL-92 statement as a quoted literal. If there is an SQL-92 syntax error, the
PREPARE
statement returns an error in the SQLCA.
EXAMPLES
The first example is a code fragment from the
DynUpd
function in sample program3DynUpd.pc
, which illustrates dynamic processing of an UPDATE statement:
This example is a code fragment from the
DynSel
function in sample program4DynSel.pc
, which illustrates dynamic processing of a SELECT statement:
The complete source for four sample programs are listed in Appendix A of the Progress Embedded SQL-92 Guide and Reference .
NOTES
- A statement string can have one or more references to input variables. These variables represent values supplied at run time to:
- A program supplies an input variable to a PREPARE statement either as a substitution name or as a parameter marker.
- The USING clauses of EXECUTE and OPEN statements identify host language storage. The values in this storage expand a statement string, replacing a substitution name or a parameter marker. You can design your program to execute the same prepared statement many times in a transaction, supplying different values for input variables for each execution. If you COMMIT or ROLLBACK the transaction, you must PREPARE the statement string again.
AUTHORIZATION
Must have DBA privilege or Authorization for SQL-92 statement being prepared (See the AUTHORIZATION section for the relevant statement).
SQL COMPLIANCE
SQL-92
ENVIRONMENT
Embedded SQL-92 only
RELATED STATEMENTS
EXECUTE Statement, OPEN Statement, CLOSE Statement, FETCH Statement, and SQLCA structure
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |