Top
Symfoware Server V12.1.0 Application Development Guide
FUJITSU Software

6.4.4 DECLARE STATEMENT

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

connection_name

A database connection name established by the CONNECT command.

If AT clause is omitted, a SQL statement identifier is associated with the DEFAULT connection.

statement_name

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.