Progress
Embedded 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. The DESCRIBE Statements, EXECUTE Statement, and DECLARE CURSOR Statement 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 either use the name of a C Language string variable containing the SQL-92 statement or specify the SQL-92 statement as a quoted literal.
In either format, the statement string must be a character string that is a dynamically executable statement. If there is an SQL-92 syntax error, the PREPARE statement returns an error in the SQLCA.
EXAMPLESThe first example is a code fragment from the
dynupd
function in sample program 3DynUpd.pc, which illustrates dynamic processing of an UPDATE statement. The complete source for the sample program is listed in "ESQL-92 Sample Programs."
This example is a code fragment from the
dynsel
function in sample program 4DynSel.pc, which illustrates dynamic processing of a SELECT statement. The complete source for the sample program is listed in "ESQL-92 Sample Programs."
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 Statement, EXECUTE IMMEDIATE Statement, and OPEN Statement 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
The user executing this statement must have at least one of the following privileges:
SQL COMPLIANCE
SQL-92
ENVIRONMENT
Embedded SQL-92 only
RELATED STATEMENTS
EXECUTE Statement, EXECUTE IMMEDIATE 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 |