Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!wieslauf.sub.de!.POSTED!reversiblemaps.ath.cx!not-for-mail From: Jasen Betts Newsgroups: comp.databases.postgresql Subject: Re: SQL state / Date: 30 Apr 2011 10:54:06 GMT Organization: Dis (not Dat) Organisation Lines: 30 Message-ID: References: NNTP-Posting-Host: Wk8PyTvLHfx9YaNov58aSw.user.wieslauf.sub.de Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@wieslauf.sub.de NNTP-Posting-Date: Sat, 30 Apr 2011 11:00:36 +0000 (UTC) User-Agent: slrn/pre1.0.0-18 (Linux) X-Notice: Filtered by postfilter v. 0.8.1 X-Face: ?)Aw4rXwN5u0~$nqKj`xPz>xHCwgi^q+^?Ri*+R(&uv2=E1Q0Zk(>h!~o2ID@6{uf8s;a +M[5[U[QT7xFN%^gR"=tuJw%TXXR'Fp~W;(T"1(739R%m0Yyyv*gkGoPA.$b,D.w:z+<'"=-lVT?6 {T?=R^:W5g|E2#EhjKCa+nt":4b}dU7GYB*HBxn&Td$@f%.kl^:7X8rQWd[NTc"P"u6nkisze/Q;8 "9Z{peQF,w)7UjV$c|RO/mQW/NMgWfr5*$-Z%u46"/00mx-,\R'fLPe.)^ Cancel-Lock: sha1:HlAwwG0VXcZAHfcL79u4XDQBoU0= Xref: x330-a1.tempe.blueboxinc.net comp.databases.postgresql:101 On 2011-04-26, Dog is love wrote: > Hi, > > I was trying to trap the SQL States as listed in > > http://www.postgresql.org/docs/8.2/static/errcodes-appendix.html > > in a normal pg/plsql script but I can't seem to do it....is it only > possible to do this in Embedded SQL ? I think you need to use the keyword in plpgsql. in plpgsql I think you need to use the constants like this: EXCEPTION WHEN io_error OR undefined_file THEN > I do not want to test the error code, I only want to pass it back to a > JAVA front end. postgres should pass the error code to the client automatically if the error is not trapped. I don't know how JAVA represents SQL errors. In python I get an exception object containing. among other things the SQL error code. eg: if I do "select 1/0;" I get an exception raised and "22012" (which means dizision by zero) as the error code -- ⚂⚃ 100% natural