Re: Create function problem

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: gustavo halperin <ggh(dot)develop(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Create function problem
Date: 2006-08-04 14:50:45
Message-ID: 20060804145045.GA76467@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

[Please copy the mailing list on replies so others can contribute
to and learn from the discussion.]

On Fri, Aug 04, 2006 at 11:20:55AM +0300, gustavo halperin wrote:
> Michael Fuhr wrote:
> >You've hardcoded the strings 'v_tbl_schm' and 'v_tbl_name' instead
> >of using the function's arguments. I don't think SQL functions
> >support named arguments so you'll need to use $1 and $2. You'll
> >also need to use "RETURNS SETOF record" if you want to return more
> >than one row.
> >
> *OK thank you, I did it. But I receive actually one row, same as you
> say, and I need a set of rows for two columns. I don't know how to use
> 'RETURNS SETOF' for two columns, This is possible ??, see the function
> below:*
> /CREATE OR REPLACE FUNCTION f_describe_tables (text, text
> OUT text, OUT text) as -- How to use RETURNS SETOF with *two text columns*??
> $$ SELECT c.column_name, c.data_type
> FROM information_schema.columns c
> WHERE c.table_schema = $1 AND c.table_name = $2
> $$ LANGUAGE SQL;/

Since the function has OUT parameters you can use "RETURNS SETOF record"
like this:

CREATE FUNCTION funcname(<params>) RETURNS SETOF record AS $$
<body>
$$ LANGUAGE SQL;

--
Michael Fuhr

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2006-08-04 14:50:55 Re: PostgreSQL engagment
Previous Message Merlin Moncure 2006-08-04 14:42:48 Re: Well, Pervasive is now out....