PREPARE

The PREPARE statement (embedded SQL only) transforms a character string form of an SQL statement into an executable form of the same statement. The resulting executable statement is known as a prepared statement, while the original character string is known as the statement string.

Invocation

PREPARE is an executable command that can only be embedded in a host language. PREPARE cannot be dynamically prepared.

Authorization

Users must have authorization to execute the command in the PREPARE statement.

Syntax

Bold text indicates clauses or options that are supported only syntactically.

PREPARE statement-name
    [INTO descriptor-name [USING {NAMES | LABELS | ANY | BOTH}]]
    {[ATTRIBUTES attr-host-variable] FROM host-variable |
     FROM string-expression}

attr-host-variable

{{ASENSITIVE | INSENSITIVE | SENSITIVE [DYNAMIC | STATIC]} |
{SCROLL | NOSCROLL} |
holdability |
returnability |
rowset-positioning |
fetch-first-clause |
{read-only-clause | update-clause} |
optimize-clause |
isolation-clause |
{FOR MULTIPLE ROWS | FOR SINGLE ROW} |
{ATOMIC | NOT ATOMIC CONTINUE ON SQLEXCEPTION} [...] }

holdability

[WITH HOLD | WITHOUT HOLD]

returnability

[WITH RETURN [TO CALLER] | WITHOUT RETURN]

rowset-positioning

[WITH ROWSET POSITIONING | WITHOUT ROWSET POSITIONING]

Parameters:

statement-name Names the prepared statement. If a prepared statement by that name already exists, then that prepared statement is destroyed and replaced by the newer version specified in this PREPARE statement.