Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UNk24-0000kN-Ai for pgsql-sql@arkaria.postgresql.org; Thu, 04 Apr 2013 13:16:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UNk23-0002Tw-Hw for pgsql-sql@arkaria.postgresql.org; Thu, 04 Apr 2013 13:16:47 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UNk22-0002To-Hc for pgsql-sql@postgresql.org; Thu, 04 Apr 2013 13:16:46 +0000 Received: from mail-da0-x22a.google.com ([2607:f8b0:400e:c00::22a]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UNk1v-0006sA-Py for pgsql-sql@postgresql.org; Thu, 04 Apr 2013 13:16:45 +0000 Received: by mail-da0-f42.google.com with SMTP id n15so1127904dad.1 for ; Thu, 04 Apr 2013 06:16:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=LNqAXra1cD3adzAnHKxzinx989OVaMByXv67Nn3QM+o=; b=Z0xw4DaK6ochVo79GVV4ws/w6kqULN9PxmWhUJDLdi63yHyH19Gs7An2fhbQcYDxLn cJGArdbdMDTDQv16fs8mQC8sj4SMv1EEZy7GVS0xluqy5YqtY2L9SHd3VUcJdEq1zy9/ 1pwCy+i/8MmTb0uvcRn9sEaYr7SwyLipbPZGRpsoJuEYQMLevnelX4IHWBi571rDuJZ0 CGY/I+OuZHAUXrxnFgwDEcPbMItOiQq7tRXluxfnk7YHwNHFjlddg2122xJ3ohI8ZfTR hCRCHKJO/9ZYNlmGXoiONQx/9/feFKgGfs7b726dJjfbemXVflHchPOt4/DE11zsyqjd ti2g== X-Received: by 10.68.242.132 with SMTP id wq4mr8538551pbc.160.1365081398488; Thu, 04 Apr 2013 06:16:38 -0700 (PDT) Received: from [192.168.1.2] (97-113-5-86.tukw.qwest.net. [97.113.5.86]) by mx.google.com with ESMTPS id hp1sm11488270pac.3.2013.04.04.06.16.36 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Apr 2013 06:16:37 -0700 (PDT) Message-ID: <515D7D33.6080802@gmail.com> Date: Thu, 04 Apr 2013 06:16:35 -0700 From: Adrian Klaver User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: Kaleeswaran Velu CC: "pgsql-sql@postgresql.org" Subject: Re: Postgres trigger issue with update statement in it. References: <1365048506.78628.YahooMailNeo@web163902.mail.gq1.yahoo.com> In-Reply-To: <1365048506.78628.YahooMailNeo@web163902.mail.gq1.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org On 04/03/2013 09:08 PM, Kaleeswaran Velu wrote: > > Hello Friends, > I am new to Postgres DB. Recently installed Postgres 9.2. > Facing an issue with very simple trigger, tried to resolve myself by > reading documents or google search but no luck. > > I have a table A(parent) and table B (child). There is a BEFORE INSERT > OR UPDATE trigger attached in table B. This trigger has a update > statement in it. This update statement should update a respective record > in table A when ever there is any insert/update happen in table B. The > issue here is where ever I insert/update record in table B, getting an > error as below : > > ********** Error ********** > ERROR: cannot begin/end transactions in PL/pgSQL > SQL state: 0A000 > Hint: Use a BEGIN block with an EXCEPTION clause instead. > Context: PL/pgSQL function func_update_payment() line 53 at SQL statement > > Line no 53 in the above error message is an update statement. If I > comment out the update statement, trigger works fine. > > Can anyone shed some lights on this? Your help is appreciated. Without seeing the actual code it is a guess, but here it goes. From this: ERROR: cannot begin/end transactions in PL/pgSQL I would say you tried to create a transaction in the function. Could be you wrote BEGIN; instead of BEGIN ... END; > > Thanks and Regards > Kaleeswaran Velu -- Adrian Klaver adrian.klaver@gmail.com -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql