From: | gustavo halperin <ggh(dot)develop(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Create function problem |
Date: | 2006-08-04 15:44:16 |
Message-ID: | 44D36B50.7070906@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Michael Fuhr wrote:
> [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
What do you mean with the word "record", can you give an example of how
this "record" looks for two columns ?
Thank you,
Gustavo
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2006-08-04 15:49:06 | Re: [NOVICE] pg_dump sequence problem |
Previous Message | Tom Lane | 2006-08-04 15:32:01 | Re: pg_dump sequence problem |