Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id BDB1237C764 for ; Thu, 9 Oct 2008 11:25:18 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 85680-05 for ; Thu, 9 Oct 2008 11:25:07 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mx01.dls.net (mx01.dls.net [216.145.245.197]) by postgresql.org (Postfix) with ESMTP id 51DFE37C10E for ; Thu, 9 Oct 2008 11:25:08 -0300 (ADT) Received: from sch-fw25.delcan.net ([12.96.29.18] helo=nc05072019) by mx01.dls.net with esmtpa (Exim 4.63) (envelope-from ) id 1KnwRs-0001fM-WE for pgsql-general@postgresql.org; Thu, 09 Oct 2008 09:25:05 -0500 Message-ID: <092C17F5803E42FCAFD8D3A43A2E5A12@nc05072019> From: To: References: Subject: PLSQL function calling another function Date: Thu, 9 Oct 2008 09:26:11 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0080_01C929F1.11574940" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.001 tagged_above=0 required=5 tests=FB_WORD1_END_DOLLAR=1, HTML_MESSAGE=0.001 X-Spam-Level: * X-Archive-Number: 200810/322 X-Sequence-Number: 138572 This is a multi-part message in MIME format. ------=_NextPart_000_0080_01C929F1.11574940 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi All, I am trying to figure out how to call one PLSQL function from another, = specifically how to access the return values from the callee. I made two test functions, A and B. A calls B. B returns two values: =20 OUT tid integer OUT msg character varying In caller function A, I do the following: SELECT B(1) INTO rec; -- rec declared as a RECORD RAISE DEBUG 'XXX % [%]', rec.tid, rec.msg; The runtime error I got was: ERROR: record "rec" has no field "tid" SQL state: 42703 The full function code is below. Thanks, CYW -------------------------------- FUNCTION B(IN id integer, OUT tid integer, OUT msg character varying) = RETURNS record AS BODY$ DECLARE BEGIN msg :=3D 'MSG'; tid :=3D 100; RETURN; END; FUNCTION A(IN x integer, IN "text" character varying, OUT whatever = character varying) RETURNS character varying AS $BODY$ DECLARE rec RECORD; tid int4; msg varchar; BEGIN SELECT B(1) INTO rec; RAISE DEBUG 'XXX % [%]', rec.tid, rec.msg; RETURN; END; ------=_NextPart_000_0080_01C929F1.11574940 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi All,
 
I am trying to figure out how to call = one PLSQL=20 function from another, specifically how to access the return values from = the=20 callee.
 
I made two test functions, A and B. A = calls=20 B.
 
B returns two values:   =
          &nbs= p;    =20 OUT tid integer
          &nbs= p;    =20 OUT msg character varying
 
In caller function A, I do the=20 following:
          &nbs= p;     SELECT=20 B(1) INTO rec;       -- rec declared as a=20 RECORD
          &nb= sp;    =20 RAISE DEBUG 'XXX %   [%]', rec.tid, rec.msg;

The runtime error I got = was:
 
          &nbs= p;     =20 ERROR: record "rec" has no field=20 "tid"
          &nbs= p;     =20 SQL state: 42703
 
The full function code is = below.
 
Thanks,
CYW
 
 
 
 
 
 
--------------------------------
FUNCTION B(IN id integer, OUT tid = integer, OUT msg=20 character varying)   RETURNS record AS = BODY$
DECLARE
BEGIN
 msg :=3D = 'MSG';
 tid :=3D=20 100;
 RETURN;
END;
 
FUNCTION A(IN x integer, IN "text" = character=20 varying, OUT whatever character varying)  RETURNS character varying = AS=20 $BODY$
DECLARE
 rec RECORD;
 tid int4;
 msg=20 varchar;
BEGIN
 SELECT B(1) INTO rec;
 RAISE DEBUG = 'XXX=20 %   [%]', rec.tid,=20 rec.msg;
 RETURN;
END;
------=_NextPart_000_0080_01C929F1.11574940--