From: | <cyw(at)dls(dot)net> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | PLSQL function calling another function |
Date: | 2008-10-09 14:26:11 |
Message-ID: | 092C17F5803E42FCAFD8D3A43A2E5A12@nc05072019 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin 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;
From | Date | Subject | |
---|---|---|---|
Next Message | Rafael Domiciano | 2008-10-09 15:02:57 | Re: checkpoint_timeout |
Previous Message | c k | 2008-10-09 13:23:42 | logging SQL statements |
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Ross | 2008-10-09 14:26:44 | Re: databases list to file |
Previous Message | A. Kretschmer | 2008-10-09 14:20:24 | Re: databases list to file |