成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

fetch 中文man頁(yè)面

系統(tǒng)
FETCH 使用游標(biāo)檢索行。

NAME

FETCH - 用游標(biāo)從查詢中抓取行

SYNOPSIS

FETCH [ direction { FROM | IN } ] cursorname

where direction can be empty or one of:

    NEXT
    PRIOR
    FIRST
    LAST
    ABSOLUTE count
    RELATIVE count
    count
    ALL
    FORWARD
    FORWARD count
    FORWARD ALL
    BACKWARD
    BACKWARD count
    BACKWARD ALL

DESCRIPTION 描述

FETCH 使用游標(biāo)檢索行。


 一個(gè)游標(biāo)有一個(gè)由 FETCH 使用的相關(guān)聯(lián)的位置。 游標(biāo)得位置可以在查詢結(jié)果的***行之前,或者在結(jié)果中的任意行, 或者在結(jié)果的***一行之后。在創(chuàng)建完之后,游標(biāo)是放在***行之前的。 在抓取了一些行之后,游標(biāo)放在檢索到的***一行上。如果 FETCH  抓完了所有可用行,那么它就停在***一行后面,或者在向前抓去的情況下是停在***行前面。 FETCH ALL 或者 FETCH BACKWARD ALL  將總是把游標(biāo)的位置放在***一行或者在***行前面。

NEXT, PRIOR, FIRST, LAST, ABSOLUTE, RELATIVE 形式在恰當(dāng)?shù)?移動(dòng)游標(biāo)之后抓取一個(gè)行。如果沒(méi)有數(shù)據(jù)行了,那么返回一個(gè)空的結(jié)果, 那么游標(biāo)就會(huì)停在查詢結(jié)果的***一行之后或者在***行之前。

FORWARD 和 BACKWARD 形式在向前或者向后移動(dòng)的過(guò)程中抓取指定的行數(shù), 然后把游標(biāo)定位在***返回的行上(或者是,如果 count 大于可用的行數(shù),在所有行之前或之后。)

RELATIVE 0,F(xiàn)ORWARD 0,和 BACKWARD 0 都要求在不移動(dòng)游標(biāo)的前提下抓取當(dāng)前行---也就是重新抓取最近剛剛抓取過(guò)的行。 除非游標(biāo)定位在***行之前或者***一行之后,這個(gè)動(dòng)作都應(yīng)該成功,而在那兩種情況下,不返回任何行。  

PARAMETERS 參數(shù)

direction
direction 定義抓取的方向和抓取的行數(shù)。它可以是下述之一:
NEXT

 抓取下一行。 direction  省略時(shí)這是缺省值。
PRIOR

 抓取前面一行。
FIRST

 抓取查詢的***行(和 ABSOLUTE 1 相同)。
LAST

 抓取查詢的***一行(和 ABSOLUTE -1 相同)。
ABSOLUTE count

 抓取查詢中第 count 行, 或者,如果 count < 0, 從查詢結(jié)果末尾抓取第abs(count)行。 如果count 超出了范圍,那么定位在***行之前和***一行之后的位置; 特別是 ABSOLUTE 0 定位在***行之前。
RELATIVE count
抓取隨后的第 count 行, 或者,如果 count < 0 的時(shí)候, 抓取前面的第 abs(count) 行。 如果有數(shù)據(jù)的話,RELATIVE 0 重新抓取當(dāng)前行。
count

 抓取下面的 count 行 (和 FORWARD count 一樣)。
ALL

 抓取所有剩余的行(和 FORWARD ALL 一樣)。
FORWARD

 抓取下面一行(和 NEXT)一樣。
FORWARD count

 抓取下面 count 行。 FORWARD 0 重新抓取當(dāng)前行。
FORWARD ALL

 抓取所有剩余行。
BACKWARD

 抓取前面一行(和 PRIOR 一樣)。
BACKWARD count

 抓取前面 count 行(向后掃描)。 BACKWARD 0 重新抓取當(dāng)前行。
