pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: kjw <kenneth69@usa.net>
To: Peter Eisentraut <peter_e@gmx.net>
Cc: pgsql-interfaces@postgresql.org
Cc: pg@fastcrypt.com
Subject: Re: ECPG and EXEC SQL GET DIAGNOSTICS
Date: Wed, 14 Jan 2004 23:22:55 -0500
Message-ID: <4006159F.5000505@usa.net> (raw)
In-Reply-To: <200401100151.12626.peter_e@gmx.net>
References: <3FFF47D7.90100@usa.net>
	<200401100151.12626.peter_e@gmx.net>

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
>
>.
>
>  
>
/* 
 * 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);
}	
	

Attachments:

  [text/plain] test.pgc (691B, ../4006159F.5000505@usa.net/2-test.pgc)
  download | inline:
/* 
 * 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);
}	
	

view thread (6+ messages)  latest in thread

Message-ID: <4006159F.5000505@usa.net>
Permalink:  ../4006159F.5000505@usa.net/
Also on:    postgresql.org/message-id/4006159F.5000505@usa.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: kenneth69@usa.net, peter_e@gmx.net, pg@fastcrypt.com
  Subject: Re: ECPG and EXEC SQL GET DIAGNOSTICS
  In-Reply-To: <4006159F.5000505@usa.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox