他のバージョンの文書 15 | 14 | 13 | 12 | 11 | 10 | 9.6 | 9.5 | 9.4 | 9.3 | 9.2 | 9.1 | 9.0 | 8.4 | 8.3 | 8.2 | 8.1 | 8.0 | 7.4 | 7.3 | 7.2

dblink_get_result

名前

dblink_get_result -- 非同期問い合わせの結果を入手します

概要

    dblink_get_result(text connname [, bool fail_on_error]) returns setof record
   

説明

dblink_get_resultは、事前にdblink_send_queryで送信された非同期問い合わせの結果を収集します。 問い合わせがまだ完了していなかった場合、dblink_get_resultは終わるまで待機します。

引数

conname

使用する接続名です。

fail_on_error

真(省略時のデフォルト)の場合、接続のリモート側で発生したエラーによりローカル側でもエラーが発生します。 偽の場合リモート側のエラーはローカル側にはNOTICEとして報告され、この関数は行を返しません。

戻り値

非同期問い合わせ(行を返すSQL文の場合)について、この関数は問い合わせで生成された行を返します。 この関数を使用するためには、上のdblinkで説明したように想定する列集合を指定する必要があります。

非同期問い合わせ(行を返さないSQL文の場合)について、この関数はk万度の状態文字列からなるテキスト列を1つ持つ1行を返します。 この場合も呼び出し元のFROM句で結果が単一のテキスト列を持つことを指定する必要があります。

注釈

dblink_send_queryが1を返した場合にこの関数を呼び出さなければなりません。 接続を再度利用できるようになる前に、送信した問い合わせに対し一度呼び出されなければなりません。 もう一度実行すると空の結果集合を得ることになります。

 contrib_regression=#   SELECT dblink_connect('dtest1', 'dbname=contrib_regression');
  dblink_connect
 ----------------
  OK
 (1 row)

 contrib_regression=#   SELECT * from
 contrib_regression-#    dblink_send_query('dtest1', 'select * from foo where f1 < 3') as t1;
  t1
 ----
   1
 (1 row)

 contrib_regression=#   SELECT * from dblink_get_result('dtest1') as t1(f1 int, f2 text, f3 text[]);
  f1 | f2 |     f3
 ----+----+------------
   0 | a  | {a0,b0,c0}
   1 | b  | {a1,b1,c1}
   2 | c  | {a2,b2,c2}
 (3 rows)

 contrib_regression=#   SELECT * from dblink_get_result('dtest1') as t1(f1 int, f2 text, f3 text[]);
  f1 | f2 | f3
 ----+----+----
 (0 rows)

 contrib_regression=#   SELECT * from
    dblink_send_query('dtest1', 'select * from foo where f1 < 3; select * from foo where f1 > 6') as t1;
  t1
 ----
   1
 (1 row)

 contrib_regression=#   SELECT * from dblink_get_result('dtest1') as t1(f1 int, f2 text, f3 text[]);
  f1 | f2 |     f3
 ----+----+------------
   0 | a  | {a0,b0,c0}
   1 | b  | {a1,b1,c1}
   2 | c  | {a2,b2,c2}
 (3 rows)

 contrib_regression=#   SELECT * from dblink_get_result('dtest1') as t1(f1 int, f2 text, f3 text[]);
  f1 | f2 |      f3
 ----+----+---------------
   7 | h  | {a7,b7,c7}
   8 | i  | {a8,b8,c8}
   9 | j  | {a9,b9,c9}
  10 | k  | {a10,b10,c10}
 (4 rows)

 contrib_regression=#   SELECT * from dblink_get_result('dtest1') as t1(f1 int, f2 text, f3 text[]);
  f1 | f2 | f3
 ----+----+----
 (0 rows)