psql sqlstate return code access - Mailing list pgsql-general

From Little, Doug C
Subject psql sqlstate return code access
Date
Msg-id DD0B11E67A9F2045AC02E1CFD7771C67ED5E96@NR1PWPGLCD1C.rb.win.frb.org
Whole thread Raw
Responses Re: psql sqlstate return code access  (Luca Ferrari <fluca1978@infinito.it>)
List pgsql-general

Hi,

 

I have a requirement to log into a table the completion code for each statement being submitted in a psql script.

 

I've looked around and can't seem to find how to access the sqlstate completion code.     Is there a system variable in psql  available or some other trick to get it?

 

For example 

 

insert into x select … from y;

 

insert into log(message, code,timestamp)  values('insert into x',:SQLSTATE,now());

 

where :SQLSTATE contains the completion code of the prior statement.

 

Thanks in advance

 

 

 

Doug Little

 

pgsql-general by date:

Previous
From: "Ruth Melendo"
Date:
Subject: how to recovery your database when stops replicating
Next
From: Rob Richardson
Date:
Subject: Update using non-existent fields does not throw an error