pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Elisha Allen <elisha@unm.edu>
To: pgsql-docs@postgresql.org
Subject: 9.7. Table Functions
Date: Fri, 5 Sep 2003 14:34:48 -0600
Message-ID: <009101c373ed$35b7b0a0$57481881@maelstrom> (raw)

Hello,

I hope I am posting this to the approprate list. I am somewhat new to postgres, 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 used the following commands to test this:

CREATE TABLE foo (fooid int, foosubid int, fooname text);
 
 CREATE FUNCTION getfoo(int) RETURNS setof foo AS '
     SELECT * FROM foo WHERE fooid = $1;
 ' LANGUAGE SQL;
 
 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, rather than a recordset of columns and values as the documentation suggests when 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 any assistance in trouble shooting this issue/ updating the documentation on this issue.

Elisha

view thread (2+ messages)  latest in thread

Message-ID: <009101c373ed$35b7b0a0$57481881@maelstrom>
Permalink:  ../009101c373ed$35b7b0a0$57481881@maelstrom/
Also on:    postgresql.org/message-id/009101c373ed$35b7b0a0$57481881@maelstrom

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: elisha@unm.edu
  Subject: Re: 9.7. Table Functions
  In-Reply-To: <009101c373ed$35b7b0a0$57481881@maelstrom>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox