This section describes the DECLARE STATEMENT statement.
Synopsis
EXEC SQL [ AT connection_name] DECLARE statement_name STATEMENT
Description
DECLARE STATEMENT declares SQL statement identifier. SQL statement identifier is associated with connection. DELARE CURSOR with a SQL statement identifier can be written before PREPARE.
Parameters
A database connection name established by the CONNECT command.
If AT clause is omitted, a SQL statement identifier is associated with the DEFAULT connection.
An identifier for SQL statement identifier which is SQL identifier or host variable.
Examples
EXEC SQL CONNECT TO postgres AS con1 EXEC SQL AT con1 DECLARE sql_stmt STATEMENT EXEC SQL DECLARE cursor_name CURSOR FOR sql_stmt EXEC SQL PREPARE sql_stmt FROM :dyn_string EXEC SQL OPEN cursor_name EXEC SQL FETCH cursor_name INTO :column1 EXEC SQL CLOSE cursor_name
Note
An SQL statement with a SQL statement identifier must use a same connection as the connection that the SQL statement identifier is associated with.
An SQL statement without a SQL statement identifier must not use AT clause.