| The PostgreSQL 9.0 Reference Manual - Volume 2 - Programming Guide
by The PostgreSQL Global Development Group Paperback (6"x9"), 478 pages ISBN 9781906966065 RRP £14.95 ($19.95) Sales of this book support the PostgreSQL project! Get a printed copy>>> |
9.7.2.1 OPEN FOR query
OPEN unbound_cursorvar [ [ NO ] SCROLL ] FOR query;
The cursor variable is opened and given the specified query to
execute. The cursor cannot be open already, and it must have been
declared as an unbound cursor variable (that is, as a simple
refcursor variable). The query must be a
SELECT, or something else that returns rows
(such as EXPLAIN). The query
is treated in the same way as other SQL commands in
PL/pgSQL: PL/pgSQL
variable names are substituted, and the query plan is cached for
possible reuse. When a PL/pgSQL
variable is substituted into the cursor query, the value that is
substituted is the one it has at the time of the OPEN;
subsequent changes to the variable will not affect the cursor's
behavior.
The SCROLL and NO SCROLL
options have the same meanings as for a bound cursor.
An example:
OPEN curs1 FOR SELECT * FROM foo WHERE key = mykey;
| ISBN 9781906966065 | The PostgreSQL 9.0 Reference Manual - Volume 2 - Programming Guide | See the print edition |