X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 53C28D1B461 for ; Thu, 15 Jan 2004 04:23:28 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 03282-07 for ; Thu, 15 Jan 2004 00:22:56 -0400 (AST) Received: from nycsmtp3out.rdc-nyc.rr.com (nycsmtp3out.rdc-nyc.rr.com [24.29.99.224]) by svr1.postgresql.org (Postfix) with ESMTP id D2FF8D1DA2C for ; Thu, 15 Jan 2004 00:22:55 -0400 (AST) Received: from usa.net (68-174-8-114.si.rr.com [68.174.8.114]) by nycsmtp3out.rdc-nyc.rr.com (8.12.10/Road Runner SMTP Server 1.0) with ESMTP id i0F4MfOf007684; Wed, 14 Jan 2004 23:22:41 -0500 (EST) Message-ID: <4006159F.5000505@usa.net> Date: Wed, 14 Jan 2004 23:22:55 -0500 From: kjw User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6b) Gecko/20031208 X-Accept-Language: en-us, en, ja MIME-Version: 1.0 To: Peter Eisentraut Cc: pgsql-interfaces@postgresql.org, pg@fastcrypt.com Subject: Re: ECPG and EXEC SQL GET DIAGNOSTICS References: <3FFF47D7.90100@usa.net> <200401100151.12626.peter_e@gmx.net> In-Reply-To: <200401100151.12626.peter_e@gmx.net> Content-Type: multipart/mixed; boundary="------------070506060909030406020403" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/7 X-Sequence-Number: 4676 This is a multi-part message in MIME format. --------------070506060909030406020403 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit To all, Thanks for responding to my question and sorry for the delay in answering your reply. Informix ESQLC (9.2.1 ) has functionality that allows you to get the status of a previously excecuted sql statement. /* there can be more than 1 exception, the "1" in the following example refers to the 1st exception" */ EXEC SQL get diagnostics exception 1 :_srvrname = SERVER_NAME, :_sqlstate_code = RETURNED_SQLSTATE, :_message = MESSAGE_TEXT, :_messlen = MESSAGE_LENGTH; This would place the DB Server name, Error message text (if any) and the length of the error message into the respective host variables. This statement would compile and run under informix but fail when compiled with ecpg (3.1.0/PostgreSQL 7.4.1) with the following error code. "test.pgc:19: ERROR: syntax error at or near "diagnostics" " Compilation command: "ecpg -c -C INFORMIX test.pgc" I have attached test.pgc Thanks to all, ken Peter Eisentraut wrote: >kjw wrote: > > >>I am currently thinking about porting >>Embedded esql/c code from informix to >>PostgreSQL. It there any plans on incorporating >>the "EXEC SQL GET DIAGNOSTICS" functionality? >> >> > >It's already there. What is missing? > > >---------------------------(end of broadcast)--------------------------- >TIP 4: Don't 'kill -9' the postmaster > >. > > > --------------070506060909030406020403 Content-Type: text/plain; name="test.pgc" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="test.pgc" /* * compiles using informix esql 9.2.1 compiler but does not compile * using ecpg 3.1.0(PostgreSQL 7.4.1) */ int main (int argc, char **argv) { /* Declare host variables */ EXEC SQL BEGIN DECLARE SECTION; char _ix_database_name[30]; int exception_count; char _message[100]; EXEC SQL END DECLARE SECTION; /* Connect to the database. */ EXEC SQL CONNECT TO 'test_db'; EXEC SQL get diagnostics :exception_count = NUMBER ; /* * The GET DIAGNOSTICS statement also returns information about the * exceptions that the most-recently executed SQL statement has generated. */ EXEC SQL get diagnostics exception 1 :_message = MESSAGE_TEXT; return (0); } --------------070506060909030406020403--