Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VPfBK-0005Wb-Fq for pgsql-sql@arkaria.postgresql.org; Fri, 27 Sep 2013 21:02:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VPfBJ-0005Dh-RE for pgsql-sql@arkaria.postgresql.org; Fri, 27 Sep 2013 21:02:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VPfBJ-0005DU-36 for pgsql-sql@postgresql.org; Fri, 27 Sep 2013 21:02:33 +0000 Received: from sam.nabble.com ([216.139.236.26]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VPfBF-0001cd-Rl for pgsql-sql@postgresql.org; Fri, 27 Sep 2013 21:02:32 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1VPfBE-0003GK-NE for pgsql-sql@postgresql.org; Fri, 27 Sep 2013 14:02:28 -0700 Date: Fri, 27 Sep 2013 14:02:28 -0700 (PDT) From: jonathansfl To: pgsql-sql@postgresql.org Message-ID: <01a001cebbc4$ced17260$6c745720$@com> In-Reply-To: <1380303751878-5772627.post@n5.nabble.com> References: <1380150677632-5772407.post@n5.nabble.com> <1380293836468-5772613.post@n5.nabble.com> <1380303751878-5772627.post@n5.nabble.com> Subject: Re: postgres subfunction return error MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_260031_5308577.1380315748712" X-Pg-Spam-Score: 1.8 (+) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org ------=_Part_260031_5308577.1380315748712 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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_Action,'1'); v_outvar1 REFCURSOR; v_outvar2 REFCURSOR; v_outvar3 REFCURSOR; BEGIN SELECT * INTO v_outvar1, v_outvar2, v_outvar3 FROM custom.pr_test_subfunction(SWV_Action); swv_refcur = v_outvar1; swv_refcur2 = v_outvar2; swv_refcur3 = v_outvar3; RETURN; END; $body$ LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER COST 100; From: David Johnston [via PostgreSQL] [mailto:ml-node+s1045698n5772627h95@n5.nabble.com] Sent: Friday, September 27, 2013 1:43 PM To: jonathansfl Subject: Re: postgres subfunction return error 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 way so my help is more theory but: The called-function already created the cursors. In the parent function you should simply be able to pass them through unaltered: SELECT * INTO v_outvar1, ...; swv_refcur := v_outvar1; ... ... RETURN; You can possible simply the above and toss the temporary variables but that should not impact the semantics. David J. _____ If you reply to this email, your message will be added to the discussion below: http://postgresql.1045698.n5.nabble.com/postgres-subfunction-return-error-tp 5772407p5772627.html To unsubscribe from postgres subfunction return error, click here . NAML -- View this message in context: http://postgresql.1045698.n5.nabble.com/postgres-subfunction-return-error-tp5772407p5772658.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com. ------=_Part_260031_5308577.1380315748712 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: quoted-printable

Hurray, that works!

= Many thanks David

<= o:p> 

CREATE OR REPLACE FU= NCTION 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_Action,'1');

   v_outvar1 REFCURSOR; v_outvar2 REFCURSOR; v_outvar3 RE= FCURSOR;

BEGIN<= /span>

    SELECT * INTO v_ou= tvar1, v_outvar2, v_outvar3 FROM custom.pr_test_subfunction(SWV_Action);

   

    swv_refcur=    =3D v_outvar1;

    swv_refcur2  =3D v_outvar2;

=

    swv_refcur3  =3D v_outv= ar3;

 

    RETURN;

END;

$body$

LANG= UAGE 'plpgsql'

VOLATILE

CALLED ON NULL INPUT

SECURITY INVOKER

COST 100;

 

= From:= David Johnston [via PostgreSQL] [mailto:[hidden email]]
Sent: Friday, September 27, 2013 1= :43 PM
To: jonathansfl
Subject: Re: postgres subfunctio= n return error

 <= /o:p>

<= b>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;
&n= bsp;   OPEN swv_refcur3 for SELECT v_outvar3;
    RETURN= ;

I've never used cursors in this way so my help is more t= heory but:

The called-function already created the cursors.  I= n the parent function you should simply be able to pass them through unalte= red:

SELECT * INTO v_outvar1, ...;
swv_refcur :=3D v_outvar1; <= br>...
...
RETURN;

You can possible simply the above and to= ss the temporary variables but that should not impact the semantics.
David J.


If yo= u reply to this email, your message will be added to the discussion below:<= o:p>

click here.
<= span style=3D'font-size:7.0pt;font-family:"Times New Roman","serif"'>NAML

=09 =09 =09

View this message in context: RE: postgre= s subfunction return error
Sent from the PostgreSQL - sql mailing list archive at Nabble.com= .
------=_Part_260031_5308577.1380315748712--