agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: jonathansfl <jonathanbrinkman@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Re: postgres subfunction return error
Date: Fri, 27 Sep 2013 14:02:28 -0700 (PDT)
Message-ID: <01a001cebbc4$ced17260$6c745720$@com> (raw)
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>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

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
<http://postgresql.1045698.n5.nabble.com/template/NamlServlet.jtp?macro=unsu
bscribe_by_code&node=5772407&code=am9uYXRoYW5icmlua21hbkB5YWhvby5jb218NTc3Mj
QwN3wtNDQ0Mzc4MjI4> .
 
<http://postgresql.1045698.n5.nabble.com/template/NamlServlet.jtp?macro=macr
o_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.B
asicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.templ
ate.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-insta
nt_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
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.

view thread (6+ messages)

Message-ID: <01a001cebbc4$ced17260$6c745720$@com>
Permalink:  ../01a001cebbc4$ced17260$6c745720$@com/
Also on:    postgresql.org/message-id/01a001cebbc4$ced17260$6c745720$@com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jonathanbrinkman@yahoo.com
  Subject: Re: postgres subfunction return error
  In-Reply-To: <01a001cebbc4$ced17260$6c745720$@com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox