Re: Plpgsql function with unknown number of args

From: Tony Caduto <tony_caduto(at)amsoftwaredesign(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Plpgsql function with unknown number of args
Date: 2005-04-19 01:17:14
Message-ID: 42645C1A.6090807@amsoftwaredesign.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2005-04-19 02:15:18 Re: PostgreSQL as a filesystem
Previous Message Steve - DND 2005-04-19 00:55:56 PG utilities won't prompt for password after Win32 8.0.2 upgrade