Unix Technical Forum

finding the sql-statement in esql

This is a discussion on finding the sql-statement in esql within the Informix forums, part of the Database Server Software category; --> Hi, how can I get the created sql-statement after an error. I have written an error-function and esql calls ...


Go Back   Unix Technical Forum > Database Server Software > Informix

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 09:12 PM
Steffen Koehler
 
Posts: n/a
Default finding the sql-statement in esql

Hi,

how can I get the created sql-statement after an error. I have written
an error-function and esql calls this function after an error (EXEC SQL
WHENEVER SQLERROR CALL ...). In this function I get the errornumber and
the errortext from sqlca. But where stands the last sql-statement which
create this error.

thanks for help
Steffen
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 09:12 PM
Jonathan Leffler
 
Posts: n/a
Default Re: finding the sql-statement in esql

Steffen Koehler wrote:
> how can I get the created sql-statement after an error. I have written
> an error-function and esql calls this function after an error (EXEC SQL
> WHENEVER SQLERROR CALL ...). In this function I get the errornumber and
> the errortext from sqlca. But where stands the last sql-statement which
> create this error.


It isn't available. You have to go through all sorts of chicanery to
achieve that - so much so I have never actually bothered to do it. If
I was going to, I'd probably grab the code from my esqlfmt program
(available as part of sqlfmt from the IIUG Software Archive - it's
indexed under I4GL because it also includes an I4GL cross-referencer),
and use it to extract the SQL statements, and generate some
corresponding code around the actual statement. Maybe:

{
static const char sql[] = "...sql statement found by esqlfmt code...";
EXEC SQL ...sql statement found by esqlfmt code...;
if (sqlca.sqlcode != 0)
err_reporter(..., sql, ..., __LINE__, __FILE__, ...);
}

Or something along those lines. That's simple and reliable because it
is under your control. Alternatively, post-process the C code before
running the C compiler, and place your error handling code inside the
generated C code, using the statement text defined by ESQL/C. That's
more subject to the vagaries of the code generator, though - but
reduces the amount of memory required since you only have one copy of
each statement instead of two.

--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:26 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com