Re: Plpgsql function with unknown number of args - Mailing list pgsql-general

From Tony Caduto
Subject Re: Plpgsql function with unknown number of args
Date
Msg-id 42645C1A.6090807@amsoftwaredesign.com
Whole thread Raw
In response to Re: Plpgsql function with unknown number of args  ("Relyea, Mike" <Mike.Relyea@xerox.com>)
List pgsql-general
You don't have to cast it as anything, just return a refcursor from your
function.

Say you return a refcursor called return_cursor

select myfunction(your_in_array);
fetch all from return_cursor;

If you are calling from a development environment, you put the return
value of the fuction (the refcursor name) into a variable, then
dynamicly build the fetch
all statement from return value of the function.  This must be done in
the context of a transaction, i.e. both statements must must be executed
in the same transaction.

The refcursors work really well and are very flexible.

Relyea, Mike wrote:

>Thanks for the input.  This looks very promising.  I have one further
>question.  My SQL statement is going to pull data from more than one
>table in a relatively complex query.  How do I cast the RETURNS portion
>of the function?  Again, I can't find what I'm looking for in the docs.
>I've included an actual sample SQL statement.  I will only be changing
>the first portion of the WHERE clause.
>
>



pgsql-general by date:

Previous
From: "Steve - DND"
Date:
Subject: PG utilities won't prompt for password after Win32 8.0.2 upgrade
Next
From: "Andy Kopciuch"
Date:
Subject: Re: tsearch2