sqlca.sqlcode = -27000 DOES NOT STOP 4GL EXECUTION
Posted in 2013
User reported that a CONNECT statement in 4GL returning sqlca.sqlcode = -27000 (connection error) does not stop program execution as expected. Responders suggested WHENEVER ERROR STOP directive, but user reported it didn't work. The practical workaround provided was to explicitly check sqlca.sqlcode and call exit program if negative. Suspected bug in CONNECT statement error handling when added to I4GL.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
Topics: Stored Procedures & SPL, Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL
Hello, I'm using ipcshm connection (deliberately incorrect; I should use tlitcp connection instead) in my 4gl program to test DATABASE & CONNECT statement concurrently. This is the code: database stores7 main database stores7 display sqlca.sqlcode connect to 'stores7' display sqlca.sqlcode end main When I execute the connect statement it fails with sqlca.sqlcode = -27000 but not stops execution. I thought that a negative sqlcode value stopped 4gl execution. Does anyone know the answer to that uncommon behaviour? Thanks a lot. Joan Roca
Juan use a whenever error stop . ------------------------------ On Mon, May 13, 2013 6:43 AM ART JUAN ROCA wrote: >Hello, >I'm using ipcshm connection (deliberately incorrect; I should use tlitcp >connection instead) in my 4gl program to test DATABASE & CONNECT statement >concurrently. > >This is the code: > >database stores7 >main >database stores7 >display sqlca.sqlcode >connect to 'stores7' >display sqlca.sqlcode >end main > >When I execute the connect statement it fails with sqlca.sqlcode = -27000 but >not stops execution. > >I thought that a negative sqlcode value stopped 4gl execution. > >Does anyone know the answer to that uncommon behaviour? > >Thanks a lot. > >Joan Roca > > >******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. >
Thanks Ignacio, I've tried whenever error stop but hasn't work. I've also tried -anyerr option in the fglpc compiler and still hasn't work.
Whether the WHENEVER ERROR works properly or not is kind of aside. The solution for handling the error is to add: if (sqlca.sqlcode < 0) then display "Error connecting to the database:', sqlca.sqlcode exit program end if Art Art S. Kagel Advanced DataTools (www.advancedatatools.com) Blog: http://informix-myview.blogspot.com/ Disclaimer: Please keep in mind that my own opinions are my own opinions and do not reflect on my employer, Advanced DataTools, the IIUG, nor any other organization with which I am associated either explicitly, implicitly, or by inference. Neither do those opinions reflect those of other individuals affiliated with any entity with which I am affiliated nor those of the entities themselves. On Mon, May 13, 2013 at 5:43 AM, JUAN ROCA <jluis.roca@hotmail.com> wrote: > Hello, > I'm using ipcshm connection (deliberately incorrect; I should use tlitcp > connection instead) in my 4gl program to test DATABASE & CONNECT statement > concurrently. > > This is the code: > > database stores7 > main > database stores7 > display sqlca.sqlcode > connect to 'stores7' > display sqlca.sqlcode > end main > > When I execute the connect statement it fails with sqlca.sqlcode = -27000 > but > not stops execution. > > I thought that a negative sqlcode value stopped 4gl execution. > > Does anyone know the answer to that uncommon behaviour? > > Thanks a lot. > > Joan Roca > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --14dae93d97080603cf04dc998ee7
Unless my memory is failing me, by default I4GL behaves as if WHENEVER ERROR CONTINUE is effect. If you add WHENEVER ERROR STOP and I4GL (or I4GL-RDS) does not stop when that error occurs, it is a bug; it should stop. If there's a bug, there is also a simple workaround as noted by Art until the bug is fixed test the value of SQLCODE after the connection attempt. It is likely that the problem will have been created when CONNECT et al were added to I4GL. The vast majority of statements will work as expected. On Mon, May 13, 2013 at 2:43 AM, JUAN ROCA <jluis.roca@hotmail.com> wrote: > Hello, > I'm using ipcshm connection (deliberately incorrect; I should use tlitcp > connection instead) in my 4gl program to test DATABASE & CONNECT statement > concurrently. > > This is the code: > > database stores7 > main > database stores7 > display sqlca.sqlcode > connect to 'stores7' > display sqlca.sqlcode > end main > > When I execute the connect statement it fails with sqlca.sqlcode = -27000 > but > not stops execution. > > I thought that a negative sqlcode value stopped 4gl execution. > > Does anyone know the answer to that uncommon behaviour? > > Thanks a lot. > > Joan Roca > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > -- Jonathan Leffler <jonathan.leffler@gmail.com> #include <disclaimer.h> Guardian of DBD::Informix - v2013.0118 - http://dbi.perl.org "Blessed are we who can laugh at ourselves, for we shall never cease to be amused." --047d7b621d9ccb376704dc9afe91
Isn't it set up so that WHENEVER ERROR STOP is default, but some minor errors continue anyway? I think to stop on every error you need to set WHENEVER ANY ERROR STOP. --EEM -----Original Message----- From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of Jonathan Leffler Sent: Monday, May 13, 2013 10:16 AM To: ids@iiug.org Subject: Re: sqlca.sqlcode = -27000 DOES NOT STOP 4GL E.... [30257] Unless my memory is failing me, by default I4GL behaves as if WHENEVER ERROR CONTINUE is effect. If you add WHENEVER ERROR STOP and I4GL (or I4GL-RDS) does not stop when that error occurs, it is a bug; it should stop. If there's a bug, there is also a simple workaround as noted by Art until the bug is fixed - test the value of SQLCODE after the connection attempt. It is likely that the problem will have been created when CONNECT et al were added to I4GL. The vast majority of statements will work as expected. On Mon, May 13, 2013 at 2:43 AM, JUAN ROCA <jluis.roca@hotmail.com> wrote: > Hello, > I'm using ipcshm connection (deliberately incorrect; I should use > tlitcp connection instead) in my 4gl program to test DATABASE & > CONNECT statement concurrently. > > This is the code: > > database stores7 > main > database stores7 > display sqlca.sqlcode > connect to 'stores7' > display sqlca.sqlcode > end main > > When I execute the connect statement it fails with sqlca.sqlcode = > -27000 but not stops execution. > > I thought that a negative sqlcode value stopped 4gl execution. > > Does anyone know the answer to that uncommon behaviour? > > Thanks a lot. > > Joan Roca > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > -- Jonathan Leffler <jonathan.leffler@gmail.com> #include <disclaimer.h> Guardian of DBD::Informix - v2013.0118 - http://dbi.perl.org "Blessed are we who can laugh at ourselves, for we shall never cease to be amused." --047d7b621d9ccb376704dc9afe91 ******************************************************************************* Forum Note: Use "Reply" to post a response in the discussion forum.