ESQL/C -439
Posted in 2003
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Hi, Does this mailing list discuss issues regarding ESQL/C programming ? If so, i'm having a problem with the -439 error: -439 Database server is currently processing an SQL task. In my app, i want to make a new connection using EXEC SQL CONNECT ... if a sqldone() call after a SET CONNECTION returns -439 psuedo-code: EXEC SQL SET CONNECTION 'connec1'; if (sqldone() == -439) { EXEC SQL CONNECT TO :host AS 'connec2' USER :user USING :passwd WITH CONCURRENT TRANSACTION; } Thanks, Corne' !Exclude Disclaimer!
Corne' Cornelius wrote: > Does this mailing list discuss issues regarding ESQL/C programming ? Yes. > If so, i'm having a problem with the -439 error: > -439 Database server is currently processing an SQL task. > > In my app, i want to make a new connection using EXEC SQL CONNECT ... if > a sqldone() call after a SET CONNECTION returns -439 > > psuedo-code: > EXEC SQL SET CONNECTION 'connec1'; > if (sqldone() == -439) { > EXEC SQL CONNECT TO :host AS 'connec2' USER :user USING :passwd WITH > CONCURRENT TRANSACTION; > } Why are you calling sqldone() like that? You test whether SET CONNECTION succeeded by looking at SQLCODE or sqlca.sqlcode. Is your application multi-threaded? Unless it is multi-threaded, you cannot make concurrent use of two connections. You can have two connections open, but only one of them can be executing an SQL statement at any given time. You execute the SQL; you wait for the response. If you're using a multi-threaded application, then you need to have your code control which thread is using which ESQL/C connection. It should be recording which thread has each connection in use. One simple way to do that is to allocate a new connection for each thread. Otherwise, you need to know about SET CONNECTION ... DORMANT (and use it). -- Jonathan Leffler #include <disclaimer.h> Email: jleffler@earthlink.net, jleffler@us.ibm.com Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/
Jonathan Leffler wrote: > Corne' Cornelius wrote: > >> Does this mailing list discuss issues regarding ESQL/C programming ? > > > Yes. > >> If so, i'm having a problem with the -439 error: >> -439 Database server is currently processing an SQL task. >> >> In my app, i want to make a new connection using EXEC SQL CONNECT ... >> if a sqldone() call after a SET CONNECTION returns -439 >> >> psuedo-code: >> EXEC SQL SET CONNECTION 'connec1'; >> if (sqldone() == -439) { >> EXEC SQL CONNECT TO :host AS 'connec2' USER :user USING :passwd >> WITH CONCURRENT TRANSACTION; >> } > > > Why are you calling sqldone() like that? You test whether SET > CONNECTION succeeded by looking at SQLCODE or sqlca.sqlcode. The sqldone() call is followed by a check on SQLCODE. so i can just skip sqldone() call and just check if SQLCODE == -439 i suppose. > Is your application multi-threaded? Unless it is multi-threaded, you > cannot make concurrent use of two connections. You can have two > connections open, but only one of them can be executing an SQL statement > at any given time. You execute the SQL; you wait for the response. Yes, i'ts multi-threaded. > > If you're using a multi-threaded application, then you need to have your > code control which thread is using which ESQL/C connection. It should > be recording which thread has each connection in use. One simple way to > do that is to allocate a new connection for each thread. Otherwise, you > need to know about SET CONNECTION ... DORMANT (and use it). > Each thread keeps track of the connection names. I would like each thread to only establish a new connection if the current connection is busy, to minimise connections. So to check if the current connection is busy, i check if SQLCODE == -439, if it is, i run: EXEC SQL CONNECT TO :host AS 'conn_thread_x' ... WITH CONCURRENT TRANSACTION; but even after the CONNECT TO, SQLCODE is still -439, and sql_getcur_conn_name() returns connection name of old connection. I've tried SET 'currconn' DORMANT; before the CONNECT, but that doesn't change anything. any ideas ?
I think its *required* for you to have separate connection per thread... Corne' Cornelius <corne@no-domain-no-spam.com> wrote in message news:<3F435642.3000705@no-domain-no-spam.com>... > Hi, > > Does this mailing list discuss issues regarding ESQL/C programming ? > > If so, i'm having a problem with the -439 error: > -439 Database server is currently processing an SQL task. > > In my app, i want to make a new connection using EXEC SQL CONNECT ... if > a sqldone() call after a SET CONNECTION returns -439 > > psuedo-code: > EXEC SQL SET CONNECTION 'connec1'; > if (sqldone() == -439) { > EXEC SQL CONNECT TO :host AS 'connec2' USER :user USING :passwd WITH > CONCURRENT TRANSACTION; > } > > > Thanks, > Corne' > !Exclude Disclaimer!
On Wed, 20 Aug 2003 08:56:23 -0400, Corne' Cornelius wrote: Better to perform this control with your own conditions and mutexes. When a thread acquires a connection it sets the corresponding condition, when it is finished with the connection it clears the condition. Mutexes protect the conditions. Art S. Kagel > Jonathan Leffler wrote: >> Corne' Cornelius wrote: >> >>> Does this mailing list discuss issues regarding ESQL/C programming ? >> >> >> Yes. >> >>> If so, i'm having a problem with the -439 error: -439 Database >>> server is currently processing an SQL task. >>> >>> In my app, i want to make a new connection using EXEC SQL CONNECT ... >>> if a sqldone() call after a SET CONNECTION returns -439 >>> >>> psuedo-code: >>> EXEC SQL SET CONNECTION 'connec1'; >>> if (sqldone() == -439) { >>> EXEC SQL CONNECT TO :host AS 'connec2' USER :user USING :passwd >>> WITH CONCURRENT TRANSACTION; >>> } >> >> >> Why are you calling sqldone() like that? You test whether SET >> CONNECTION succeeded by looking at SQLCODE or sqlca.sqlcode. > > > The sqldone() call is followed by a check on SQLCODE. so i can just skip > sqldone() call and just check if SQLCODE == -439 i suppose. > >> Is your application multi-threaded? Unless it is multi-threaded, you >> cannot make concurrent use of two connections. You can have two >> connections open, but only one of them can be executing an SQL >> statement at any given time. You execute the SQL; you wait for the >> response. > > > Yes, i'ts multi-threaded. > > >> If you're using a multi-threaded application, then you need to have >> your code control which thread is using which ESQL/C connection. It >> should be recording which thread has each connection in use. One >> simple way to do that is to allocate a new connection for each thread. >> Otherwise, you need to know about SET CONNECTION ... DORMANT (and use >> it). >> >> >> > Each thread keeps track of the connection names. I would like each > thread to only establish a new connection if the current connection is > busy, to minimise connections. > > So to check if the current connection is busy, i check if SQLCODE == > -439, if it is, i run: > > EXEC SQL CONNECT TO :host AS 'conn_thread_x' ... WITH CONCURRENT > TRANSACTION; > > but even after the CONNECT TO, SQLCODE is still -439, and > sql_getcur_conn_name() returns connection name of old connection. I've > tried SET 'currconn' DORMANT; before the CONNECT, but that doesn't > change anything. > > any ideas ?