Multi-thread esql program for NSAPI?
Posted in 2000
Topics: Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL
Hi, Does anyone has the experience of using informix esql in NSAPI program? Recently I have been trying but encountered a cursor error with SQLSTATE 07003 and SQLCODE -404. Anyone has clue about this? Thanks in advance. Cheers, Yang Yang
At what point do you get this message? If its on the fetch, your cursor is not open. If its on the open you probably have no connection to the database. It is best to use named connections (via CONNECT TO AS ...). I would recommend using the getpid() call to serve as your connection name, and protect the EXEC SQL CONNECT with the crit*() NSAPI functions. Hope this helps. Alan Yang Yang wrote: > Hi, > > Does anyone has the experience of using informix esql in NSAPI program? > Recently I have been trying but encountered a cursor error with SQLSTATE > 07003 and SQLCODE -404. Anyone has clue about this? > > Thanks in advance. > > Cheers, > Yang Yang
Hi Alan, Thanks for your help. After further investigating the program, I realized that the DB connection is not established successfully, an error message -27000 is generated. I should be able to resolve this. Is it possible to give me an example on how to use crit*() functions? Really appreciate it. Cheers, Yang Yang Alan Caldera wrote: > At what point do you get this message? If its on the fetch, your cursor is not open. > If its on the open you probably have no connection to the database. It is best to > use named connections (via CONNECT TO AS ...). I would recommend using the getpid() call to serve as > your connection name, and protect the EXEC SQL CONNECT with the crit*() NSAPI functions. > Hope this helps. > > Alan > > Yang Yang wrote: > > > Hi, > > > > Does anyone has the experience of using informix esql in NSAPI program? > > Recently I have been trying but encountered a cursor error with SQLSTATE > > 07003 and SQLCODE -404. Anyone has clue about this? > > > > Thanks in advance. > > > > Cheers, > > Yang Yang
Yang Yang, There are 3 basic calls that you will need to make. crit_init() must be called in a NSAPI style init function registered in the same manner as the NSAPI function you are calling. A line such like this: Init fn=myfunc_init in your obj.conf file will call the init function. The crit_init() function returns a variable of type CRITICAL whose definition can be found in the NSAPI header files. This CRITICAL variable must be global. The other 2 calls: crit_enter() and crit_exit() need to surround your CONNECT statement. Those 2 functions take 1 argument which is the CRITICAL variable that you defined globally. By the way, multithreaded programs such as Netscape really should use your network connection instead of shared mem. Switch your connect statement to utilize your tli or soc connection depending on your platform. For more information on the crit() functions consult the Netscape NSAPI Programmers Guide. Alan Yang Yang wrote: > Hi Alan, > > Thanks for your help. After further investigating the program, I realized that the DB connection is not > established successfully, an error message -27000 is generated. I should be able to resolve this. Is it > possible to give me an example on how to use crit*() functions? Really appreciate it. > > Cheers, > Yang Yang > > Alan Caldera wrote: > > > At what point do you get this message? If its on the fetch, your cursor is not open. > > If its on the open you probably have no connection to the database. It is best to > > use named connections (via CONNECT TO AS ...). I would recommend using the getpid() call to serve as > > your connection name, and protect the EXEC SQL CONNECT with the crit*() NSAPI functions. > > Hope this helps. > > > > Alan > > > > Yang Yang wrote: > > > > > Hi, > > > > > > Does anyone has the experience of using informix esql in NSAPI program? > > > Recently I have been trying but encountered a cursor error with SQLSTATE > > > 07003 and SQLCODE -404. Anyone has clue about this? > > > > > > Thanks in advance. > > > > > > Cheers, > > > Yang Yang
Thanks Alan, it works now. Cheers, Yang Yang