BACKWARD ALL

 抓取所有前面的行(向后掃描)。
count
count 可能是一個(gè)有符號(hào)的整數(shù)常量,決定要抓取的行數(shù)和方向。 對(duì)于 FORWARD 和 BACKWARD 的情況,聲明一個(gè)帶負(fù)號(hào)的 count 等效于改變 FORWARD 和 BACKWARD 的方向。
cursorname

 一個(gè)打開(kāi)的游標(biāo)的名稱。

OUTPUTS 輸出


 成功完成時(shí),一個(gè) FETCH 命令返回一個(gè)形如下面的標(biāo)記

FETCH count


 這里的 count 是抓取的行數(shù)(可能是零)。 請(qǐng)注意在 psql 里,命令標(biāo)簽實(shí)際上不會(huì)顯示, 因?yàn)?nbsp;psql 用抓取的行數(shù)取代了。  

NOTES 注意


 如果你想使用 FETCH NEXT 之外的任何 FETCH 的變種, 或者是帶負(fù)數(shù)計(jì)數(shù)的 FETCH FORWARD。那么定義游標(biāo)的時(shí)候應(yīng)該帶著 SCROLL 選項(xiàng)。 對(duì)于簡(jiǎn)單的查詢,PostgreSQL 會(huì)允許那些沒(méi)有帶 SCROLL 選項(xiàng)定義的游標(biāo)也可以反向抓取, 但是我們***不要依賴這個(gè)行為。 如果游標(biāo)定義了 NO SCROLL,那么不允許反向抓取。

ABSOLUTE 抓取不會(huì)比用相對(duì)位移移動(dòng)到需要的數(shù)據(jù)行更快: 因?yàn)橄聦拥膶?shí)現(xiàn)必須遍歷所有中間的行。負(fù)數(shù)的絕對(duì)抓取甚至更糟糕: 查詢必須一直讀到結(jié)尾才能找到***一行,然后從那里開(kāi)始反向遍歷。 不過(guò),回退到查詢開(kāi)頭(就像 FETCH ABSOLUTE 0)很快。


 在游標(biāo)中更新數(shù)據(jù)還不被 PostgreSQL 支持。

DECLARE [declare(7)] 語(yǔ)句用于定義一個(gè)游標(biāo)。使用 MOVE [move(7)] 語(yǔ)句來(lái)改變游標(biāo)位置而不檢索數(shù)據(jù)。  

EXAMPLES 例子


 下面的例子用一個(gè)游標(biāo)跨過(guò)一個(gè)表。

BEGIN WORK;

-- 建立一個(gè)游標(biāo):
DECLARE liahona SCROLL CURSOR FOR SELECT * FROM films;

-- 抓取頭 5 行到游標(biāo) liahona 里:
FETCH FORWARD 5 FROM 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 PRIOR FROM liahona;

 code  |  title  | did | date_prod  |  kind  |  len
-------+---------+-----+------------+--------+-------
 P_301 | Vertigo | 103 | 1958-11-14 | Action | 02:08

-- 關(guān)閉游標(biāo)并提交事務(wù):
CLOSE liahona;
COMMIT WORK;

COMPATIBILITY 兼容性

SQL 標(biāo)準(zhǔn)定義的 FETCH 只用于嵌入式環(huán)境下。 這里描述的 FETCH 變種是把結(jié)果數(shù)據(jù)像 SELECT 結(jié)果那樣返回,而不是把它放在宿主變量里。除了這點(diǎn)之外,F(xiàn)ETCH 和 SQL 標(biāo)準(zhǔn)完全向上兼容。


 涉及 FORWARD 和 BACKWARD 的 FETCH 形式 (包括 FETCH count 和 FETCH ALL 的形式,這個(gè)時(shí)候 FORWARD 是隱含的)是 PostgreSQL  的擴(kuò)展。


 SQL 標(biāo)準(zhǔn)只允許游標(biāo)前面有 FROM, 用 IN 是一種擴(kuò)展。  

