X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0D118529E2 for ; Tue, 2 Aug 2005 12:32:57 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28145-09 for ; Tue, 2 Aug 2005 15:32:53 +0000 (GMT) Received: from isis.sigpipe.cz (fw.sigpipe.cz [62.245.70.224]) by svr1.postgresql.org (Postfix) with ESMTP id 28E09529D2 for ; Tue, 2 Aug 2005 12:32:51 -0300 (ADT) Received: by isis.sigpipe.cz (Postfix, from userid 1001) id B22EF1F87BEF; Tue, 2 Aug 2005 17:32:48 +0200 (CEST) Date: Tue, 2 Aug 2005 17:32:48 +0200 From: Roman Neuhauser To: pgsql-docs@postgresql.org Subject: "FETCH returns data as if it were a SELECT result" Message-ID: <20050802153248.GA5320@isis.sigpipe.cz> Mail-Followup-To: pgsql-docs@postgresql.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.467 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL, UPPERCASE_25_50 X-Spam-Level: * X-Archive-Number: 200508/1 X-Sequence-Number: 3163 "The variant of FETCH described here returns the data as if it were a SELECT result rather than placing it in host variables." http://www.postgresql.org/docs/current/static/sql-fetch.html That doesn't seem to be the case. Try the following script: CREATE TABLE t1 (t1i INT, t1c CHAR(1)); CREATE TABLE t2 (t2i INT, t2c CHAR(1)); INSERT INTO t1 VALUES (1, 'a'); INSERT INTO t1 VALUES (2, 'b'); INSERT INTO t1 VALUES (3, 'c'); BEGIN; INSERT INTO t2 (SELECT * FROM t1); SELECT * FROM t2; ROLLBACK; BEGIN; DECLARE c1 CURSOR FOR SELECT * FROM t1; INSERT INTO t2 (FETCH ALL FROM c1); ROLLBACK; The output I get: CREATE TABLE CREATE TABLE INSERT 19110 1 INSERT 19111 1 INSERT 19112 1 BEGIN INSERT 0 3 t2i | t2c -----+----- 1 | a 2 | b 3 | c (3 rows) ROLLBACK BEGIN DECLARE CURSOR psql:tmp/fetch-is-unlike-select.sql:15: ERROR: syntax error at or near "ALL" at character 23 psql:tmp/fetch-is-unlike-select.sql:15: LINE 1: INSERT INTO t2 (FETCH ALL FROM c1); psql:tmp/fetch-is-unlike-select.sql:15: ^ ROLLBACK This is on PostgreSQL 8.0.3 on i386-portbld-freebsd4.11, compiled by GCC 2.95.4 -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991