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;

Reply via email to