Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkPng-0005vS-ML for pgsql-general@arkaria.postgresql.org; Wed, 02 Dec 2020 10:55:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kkPnf-0003i2-6l for pgsql-general@arkaria.postgresql.org; Wed, 02 Dec 2020 10:55:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkPne-0003fV-TI for pgsql-general@lists.postgresql.org; Wed, 02 Dec 2020 10:55:54 +0000 Received: from mout.gmx.net ([212.227.15.15]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkPnc-0001IK-KB for pgsql-general@lists.postgresql.org; Wed, 02 Dec 2020 10:55:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1606906550; bh=4M3GL696D4DokQkwxJItbCiNPBXz1NEDTpsT2re4Wsc=; h=X-UI-Sender-Class:Subject:To:References:Cc:From:Date:In-Reply-To; b=GYb5Xdcyxv/13s/eJ4TH7b35cfQjjsMgcuB5DafEZ1GapTFL0N/pNYANE7u4IRtAg /1Mm6B5N3S2hrHPuYISQNcw5pusPpGgtgv3qwfQxbk8eXkmRExPL932wAgAGRuUn2G Pwq+1d193mHReX8KE1ZkM4QR9kR0/TGQfEEVln2k= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [10.1.35.166] ([185.40.248.10]) by mail.gmx.com (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MmlT2-1kITIG06y6-00jqs2; Wed, 02 Dec 2020 11:55:50 +0100 Subject: Re: Calling Procedure from another procedure in Postgres To: pgsql-general@lists.postgresql.org References: Cc: "Muthukumar.GK" From: Thomas Kellerer Message-ID: Date: Wed, 2 Dec 2020 11:55:49 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:JihhotGpDUdVvWTarJwIVUqVCfn64vT41fzfAtZy8OKs26wnwVZ 7jEBBcuce9vgMeiOzcFE9QLDhTC99xv/b+aZyzMcLDYObiMUJvf7eu2rj2BsIonGtZERAaD z7XOzOWNbjtoWsUbIaFpsTPGwA1Nq7aTYdri96Nd5SHbtMaWTVKNMMLqpD4MRzeZ1aTSAEm L0xPuqGYeyiE57eJN1Hzw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:NhxV0qvJDLA=:JiU23IsdYAJloxPEFcELJo tr/3uXRkalxWrTQJOqshWPctdVsQmWF0vgSXWTD1TA8mnykTjOavEe6jLTDa+WWE3G0Y9c3DX gtRGESfboVwhR12IglzmuOuExl6HVjUowvgEaefIudFr3ldtWNZ57sCEjd+H5xwQzLbrSO2Ii Y4G4riJzAC88TIgV0v16kLZj7lajYXkoOJ0phEAjHoJZd5Dl754segGbsYOkhFfURCW5kLxv+ b63CCFeynFAgMSLXNVwxI+goY2eLslYWZ10MJBT6SIBJ7CmWZCI0BY+QhK671l/bz84LqVJN3 Y09yPw5P9xBAlR+/13l4XzuPqeXlcDWv5W16U97M4o452ChrUJPY+6IIlbBtgxIv/fAtmUwy2 mZDR9C9XUj8ujhMQEtDJY9OQjd2DbKzJn+J8uW6cJyGyLJGlhRKb93ETbGSEpjuXU9QFes0e+ BYQAxFreA5co04MQNtog1xgsDputTDT+G1DJ4t4BicxsmnrXtkr5Zsv/V0WJUcoUoGi1ULiRy MH5hTHEqag7ux7bHMQ8ft+vKR3QznZmB48qb6XknpkMLnCo3/1KzZ1o4QtMOSyzaZF/knXvnl ayibfB/ghK5Zexo17LOytZYY5wU4mcK61PhaZvWHUSccNupytUfamMhYj+Knd49DwwLJiTt88 Ws1ri+dhNJjmC+xYAClOw35lyRplKkRCHQGq1s+0rMpPIq8w0drpfLR3SMbcB3buRO1Z/JyeF rFvr1LaSTHmeGWpuQdGsGcL2+wnqQwVJnpBU4saqj5GFDpz4uxRhEBPDKJ89RZLn++L1KJXTt dKu3GEAyEQuxBaOHNyhKYs8HrncGYxY3peouSDwCTxp0gfQCtyWvYLfVxMJUH9s6Kq/iqVD7m y57ZxwJDo6Q5PF1Zw+Vw== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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()=C2=A0=C2=A0=C2=A0=C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0as=C2=A0 =C2=A0=C2=A0$$ > =C2=A0=C2=A0=C2=A0=C2=A0declare > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0c1=C2=A0refcursor:=3D'result1'= ;=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 > =C2=A0=C2=A0=C2=A0=C2=A0begin > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0open c1 for > =C2=A0=C2=A0=C2=A0=C2=A0select=C2=A0approverid,assigntoid,effstdt,effend= dtfrom tblApproverreassign; > =C2=A0=C2=A0=C2=A0=C2=A0end; > =C2=A0=C2=A0=C2=A0=C2=A0$$ > =C2=A0=C2=A0=C2=A0=C2=A0language=C2=A0plpgsql; > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0INSERT INTO=C2=A0TMPApproverAssign > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0*CALL SampleProc1();=C2=A0 =C2=A0 =C2=A0* 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.