Re: How to add a function that returns the result of a select statement? - Mailing list pgadmin-support

From ben sewell
Subject Re: How to add a function that returns the result of a select statement?
Date
Msg-id bf6c74d80608180444v45f55d67j4edb960305ae2ad7@mail.gmail.com
Whole thread Raw
In response to How to add a function that returns the result of a select statement?  (Gibson <gibson@nexgenstudio.com>)
Responses Re: How to add a function that returns the result of a select statement?
List pgadmin-support
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@nexgenstudio.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

pgadmin-support by date:

Previous
From: Gibson
Date:
Subject: How to add a function that returns the result of a select statement?
Next
From: Henry Andres Sanabria Fuentes
Date:
Subject: Re: How to add a function that returns the result of a select statement?