Oracle7 Server SQL Reference

Contents Index Home Previous Next

PREPARE (Embedded SQL)

Purpose

To parse a SQL statement or PL/SQL block specified by a host variable and associate it with an identifier.

Prerequisites

None.

Syntax

Keywords and Parameters

statement_name block_name

is the identifier to be associated with the prepared SQL statement or PL/SQL block. If this name has been previously assigned to another statement or block, the prior assignment is superseded.

:host_string

is a host variable whose value is the text of a SQL statement or PL/SQL block to be prepared.

'text'

is a string literal containing a SQL statement or PL/SQL block to be prepared.

Usage Notes

Any variables that appear in the :host_string or 'text' are placeholders. The actual host variable names are assigned in the USING clause of the OPEN command (input host variables) or in the INTO clause of the FETCH command (output host variables).

A SQL statement is prepared only once, but can be executed any number of times.

Example

This example illustrates the use of a PREPARE statement in a Pro*C embedded SQL program:

EXEC SQL PREPARE my_statement FROM :my_string; 
EXEC SQL EXECUTE my_statement 

Related Topics

DECLARE CURSOR command [*] OPEN command [*] FETCH command [*] CLOSE command [*]


Contents Index Home Previous Next