pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: cyw@dls.net
To: pgsql-general@postgresql.org
Subject: PLSQL function calling another function
Date: Thu, 9 Oct 2008 09:26:11 -0500
Message-ID: <092C17F5803E42FCAFD8D3A43A2E5A12@nc05072019> (raw)
References: <d8e7a1e30810090623i7766fc50xb46fc3e5efa3836@mail.gmail.com>

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;

view thread (2+ messages)  latest in thread

Message-ID: <092C17F5803E42FCAFD8D3A43A2E5A12@nc05072019>
Permalink:  ../092C17F5803E42FCAFD8D3A43A2E5A12@nc05072019/
Also on:    postgresql.org/message-id/092C17F5803E42FCAFD8D3A43A2E5A12@nc05072019

 · 

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-admin@postgresql.org
  Cc: cyw@dls.net, pgsql-general@postgresql.org
  Subject: Re: PLSQL function calling another function
  In-Reply-To: <092C17F5803E42FCAFD8D3A43A2E5A12@nc05072019>

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

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