A question about "table function" - Mailing list pgsql-general

From Yuan Lin
Subject A question about "table function"
Date
Msg-id b562uc$1nul$1@news.hub.org
Whole thread Raw
Responses Re: A question about "table function"  (Joe Conway <mail@joeconway.com>)
List pgsql-general
hi, all:

   When I see the following definitions from postgresql document. I am
completely puzzeled.

CREATE TABLE foo (fooid int, foosubid int, fooname text);

>> As I say it, foo is already a set of columns.

CREATE FUNCTION getfoo(int) RETURNS setof foo AS '
    SELECT * FROM foo WHERE fooid = $1;
' LANGUAGE SQL;

>> here return type should be "setof setof foo".

----------------------------------------------------------------------------
-----------------
Can I rewrite the definition as follows:

CREATE TYPE foo (fooid int, foosubid int, fooname text);

CREATE FUNCTION getfoo(int) RETURNS setof foo AS '
    SELECT * FROM foo WHERE fooid = $1;
' LANGUAGE SQL;

----------------------------------------------------------------------------
-------------------

any comments are appriciate.

JACK DULL




pgsql-general by date:

Previous
From: "Kev Martin"
Date:
Subject: newbie going round in circle
Next
From: Trevor Bylsma
Date:
Subject: postmaster has high CPU (system) utilization