Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
DECLARE
Prev Up34.14. Embedded SQL CommandsHome Next

DECLARE

DECLARE — define a cursor

Synopsis

DECLAREcursor_name [ BINARY ] [ ASENSITIVE | INSENSITIVE ] [ [ NO ] SCROLL ] CURSOR [ { WITH | WITHOUT } HOLD ] FORprepared_nameDECLAREcursor_name [ BINARY ] [ ASENSITIVE | INSENSITIVE ] [ [ NO ] SCROLL ] CURSOR [ { WITH | WITHOUT } HOLD ] FORquery

Description

DECLARE declares a cursor for iterating over the result set of a prepared statement. This command has slightly different semantics from the direct SQL commandDECLARE: Whereas the latter executes a query and prepares the result set for retrieval, this embedded SQL command merely declares a name as aloop variable for iterating over the result set of a query; the actual execution happens when the cursor is opened with theOPEN command.

Parameters

cursor_name#

A cursor name, case sensitive. This can be an SQL identifier or a host variable.

prepared_name#

The name of a prepared query, either as an SQL identifier or a host variable.

query#

ASELECT orVALUES command which will provide the rows to be returned by the cursor.

For the meaning of the cursor options, seeDECLARE.

Examples

Examples declaring a cursor for a query:

EXEC SQL DECLARE C CURSOR FOR SELECT * FROM My_Table;EXEC SQL DECLARE C CURSOR FOR SELECT Item1 FROM T;EXEC SQL DECLARE cur1 CURSOR FOR SELECT pgpro_version();

An example declaring a cursor for a prepared statement:

EXEC SQL PREPARE stmt1 AS SELECT pgpro_version();EXEC SQL DECLARE cur1 CURSOR FOR stmt1;

Compatibility

DECLARE is specified in the SQL standard.


Prev Up Next
DEALLOCATE DESCRIPTOR Home DECLARE STATEMENT
pdfepub
Go to Postgres Pro Standard 17
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp