Re: sqlbreak and ESQL-C
Posted in 2000
Topics: Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL, Server Administration
Dirk, I use sqlbreak() in my code usually in my own C level interrupt
handler since the callback setup is relatively new and I would rather
just call signal to setup a handler and call sqlbreak from there.
It works for me with some gotchas. Some statements just will not be
interrupted, UPDATE STATISTICS comes to mind. Others, like large
deletes and updates will not interrupt and return -213 until they
have finished rolling back so you may have to be patient.
Art S. Kagel
Dirk Niemeier wrote:
>
> Hi,
> does anyone know about an other method to interrupt an current statement ?
> Because in dbaccess and isql it works fine.
>
> Dirk
>
> Dirk Niemeier schrieb:
>
> > Hello,
> > I am trying to use the sqlbreak() fkt. to interrupt an long
> > sql-statement with Informix SE-Database.
> > I defined a sqlbreakcallback() etc. like below. But it doesn't interrupt
> > the SQL-Staement.
> > I see the callback is called every second. And the sqlbreak() returned 0
> > as exit code. But nothing happens.
> > No SQLCODE -213 like discribed in "fm", but why ?
> >
> > TIA
> > Dirk
> >
> > /*--------------------------------------------------------------------------*/
> >
> > void ListenBreak(int status)
> > { // eine Callback-Routine zum Abbrechen einer langwierigen Abfrage
> >
> > fprintf(ferr, "ListenBreak %d ", status);
> >
> > if ( status==2 )
> > {
> > int xCH=rkey(); // get keyboard input
> >
> > fprintf(ferr, "und rKey=%d ", xCH);
> >
> > if ( xCH==cESC )
> > {
> > int xB=sqlbreak();
> >
> > fprintf(ferr, "und sqlbreak=%d ", xB);
> >
> > }
> > }
> >
> > fprintf(ferr, "\\n");
> > fflush(ferr);
> >
> > }
> >
> > /*--------------------------------------------------------------------------*/
> >
> > ...
> > sqlbreakcallback(1000, ListenBreak);
> > ...
> > $open...
> >
> > sqlbreakcallback(-1L, (void*)NULL);
> > ...
> > /*--------------------------------------------------------------------------*/
Hi Art,
doesn't interrupt the open statement with an simple select, too ? I don't understand
that reason, bacause the interrupt function in isql and dbaccess works fine.
Dirk
"Art S. Kagel" schrieb:
> Dirk, I use sqlbreak() in my code usually in my own C level interrupt
> handler since the callback setup is relatively new and I would rather
> just call signal to setup a handler and call sqlbreak from there.
>
> It works for me with some gotchas. Some statements just will not be
> interrupted, UPDATE STATISTICS comes to mind. Others, like large
> deletes and updates will not interrupt and return -213 until they
> have finished rolling back so you may have to be patient.
>
> Art S. Kagel
>
> Dirk Niemeier wrote:
> >
> > Hi,
> > does anyone know about an other method to interrupt an current statement ?
> > Because in dbaccess and isql it works fine.
> >
> > Dirk
> >
> > Dirk Niemeier schrieb:
> >
> > > Hello,
> > > I am trying to use the sqlbreak() fkt. to interrupt an long
> > > sql-statement with Informix SE-Database.
> > > I defined a sqlbreakcallback() etc. like below. But it doesn't interrupt
> > > the SQL-Staement.
> > > I see the callback is called every second. And the sqlbreak() returned 0
> > > as exit code. But nothing happens.
> > > No SQLCODE -213 like discribed in "fm", but why ?
> > >
> > > TIA
> > > Dirk
> > >
> > > /*--------------------------------------------------------------------------*/
> > >
> > > void ListenBreak(int status)
> > > { // eine Callback-Routine zum Abbrechen einer langwierigen Abfrage
> > >
> > > fprintf(ferr, "ListenBreak %d ", status);
> > >
> > > if ( status==2 )
> > > {
> > > int xCH=rkey(); // get keyboard input
> > >
> > > fprintf(ferr, "und rKey=%d ", xCH);
> > >
> > > if ( xCH==cESC )
> > > {
> > > int xB=sqlbreak();
> > >
> > > fprintf(ferr, "und sqlbreak=%d ", xB);
> > >
> > > }
> > > }
> > >
> > > fprintf(ferr, "\\n");
> > > fflush(ferr);
> > >
> > > }
> > >
> > > /*--------------------------------------------------------------------------*/
> > >
> > > ...
> > > sqlbreakcallback(1000, ListenBreak);
> > > ...
> > > $open...
> > >
> > > sqlbreakcallback(-1L, (void*)NULL);
> > > ...
> > > /*--------------------------------------------------------------------------*/