From: Thomas Kellerer <shammat@gmx.net>
To: pgsql-general@lists.postgresql.org
Cc: Muthukumar.GK <muthankumar@gmail.com>
Subject: Re: Calling Procedure from another procedure in Postgres
Date: Wed, 2 Dec 2020 11:55:49 +0100
Message-ID: <d68f1678-f769-a9fe-e548-799f9ecb2c1d@gmx.net> (raw)
In-Reply-To: <CA+rAWgn5UKvrT+aN=s_E_ysXxhKRPcxTK5KfTKjF27xZeg+fmA@mail.gmail.com>
References: <CA+rAWgn5UKvrT+aN=s_E_ysXxhKRPcxTK5KfTKjF27xZeg+fmA@mail.gmail.com>
Muthukumar.GK schrieb am 02.12.2020 um 11:20:
> I need to call the procedure(not function) and insert the records
> into a temporary table from another procedure in postgres. When
> executing the procedure 'Sampleproc2',I got some below syntax error.
> Kindly let me know whether postgres supports this functionality or
> any other way of calling the procedure from another procedure.
> CREATE OR REPLACE PROCEDURE SampleProc1()
> as $$
> declare
> c1 refcursor:='result1';
> begin
> open c1 for
> select approverid,assigntoid,effstdt,effenddtfrom tblApproverreassign;
> end;
> $$
> language plpgsql;
>
> INSERT INTO TMPApproverAssign
> *CALL SampleProc1(); *
You need to make sampleproc1 a set returning _function_, then you can do:
INSERT INTO TMPApproverAssign
select *
from sampleproc1();
Procedures aren't meant to return stuff, that's what functions are for.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: shammat@gmx.net, muthankumar@gmail.com
Subject: Re: Calling Procedure from another procedure in Postgres
In-Reply-To: <d68f1678-f769-a9fe-e548-799f9ecb2c1d@gmx.net>
References: <CA+rAWgn5UKvrT+aN=s_E_ysXxhKRPcxTK5KfTKjF27xZeg+fmA@mail.gmail.com> <d68f1678-f769-a9fe-e548-799f9ecb2c1d@gmx.net>
* 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