Re: Return type for procedure

From: "ben sewell" <mosherben(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org, systemguards(at)gmail(dot)com
Subject: Re: Return type for procedure
Date: 2006-08-16 08:41:27
Message-ID: bf6c74d80608160141o4f60f0b6h5eb3566c08ef739d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi Jaime,
thanks for your reply.

Could anyone check if this is correct for what I'm trying to do

CREATE FUNCTION test(id integer,name varchar,date_start date date_end date)
RETURNS record as $$
$$ language 'your-language';

if id="1" then
select * from tblemployee;
elseif id="2" then
select client_name,address
from tblclients;
endif

and then execute the function as

select * from test() as (report1, report2)

would this work? This is just example code for select statements which are
far much longer

Cheers,
Ben

On 8/16/06, Jaime Casanova <systemguards(at)gmail(dot)com> wrote:
>
> >
> > What I was wondering was if it was possible for me to return different
> user
> > defined types. To try to illustrate what I mean, here's some example
> code
> > which I think is allowed:
> >
>
> yes.
>
> just create your functions as:
>
> CREATE FUNCTION test() RETURNS record as $$
> $$ language 'your-language';
>
> then execute the function as
>
> select * from test() as (field1 type1, field2 type2...);
>
> --
> regards,
> Jaime Casanova
>
> "Programming today is a race between software engineers striving to
> build bigger and better idiot-proof programs and the universe trying
> to produce bigger and better idiots.
> So far, the universe is winning."
> Richard Cook
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message ben sewell 2006-08-16 08:57:02 Re: Optimal Postgres Development Process, Software
Previous Message Roger Rasmussen 2006-08-16 08:01:07 Re: Optimal Postgres Development Process, Software