From elisha@unm.edu Mon Jun 8 05:07:36 2026 X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AA5D7D1B8BB for ; Fri, 5 Sep 2003 20:35:35 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 23223-10 for ; Fri, 5 Sep 2003 17:35:03 -0300 (ADT) Received: from izar.unm.edu (izar.unm.edu [129.24.9.34]) by svr1.postgresql.org (Postfix) with SMTP id 8A0B8D1B8A5 for ; Fri, 5 Sep 2003 17:35:02 -0300 (ADT) Received: (qmail 1588 invoked by uid 124); 5 Sep 2003 14:34:56 -0600 Received: from elisha@unm.edu by mail.unm.edu by uid 121 with qmail-scanner-1.16 (csav: version 4.75.1 deffiles-20030904 Clear:. Processed in 0.371129 secs); 05 Sep 2003 20:34:56 -0000 Received: from csel-0169.unm.edu (HELO maelstrom) (129.24.72.87) by izar.unm.edu with SMTP; 5 Sep 2003 14:34:55 -0600 Message-ID: <009101c373ed$35b7b0a0$57481881@maelstrom> From: "Elisha Allen" To: Subject: 9.7. Table Functions Date: Fri, 5 Sep 2003 14:34:48 -0600 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_008E_01C373BA.DB8D55D0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.6 tagged_above=0.0 required=5.0 tests=BAYES_30, HTML_30_40, RCVD_IN_OSIRUSOFT_COM X-Spam-Level: X-Archive-Number: 200309/23 X-Sequence-Number: 1979 This is a multi-part message in MIME format. ------=_NextPart_000_008E_01C373BA.DB8D55D0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello, I hope I am posting this to the approprate list. I am somewhat new to postg= res, and have been extensively reading the documentation over the last few = days. As a whole, it is very helpful and informative. Great work! Today I came across the following issue with table functions: I'm trying to write a table function that returns a recordset. I'm running = postgres 7.3.3 on redhat Following postgres Documentation Chapter 9.7, I u= sed the following commands to test this: CREATE TABLE foo (fooid int, foosubid int, fooname text); =20 CREATE FUNCTION getfoo(int) RETURNS setof foo AS ' SELECT * FROM foo WHERE fooid =3D $1; ' LANGUAGE SQL; =20 SELECT * FROM getfoo(1) AS t1; Unfortunately, the command: SELECT * FROM getfoo(1) AS t1; returns a: server parse error at or near "(" Is there something I'm missing here? As a workaround I tried: SELECT getfoo(1) AS t1; This command ran, but returned a row t1 with a series of numbers in it, rat= her than a recordset of columns and values as the documentation suggests wh= en it says: "If the function returns a composite type, the result columns get the same = names as the individual attributes of the type." Thank you very much for your help, and please let me know if I can be of an= y assistance in trouble shooting this issue/ updating the documentation on = this issue. Elisha ------=_NextPart_000_008E_01C373BA.DB8D55D0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello,
 
I hope I am posting this to the approprate= list. I=20 am somewhat new to postgres, and have been extensively reading the document= ation=20 over the last few days. As a whole, it is very helpful and informative. Gre= at=20 work!
 
Today I came across the following issue wi= th table=20 functions:
 
I'm trying to write a table function that = returns a=20 recordset. I'm running postgres 7.3.3 on redhat Following postgres=20 Documentation Chapter 9.7,  I used the following commands to test=20 this:
 
CREATE TABLE foo (fooid int, foosubid int, fooname text);

CRE= ATE=20 FUNCTION getfoo(int) RETURNS setof foo AS '
     SEL= ECT *=20 FROM foo WHERE fooid =3D $1;
' LANGUAGE SQL;

SELECT * FROM get= foo(1)=20 AS t1;
 
Unfortunately, the command:
 
 SELECT * FROM getfoo(1) AS t1;
 
returns a:
 
server parse error at or near "("
 
Is there something I'm missing here? As a= =20 workaround I tried:
 
 SELECT getfoo(1) AS t1;
 
This command ran, but returned a row t1 wi= th a=20 series of numbers in it, rather than a recordset of columns and values as t= he=20 documentation suggests when it says:
 
"I= f the=20 function returns a composite type, the result columns get the same names as= the=20 individual attributes of the type."
 
Thank you very much for your help, and ple= ase let=20 me know if I can be of any assistance in trouble shooting this issue/ updat= ing=20 the documentation on this issue.
 
Elisha
------=_NextPart_000_008E_01C373BA.DB8D55D0-- From tgl@sss.pgh.pa.us Mon Jun 8 05:07:36 2026 X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 97F1FD1B8E7 for ; Fri, 5 Sep 2003 23:33:02 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 38539-04 for ; Fri, 5 Sep 2003 20:32:53 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id A77DDD1B8B7 for ; Fri, 5 Sep 2003 20:32:51 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h85NWqAn026808; Fri, 5 Sep 2003 19:32:52 -0400 (EDT) To: "Elisha Allen" Cc: pgsql-docs@postgresql.org Subject: Re: 9.7. Table Functions In-reply-to: <009101c373ed$35b7b0a0$57481881@maelstrom> References: <009101c373ed$35b7b0a0$57481881@maelstrom> Comments: In-reply-to "Elisha Allen" message dated "Fri, 05 Sep 2003 14:34:48 -0600" Date: Fri, 05 Sep 2003 19:32:52 -0400 Message-ID: <26807.1062804772@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/24 X-Sequence-Number: 1980 "Elisha Allen" writes: > Unfortunately, the command: > SELECT * FROM getfoo(1) AS t1; > returns a: > server parse error at or near "(" Works fine here. You sure you are talking to a 7.3 server? 7.2 or before would reject it just that way. regards, tom lane