pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Create Function (SQL)
2+ messages / 2 participants
[nested] [flat]

* Create Function (SQL)
@ 2006-11-05 06:21  Mark Simon <mark@manngo.net>
  0 siblings, 1 reply; 2+ messages in thread

From: Mark Simon @ 2006-11-05 06:21 UTC (permalink / raw)
  To: pgsql-sql

I am trying to create a simple function using SQL rather than PGSQL. At 
this point, it's just for the exercise.

Is it possible to create a function similar to the following:

    create function thing(text) as select * from whatever where id=$1;

Do I need to specify all of the columns from the table (whatever) as out 
parameters, or as a return type, or can I have a generic table returned 
from this?

Thanks,

Mark
-- 


  Mark Simon

Manngo Net Pty Ltd

Phone/Fax: 1300 726 000
mobile: 0411 246 672

email: mark@manngo.net <mailto:mark@comparity.net>
web: http://www.manngo.net

Resume: http://mark.manngo.net

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Create Function (SQL)
@ 2006-11-05 11:59  imad <immaad@gmail.com>
  parent: Mark Simon <mark@manngo.net>
  0 siblings, 0 replies; 2+ messages in thread

From: imad @ 2006-11-05 11:59 UTC (permalink / raw)
  To: Mark Simon <mark@manngo.net>; +Cc: pgsql-sql

You can return a record:

create function thing(text) returns record as 'select * from whatever
where id=$1' language sql;

Hope this helps.

--Imad
www.EnterpriseDB.com



On 11/5/06, Mark Simon <mark@manngo.net> wrote:
>
>  I am trying to create a simple function using SQL rather than PGSQL. At
> this point, it's just for the exercise.
>
>  Is it possible to create a function similar to the following:
>
>      create function thing(text) as select * from whatever where id=$1;
>
>  Do I need to specify all of the columns from the table (whatever) as out
> parameters, or as a return type, or can I have a generic table returned from
> this?
>
>  Thanks,
>
>  Mark
>
> --
>
>
> Mark Simon
>
> Manngo Net Pty Ltd
>
> Phone/Fax: 1300 726 000
>  mobile: 0411 246 672
>
> email: mark@manngo.net
>  web: http://www.manngo.net
>
> Resume: http://mark.manngo.net



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2006-11-05 11:59 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-11-05 06:21 Create Function (SQL) Mark Simon <mark@manngo.net>
2006-11-05 11:59 ` imad <immaad@gmail.com>

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