From: | Hemil Ruparel <hemilruparel2002(at)gmail(dot)com> |
---|---|
To: | "Muthukumar(dot)GK" <muthankumar(at)gmail(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Calling Procedure from another procedure in Postgres |
Date: | 2020-12-02 10:34:22 |
Message-ID: | CANW1aT-YAdYHFc6SF71Bq4FZFgXvmeJbUxn_jBBWaeAQ=Fyi4Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
insert into <table> is not valid
On Wed, Dec 2, 2020 at 3:50 PM Muthukumar.GK <muthankumar(at)gmail(dot)com> wrote:
> Hi team,
>
> 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;
>
>
> -------------------------------------------------------------------------------------------------------------
>
> CREATE OR REPLACE PROCEDURE SampleProc2()
>
> as $$
>
> declare c1 refcursor:='result1';
>
> begin
>
> CREATE TEMP TABLE TMPApproverAssign
>
> ( approverid VARCHAR(10),
>
> assigntoid VARCHAR(10),
>
> effstdt timestamptz,
>
> effenddt timestamptz
>
> ) ON COMMIT DROP;
>
>
>
> INSERT INTO TMPApproverAssign
>
> *CALL SampleProc1(); *
>
>
> open c1 for
>
> select approverid,assigntoid,effstdt,effenddtfrom TMPApproverAssign;
>
> end;
>
> $$
>
> language plpgsql;
>
>
> ---------------------------------------------------------------------------------------------
>
> Error : syntax error at or near "CALL"
>
> LINE 12 : ^CALL SampleProc1();
>
> SQL state : 42601
>
> Character:453
>
> ------------------------------------------------------------------
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2020-12-02 10:39:25 | Re: Calling Procedure from another procedure in Postgres |
Previous Message | Muthukumar.GK | 2020-12-02 10:20:14 | Calling Procedure from another procedure in Postgres |