PREPARE

Prepares an SQL statement contained in a host string variable for execution.

prepare.png

 

Usage

Embedded, Module.

Description

The SQL statement contained in the host variable is prepared for execution. This function is equivalent to pre-processing and compiling an embedded SQL statement, but is performed at run-time. The (internal) output form of the statement is identified by the statement-name parameter.

See ALLOCATE CURSOR for a description of extended statements.

See also, DESCRIBE.

The following SQL statements can be used with the PREPARE statement:

ALTER

EXECUTE STATEMENT

SET DATABASE

CALL

GRANT

SET SESSION

COMMENT

INSERT

SET SHADOW

COMMIT

LEAVE

SET TRANSACTION

CREATE

REVOKE

START

DELETE

ROLLBACK

UPDATE

DELETE CURRENT

SELECT

UPDATE CURRENT

DROP

SET

 

ENTER

SET DATABANK

 

Notes

The source form of the SQL statement to be prepared is not preceded by the identifier EXEC SQL or terminated by the language-specific delimiter.

The source statement may contain question marks as parameter markers to represent variables to be used when the prepared statement is executed. See the Mimer SQL Programmer's Manual, Dynamic SQL, for more details.

Example

...

EXEC SQL BEGIN DECLARE SECTION;

   CHARACTER SQL_TXT(255);

...

EXEC SQL END DECLARE SECTION;

...

SQL_TXT := "DELETE FROM products WHERE product_search LIKE ?";

EXEC SQL PREPARE statement1 FROM :SQL_TXT;

...

 

For more information, see the Mimer SQL Programmer's Manual, Preparing Statements.

Standard Compliance

Standard

Compliance

Comments

SQL-2016

Features outside core

Feature B031, “Basic dynamic SQL”.