variable names are substituted, and the query plan is cached for
variable names are substituted, and the query plan is cached for
possible reuse.
possible reuse. The <literal>SCROLL</> and <literal>NO SCROLL</>
options have the same meanings as for a bound cursor.
</para>
</para>
<para>
<para>
...
@@ -2437,7 +2442,7 @@ OPEN curs1 FOR SELECT * FROM foo WHERE key = mykey;
...
@@ -2437,7 +2442,7 @@ OPEN curs1 FOR SELECT * FROM foo WHERE key = mykey;
<title><command>OPEN FOR EXECUTE</command></title>
<title><command>OPEN FOR EXECUTE</command></title>
<synopsis>
<synopsis>
OPEN <replaceable>unbound_cursor</replaceable> FOR EXECUTE <replaceable class="command">query_string</replaceable>;
OPEN <replaceable>unbound_cursor</replaceable> <optional> <optional> NO </optional> SCROLL </optional> FOR EXECUTE <replaceable class="command">query_string</replaceable>;
</synopsis>
</synopsis>
<para>
<para>
...
@@ -2447,7 +2452,9 @@ OPEN <replaceable>unbound_cursor</replaceable> FOR EXECUTE <replaceable class="c
...
@@ -2447,7 +2452,9 @@ OPEN <replaceable>unbound_cursor</replaceable> FOR EXECUTE <replaceable class="c
<type>refcursor</> variable). The query is specified as a string
<type>refcursor</> variable). The query is specified as a string
expression, in the same way as in the <command>EXECUTE</command>
expression, in the same way as in the <command>EXECUTE</command>
command. As usual, this gives flexibility so the query can vary
command. As usual, this gives flexibility so the query can vary
from one run to the next.
from one run to the next. The <literal>SCROLL</> and
<literal>NO SCROLL</> options have the same meanings as for a bound
cursor.
</para>
</para>
<para>
<para>
...
@@ -2473,6 +2480,9 @@ OPEN <replaceable>bound_cursor</replaceable> <optional> ( <replaceable>argument_
...
@@ -2473,6 +2480,9 @@ OPEN <replaceable>bound_cursor</replaceable> <optional> ( <replaceable>argument_
take arguments. These values will be substituted in the query.
take arguments. These values will be substituted in the query.
The query plan for a bound cursor is always considered cacheable;
The query plan for a bound cursor is always considered cacheable;
there is no equivalent of <command>EXECUTE</command> in this case.
there is no equivalent of <command>EXECUTE</command> in this case.
Notice that <literal>SCROLL</> and
<literal>NO SCROLL</> cannot be specified, as the cursor's scrolling
behavior was already determined.
</para>
</para>
<para>
<para>
...
@@ -2513,7 +2523,7 @@ OPEN curs3(42);
...
@@ -2513,7 +2523,7 @@ OPEN curs3(42);
<title><literal>FETCH</></title>
<title><literal>FETCH</></title>
<synopsis>
<synopsis>
FETCH <replaceable>cursor</replaceable> INTO <replaceable>target</replaceable>;
FETCH <optional> <replaceable>direction</replaceable> FROM </optional> <replaceable>cursor</replaceable> INTO <replaceable>target</replaceable>;
</synopsis>
</synopsis>
<para>
<para>
...
@@ -2526,10 +2536,32 @@ FETCH <replaceable>cursor</replaceable> INTO <replaceable>target</replaceable>;
...
@@ -2526,10 +2536,32 @@ FETCH <replaceable>cursor</replaceable> INTO <replaceable>target</replaceable>;
</para>
</para>
<para>
<para>
An example:
The <replaceable>direction</replaceable> clause can be any of the
variants allowed in the SQL <xref linkend="sql-fetch"
endterm="sql-fetch-title"> command except the ones that can fetch