PLPGSQL SETOF functions

From: David Greco <David_Greco(at)harte-hanks(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: PLPGSQL SETOF functions
Date: 2011-06-28 18:34:30
Message-ID: CDFA9340E95A764E9366B4EDF3A43125C8F47A685F@VA3DIAXVS091.RED001.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am porting some Oracle code to PLPGSQL and am having a problem with functions that return SETOF datatype. In Oracle, the functions I'm porting return a TABLE of TYPE datatype, this TABLE being itself a named type. I am not aware of how to do this in PLPGSQL.

Consider a function with header:
CREATE OR REPLACE FUNCTION dates_pkg.getbusinessdays(pstartdate timestamp with time zone, penddate timestamp with time zone) RETURNS SETOF timestamp with time zone AS

I can easily call this function in SQL like so:
select * from dates_pkg.getbusinessdays( now(), now() + INTERVAL '7' day ) as business_day;

However, I can't figure out how to call this function from another plpgsql function. Any hints?

~Dave Greco

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Smith 2011-06-28 20:37:54 Re: rationale behind quotes for camel case?
Previous Message dennis jenkins 2011-06-28 16:09:52 Re: rationale behind quotes for camel case?