Entering content frame

 Static SQL Statement with Parameters 

Use

The most common use of parameters in a static SQL statement is the use of host variables as parameters in a WHERE condition.

The host variables must be declared in the declaration section.

You can use host variables in static SQL statements only in positions where the SQL syntax allows a parameter. For example, you cannot specify table names with host variables.

Syntax

EXEC SQL [<session_spec>] <statement>;

Specify <session_spec> , when you are working with multiple database sessions.

 

EXEC SQL BEGIN DECLARE SECTION;

char name[16];

EXEC SQL END DECLARE SECTION;

sprintf (name, "Excelsior");

EXEC SQL SELECT name FROM hotel WHERE name = :name;

EXEC SQL FETCH INTO :name;

 

 

Leaving content frame