Re: [SQL] postgres subfunction return error

2013-09-27 Thread jonathansfl
I'm trying to pass a REFCURSOR variable from a subfunction to its parent calling function, who will then pass it to the user (for parsing). thanks to David J I fixed it somewhat, but the user now receives the TEXT of (etc.) instead of the actual data in that REFCURSOR variable. I think the proble

[SQL] Can I simplify this somehow?

2013-09-27 Thread Larry Rosenman
I tried(!) to write this as a with (CTE), but failed. Can one of the CTE experts (or better SQL writer) help me here? -- generate a table of timestamps to match against select generate_series(date_trunc('day',now()-'45 days'::interval),now()+'1 hour'::inte rval,'1 hour') AS thetime into te

Re: [SQL] postgres subfunction return error

2013-09-27 Thread David Johnston
jonathansfl wrote > SELECT * INTO v_outvar1, v_outvar2, v_outvar3 FROM > custom.pr_test_subfunction(SWV_Action); > OPEN swv_refcur for SELECT v_outvar1; > OPEN swv_refcur2 for SELECT v_outvar2; > OPEN swv_refcur3 for SELECT v_outvar3; > RETURN; I've never used cursors in this

Re: [SQL] Can I simplify this somehow?

2013-09-27 Thread Adam Jelinek
Are you looking for something like this for the result for the last 45 days or something else? TIME MON TUE WED ... 09:00 13 4 10:00 50 8 On Fri, Sep 27, 2013 at 10:22 AM, Larry Rosenman wrote: > I tried(!) to write this as a with (CTE), but failed. > >

Re: [SQL] Can I simplify this somehow?

2013-09-27 Thread Larry Rosenman
On 2013-09-27 14:24, Adam Jelinek wrote: Are you looking for something like this for the result for the last 45 days or something else? TIME  MON   TUE  WED ... 09:00     1        3       4 10:00     5        0       8 That would be cool, but just a list is good too. -- Larry Rosenman

Re: [SQL] postgres subfunction return error

2013-09-27 Thread jonathansfl
Hurray, that works! Many thanks David CREATE OR REPLACE FUNCTION custom.pr_test_parentfunction ( v_action varchar, out swv_refcur refcursor, out swv_refcur2 refcursor, out swv_refcur3 refcursor ) RETURNS record AS $body$ DECLARE SWV_Action VARCHAR(50) DEFAULT Coalesce(v_Act

Re: [SQL] Can I simplify this somehow?

2013-09-27 Thread Sergey Konoplev
On Fri, Sep 27, 2013 at 12:32 PM, Larry Rosenman wrote: > On 2013-09-27 14:24, Adam Jelinek wrote: >> TIME MON TUE WED ... >> 09:00 13 4 >> 10:00 50 8 >> > That would be cool, but just a list is good too. You need to take a look at this module: http://