#p#

NAME

FETCH - retrieve rows from a query using a cursor

SYNOPSIS

FETCH [ direction { FROM | IN } ] cursorname

where direction can be empty or one of:

    NEXT
    PRIOR
    FIRST
    LAST
    ABSOLUTE count
    RELATIVE count
    count
    ALL
    FORWARD
    FORWARD count
    FORWARD ALL
    BACKWARD
    BACKWARD count
    BACKWARD ALL

DESCRIPTION

FETCH retrieves rows using a previously-created cursor.

A cursor has an associated position, which is used by FETCH. The cursor position can be before the first row of the query result, on any particular row of the result, or after the last row of the result. When created, a cursor is positioned before the first row. After fetching some rows, the cursor is positioned on the row most recently retrieved. If FETCH runs off the end of the available rows then the cursor is left positioned after the last row, or before the first row if fetching backward. FETCH ALL or FETCH BACKWARD ALL will always leave the cursor positioned after the last row or before the first row.

The forms NEXT, PRIOR, FIRST, LAST, ABSOLUTE, RELATIVE fetch a single row after moving the cursor appropriately. If there is no such row, an empty result is returned, and the cursor is left positioned before the first row or after the last row as appropriate.

The forms using FORWARD and BACKWARD retrieve the indicated number of rows moving in the forward or backward direction, leaving the cursor positioned on the last-returned row (or after/before all rows, if the count exceeds the number of rows available).

RELATIVE 0, FORWARD 0, and BACKWARD 0 all request fetching the current row without moving the cursor, that is, re-fetching the most recently fetched row. This will succeed unless the cursor is positioned before the first row or after the last row; in which case, no row is returned.  

PARAMETERS

direction
direction defines the fetch direction and number of rows to fetch. It can be one of the following:
NEXT
Fetch the next row. This is the default if direction is omitted.
PRIOR
Fetch the prior row.
FIRST
Fetch the first row of the query (same as ABSOLUTE 1).
LAST
Fetch the last row of the query (same as ABSOLUTE -1).
ABSOLUTE count
Fetch the count'th row of the query, or the abs(count)'th row from the end if count is negative. Position before first row or after last row if count is out of range; in particular, ABSOLUTE 0 positions before the first row.
RELATIVE count
Fetch the count'th succeeding row, or the abs(count)'th prior row if count is negative. RELATIVE 0 re-fetches the current row, if any.
count
Fetch the next count rows (same as FORWARD count).
ALL
Fetch all remaining rows (same as FORWARD ALL).
FORWARD
Fetch the next row (same as NEXT).
FORWARD count
Fetch the next count rows. FORWARD 0 re-fetches the current row.
FORWARD ALL
Fetch all remaining rows.
BACKWARD
Fetch the prior row (same as PRIOR).
BACKWARD count
Fetch the prior count rows (scanning backwards). BACKWARD 0 re-fetches the current row.
BACKWARD ALL
Fetch all prior rows (scanning backwards).
count
count is a possibly-signed integer constant, determining the location or number of rows to fetch. For FORWARD and BACKWARD cases, specifying a negative count is equivalent to changing the sense of FORWARD and BACKWARD.
cursorname
An open cursor's name.

OUTPUTS

On successful completion, a FETCH command returns a command tag of the form

FETCH count

The count is the number of rows fetched (possibly zero). Note that in psql, the command tag will not actually be displayed, since psql displays the fetched rows instead.  

NOTES

The cursor should be declared with the SCROLL option if one intends to use any variants of FETCH other than FETCH NEXT or FETCH FORWARD with a positive count. For simple queries PostgreSQL will allow backwards fetch from cursors not declared with SCROLL, but this behavior is best not relied on. If the cursor is declared with NO SCROLL, no backward fetches are allowed.

