23.10.2012 Views

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example<br />

statement_name<br />

Name of the prepared <strong>SQL</strong> statement.<br />

structure_name<br />

Name of an <strong>SQL</strong> descriptor area (<strong>SQL</strong>DA).<br />

E<strong>SQL</strong> elements and statements<br />

Notes • A statement must be processed with a PREPARE statement before it can be processed with<br />

an EXECUTE statement.<br />

Syntax<br />

/*<br />

** Process the non-SELECT input statement<br />

** PREPARE the statement<br />

** EXECUTE the prepared statement<br />

** COMMIT WORK<br />

*/<br />

EXEC <strong>SQL</strong> PREPARE dynstmt FROM :sql_stmt_v ;<br />

EXEC <strong>SQL</strong> EXECUTE dynstmt ;<br />

EXEC <strong>SQL</strong> COMMIT WORK ;<br />

• A prepared statement can be executed multiple times in the same transaction. Typically<br />

each call to the EXECUTE statement supplies a different set of host variables.<br />

• If there is no DESCRIPTOR in the USING clause, the EXECUTE statement is restricted to the<br />

number of variables specified in the host variable list. The number and type of the<br />

variables must be known at compile time. The host variables must be declared in the<br />

DECLARE SECTION before they can be used in the USING clause of the EXECUTE statement.<br />

• If there is a DESCRIPTOR in the USING clause, the program can allocate space for the input<br />

host variables at run time.<br />

Related statements<br />

EXECUTE IMMEDIATE, PREPARE<br />

EXECUTE IMMEDIATE<br />

Executes the statement specified in a statement_string or host_variable.<br />

EXECUTE IMMEDIATE { statement_string | host_variable } ;<br />

statement_name<br />

Name of the prepared <strong>SQL</strong> statement.<br />

structure_name<br />

Name of an <strong>SQL</strong> descriptor area (<strong>SQL</strong>DA).<br />

Notes • The character string form of the statement is referred to as a statement string. An EXECUTE<br />

IMMEDIATE statement accepts either a statement string or a host variable as input.<br />

331

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!