]> begriffs open source - ai-pg/blob - full-docs/txt/ecpg-sql-declare-statement.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / ecpg-sql-declare-statement.txt
1
2 DECLARE STATEMENT
3
4    DECLARE STATEMENT — declare SQL statement identifier
5
6 Synopsis
7
8 EXEC SQL [ AT connection_name ] DECLARE statement_name STATEMENT
9
10 Description
11
12    DECLARE STATEMENT declares an SQL statement identifier. SQL statement
13    identifier can be associated with the connection. When the identifier
14    is used by dynamic SQL statements, the statements are executed using
15    the associated connection. The namespace of the declaration is the
16    precompile unit, and multiple declarations to the same SQL statement
17    identifier are not allowed. Note that if the precompiler runs in
18    Informix compatibility mode and some SQL statement is declared,
19    "database" can not be used as a cursor name.
20
21 Parameters
22
23    connection_name #
24           A database connection name established by the CONNECT command.
25
26           AT clause can be omitted, but such statement has no meaning.
27
28    statement_name #
29           The name of an SQL statement identifier, either as an SQL
30           identifier or a host variable.
31
32 Notes
33
34    This association is valid only if the declaration is physically placed
35    on top of a dynamic statement.
36
37 Examples
38
39 EXEC SQL CONNECT TO postgres AS con1;
40 EXEC SQL AT con1 DECLARE sql_stmt STATEMENT;
41 EXEC SQL DECLARE cursor_name CURSOR FOR sql_stmt;
42 EXEC SQL PREPARE sql_stmt FROM :dyn_string;
43 EXEC SQL OPEN cursor_name;
44 EXEC SQL FETCH cursor_name INTO :column1;
45 EXEC SQL CLOSE cursor_name;
46
47 Compatibility
48
49    DECLARE STATEMENT is an extension of the SQL standard, but can be used
50    in famous DBMSs.
51
52 See Also
53
54    CONNECT, DECLARE, OPEN