ABSOLUTE fetches are not any faster than navigating to the desired row with a relative move: the underlying implementation must traverse all the intermediate rows anyway. Negative absolute fetches are even worse: the query must be read to the end to find the last row, and then traversed backward from there. However, rewinding to the start of the query (as with FETCH ABSOLUTE 0) is fast.

Updating data via a cursor is currently not supported by PostgreSQL.

DECLARE [declare(7)] is used to define a cursor. Use MOVE [move(7)] to change cursor position without retrieving data.  

EXAMPLES

The following example traverses a table using a cursor.

BEGIN WORK;

-- Set up a cursor:
DECLARE liahona SCROLL CURSOR FOR SELECT * FROM films;

-- Fetch the first 5 rows in the cursor liahona:
FETCH FORWARD 5 FROM 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 the previous row:
FETCH PRIOR FROM liahona;

 code  |  title  | did | date_prod  |  kind  |  len
-------+---------+-----+------------+--------+-------
 P_301 | Vertigo | 103 | 1958-11-14 | Action | 02:08

-- Close the cursor and end the transaction:
CLOSE liahona;
COMMIT WORK;

COMPATIBILITY

The SQL standard defines FETCH for use in embedded SQL only. This variant of FETCH described here returns the data as if it were a SELECT result rather than placing it in host variables. Other than this point, FETCH is fully upward-compatible with the SQL standard.

The FETCH forms involving FORWARD and BACKWARD, as well as the forms FETCH count and FETCH ALL, in which FORWARD is implicit, are PostgreSQL extensions.

The SQL standard allows only FROM preceding the cursor name; the option to use IN is an extension.

責(zé)任編輯:韓亞珊 來(lái)源: CMPP.net
相關(guān)推薦

2011-08-15 10:21:09

man中文man

2011-08-24 16:48:36

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-08-11 15:03:21

ACCESS中文man

2011-08-11 15:28:43

ali中文man

2011-08-11 16:31:49

biff中文man

2011-08-11 17:16:43

cce中文man

2011-08-11 18:05:04

chvt中文man

2011-08-11 18:13:07

clear中文man

2011-08-12 09:13:02

df中文man

2011-08-12 09:38:06

dircolors中文man

2011-08-12 09:44:37

dirname中文man

2011-08-12 10:20:02

echo中文man

2011-08-12 10:25:55

eject中文man

2011-08-12 11:07:19

git中文man

2011-08-12 13:18:19

head中文man

2011-08-12 13:49:23

hostid中文man

2011-08-12 13:54:46

hostname中文man

2011-08-12 14:53:56

kill中文man
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)

主站蜘蛛池模板: 国产精品久久久久久久久污网站 | 亚洲欧美在线一区 | 久久亚洲综合 | 亚洲精品一区中文字幕乱码 | 国产日韩免费视频 | 久草欧美 | 国产欧美在线播放 | 欧美日韩国产欧美 | 呦呦在线视频 | 999久久久久久久 | 日韩精品a在线观看图片 | 亚洲欧美久久 | 亚洲精品日韩综合观看成人91 | 久久精品免费 | 九九热精品在线 | 日韩在线精品视频 | 欧美日韩一区不卡 | 国产一级免费视频 | 国产精品一区二区不卡 | 亚洲国产片 | 99久久精品国产一区二区三区 | 久久久久一区 | 亚洲精品乱码久久久久久按摩 | 成人在线视频免费看 | 精品久久精品 | 中文字幕在线一区二区三区 | 韩日一区二区 | 亚洲综合无码一区二区 | 成人精品国产一区二区4080 | 精品美女视频在线观看免费软件 | 国产精品久久精品 | 国产精品99久久久久久大便 | 观看av| av午夜电影| 亚洲二区视频 | 欧美一区二区三区四区视频 | 精品一区二区三区电影 | 91精品国产91久久久久游泳池 | 日本电影一区二区 | 国产成人网 | 欧美精品一区在线 |