Re: How to add a function that returns the result of a select statement?

From: Henry Andres Sanabria Fuentes <hensa22(at)yahoo(dot)es>
To: ben sewell <mosherben(at)gmail(dot)com>, Gibson <gibson(at)nexgenstudio(dot)com>, pgadmin-support(at)postgresql(dot)org
Subject: Re: How to add a function that returns the result of a select statement?
Date: 2006-08-19 01:51:28
Message-ID: 20060819015128.68473.qmail@web30808.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

You have to use RETURNS refcursor
to return a cursor.
ben sewell <mosherben(at)gmail(dot)com> escribió:
Hi Gibson,
you need to add into and add a variable assuming your using plpgsql.

create or replace function function_name() returns user as'
begin
declare rec user;
select into rec * from user;
return rec;
end;
'language ' plpgsql';

This should work, I had the same problem the other day.

Regards,
Ben

On 8/18/06, Gibson <gibson(at)nexgenstudio(dot)com> wrote: Hi,

I've tried using the "New function" option to create a new SQL function
that will return the result of a select statement "Select * from user".
I've set the return type to be the "user" table. But i keep getting an
error about "Syntax error at or near Select". My SQL statement is very
simple "select * from user" so there is no syntax error. Anyone can help?
--

Cheers
Gibson Tang
Game Programmer
179, River Valley Building #04-09
Singapore 179033
Nexgen Studio <www.nexgenstudio.com>

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq


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

LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com

In response to

Browse pgadmin-support by date

  From Date Subject
Next Message Gibson 2006-08-21 07:02:17 Select statement doesn't work in Query tool
Previous Message ben sewell 2006-08-18 11:44:29 Re: How to add a function that returns the result of a select statement?