Re: About a PL/pgSQL function - Mailing list pgsql-admin

From Joel Burton
Subject Re: About a PL/pgSQL function
Date
Msg-id Pine.LNX.4.30.0206061239340.12975-100000@temp.joelburton.com
Whole thread Raw
In response to About a PL/pgSQL function  (Ferdinand Smit <ferdinand@telegraafnet.nl>)
List pgsql-admin
On Thu, 6 Jun 2002, Ferdinand Smit wrote:

> When i create a function with a "static" table name, it works fine.
> EXECUTE does not allow SELECT INTO, so does anyone have an other solution?

Use:

DECLARE
  cursorname refcursor;
  varname int;
BEGIN
  OPEN cursorname FOR EXECUTE ''SELECT ... FROM '' || $1 || ...;
  FETCH cursorname INTO varname;
  CLOSE cursorname;
  RETURN varname;
END;


--

Joel BURTON  |  joel@joelburton.com  |  joelburton.com  |  aim: wjoelburton
Independent Knowledge Management Consultant


pgsql-admin by date:

Previous
From: Ferdinand Smit
Date:
Subject: About a PL/pgSQL function
Next
From: Oliver Elphick
Date:
Subject: Re: [GENERAL] performance issue using DBI