PLSQL function calling another function - Mailing list pgsql-general

From
Subject PLSQL function calling another function
Date
Msg-id 092C17F5803E42FCAFD8D3A43A2E5A12@nc05072019
Whole thread Raw
In response to logging SQL statements  ("c k" <shreeseva.learning@gmail.com>)
Responses Re: PLSQL function calling another function
List pgsql-general
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:  
                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 := 'MSG';
 tid := 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;

pgsql-general by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: databases list to file
Next
From: Jeff Ross
Date:
Subject: Re: databases list to file