Re: Get the last sql error

From: Bartosz Dmytrak <bdmytrak(at)gmail(dot)com>
To: Erik Ande <Erik(dot)Ande(at)muthpartners(dot)de>
Cc: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Get the last sql error
Date: 2013-06-11 14:04:27
Message-ID: CAD8_UcZ+O1qmUM8y6rNTvW74atfd=4ZNN+WqfZM04SW8gVDwUQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

2013/6/5 Erik Ande <Erik(dot)Ande(at)muthpartners(dot)de>

> @@error

Hi,
assuming:*
*
1. definition*: "**Returns an error number if the previous statement
encountered an error.*" by
http://msdn.microsoft.com/en-us/library/ms188790.aspx
2. last (? - maybe first) error in current transaction
3. You use plpgsql

You can use GET STACKED DIAGNOSTICS (
http://www.postgresql.org/docs/9.2/static/plpgsql-control-structures.html#PLPGSQL-EXCEPTION-DIAGNOSTICS)
I think full BEGIN...EXCEPTION...END will do the work for you.

Regards,
Bartek

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Sergey Konoplev 2013-06-11 19:48:05 Re: DB design advice
Previous Message Toni Alfirević 2013-06-11 09:48:50 Re: DB design advice