diff options
Diffstat (limited to 'src/bin/pgaccess/lib/help/fetch.hlp')
-rw-r--r-- | src/bin/pgaccess/lib/help/fetch.hlp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/bin/pgaccess/lib/help/fetch.hlp b/src/bin/pgaccess/lib/help/fetch.hlp new file mode 100644 index 00000000000..b15be459574 --- /dev/null +++ b/src/bin/pgaccess/lib/help/fetch.hlp @@ -0,0 +1,62 @@ +.pgaw:Help.f.t insert end "FETCH" {bold} " FETCH allows a user to retrieve rows using a cursor. The number of rows retrieved is specified by #. If the number of rows remaining in the cursor is less than #, then only those available are \ +fetched. Substituting the keyword ALL in place of a number will cause all remaining rows in the cursor to be retrieved. Instances may be fetched in both FORWARD and BACKWARD \ +directions. The default direction is FORWARD. + + Tip: Negative numbers are now allowed to be specified for the row count. A negative number is equivalent to reversing the sense of the FORWARD and BACKWARD \ + keywords. For example, FORWARD -1 is the same as BACKWARD 1. + +Note that the FORWARD and BACKWARD keywords are Postgres extensions. The SQL92 syntax is also supported, specified in the second form of the command. See below for details on \ +compatibility issues. + +Once all rows are fetched, every other fetch access returns no rows. + +Updating data in a cursor is not supported by Postgres, because mapping cursor updates back to base tables is not generally possible, as is also the case with VIEW updates. Consequently, \ +users must issue explicit UPDATE commands to replace data. + +Cursors may only be used inside of transactions because the data that they store spans multiple user queries. + +" {} "Synopsis" {bold} " +" {} " +FETCH \[ selector \] \[ count \] + \{ IN | FROM \} cursor +FETCH \[ RELATIVE \] \[ \{ \[ # | ALL | NEXT | PRIOR \] \} \] + FROM \] cursor + +" {code} "Usage" {bold} " +" {} " + --set up and use a cursor: + -- + BEGIN WORK; + DECLARE liahona CURSOR + FOR SELECT * FROM films; + + --Fetch first 5 rows in the cursor liahona: + -- + FETCH FORWARD 5 IN liahona; + + code |title |did| date_prod|kind |len + -----+-----------------------+---+----------+----------+------ + BL101|The Third Man |101|1949-12-23|Drama | 01:44 + BL102|The African Queen |101|1951-08-11|Romantic | 01:43 + JL201|Une Femme est une Femme|102|1961-03-12|Romantic | 01:25 + P_301|Vertigo |103|1958-11-14|Action | 02:08 + P_302|Becket |103|1964-02-03|Drama | 02:28 + + + --Fetch previous row: + -- + FETCH BACKWARD 1 IN liahona; + + code |title |did| date_prod|kind |len + -----+-----------------------+---+----------+----------+------ + P_301|Vertigo |103|1958-11-14|Action | 02:08 + + -- close the cursor and commit work: + -- + CLOSE liahona; + COMMIT WORK; + +" {code} "Notes" {bold} " + +Refer to MOVE statements to change cursor position. Refer to DECLARE statements to declare a cursor. Refer to BEGIN WORK, COMMIT WORK, ROLLBACK WORK statements for \ +further information about transactions." |