PRO*C/C++中SQLCA的声明

在多个类中声明SQLCA时,要用以下两种方式之一,否则的话,在程序链接的时候出错 
A.  
#define SQLCA_NONE  
#include "sqlca.h" 
这种方式没有定义sqlca 全局变量,需要自己定义一个sqlca ,建议为每个sql_context定义一个局部的sqlca; 
void ClassA::FuncA() 

struct sqlca sqlca;  
EXEC SQL WHENEVER SQLERROR GOTO SQLERR; 
EXEC SQL WHENEVER NOT FOUND CONTINUE; 
EXEC SQL CONTEXT USE :m_ctx;  
EXEC SQL select * from tableName; 
//process data  
return ; 
SQLERR: 
SqlError(sqlca);  
return -1; 

 
B. 
#define SQLCA_STORAGE_CLASS extern 
#include "sqlca.h" 
此种方式会有一个全局的sqlca区,建议为每个sql_context定义一个同名的局部的sqlca覆盖,以保证sqlca 是多线程安全的. 
 
附sqlca定义 
//*****************start sqlca.h********************** 
#ifndef SQLCA 
#define SQLCA 1 
 
struct sqlca 

/* ub1 */ char sqlcaid[8]; 
/* b4 */ int sqlabc; 
/* b4 */ int sqlcode; 
struct 

/* ub2 */ unsigned short sqlerrml; 
/* ub1 */ char sqlerrmc[70]; 
} sqlerrm; 
/* ub1 */ char sqlerrp[8]; 
/* b4 */ int sqlerrd[6]; 
/* ub1 */ char sqlwarn[8]; 
/* ub1 */ char sqlext[8]; 
}; 
 
#ifndef SQLCA_NONE  
#ifdef SQLCA_STORAGE_CLASS 
SQLCA_STORAGE_CLASS struct sqlca sqlca 
#else 
struct sqlca sqlca 
#endif 
 
#ifdef SQLCA_INIT 
= { 
{'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '}, 
sizeof(struct sqlca), 
0, 
{ 0, {0}}, 
{'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '}, 
{0, 0, 0, 0, 0, 0}, 
{0, 0, 0, 0, 0, 0, 0, 0}, 
{0, 0, 0, 0, 0, 0, 0, 0} 

#endif 

#endif 
 
#endif 
 
//*****************end sqlca.h***************************************** 
 
11.4.4 Programming Considerations 
While Oracle ensures that the SQLLIB code is thread-safe, you are responsible for ensuring that your Pro*C/C++ source code is designed to work properly with threads; for example, carefully consider your use of static and global variables. 
In addition, multithreaded applications require design decisions regarding the following: 
Declaring the SQLCA as a thread-safe struct, typically an auto variable and one for each runtime context 
Declaring the SQLDA as a thread-safe struct, like the SQLCA, typically an auto variable and one for each runtime context 
Declaring host variables in a thread-safe fashion, in other words, carefully consider your use of static and global host variables. 
Avoiding simultaneous use of a runtime context in multiple threads 
Whether or not to use default database connections or to explicitly define them using the AT clause 
Also, no more than one executable embedded SQL statement, for example, EXEC SQL UPDATE, may be outstanding on a runtime context at a given time. 
Existing requirements for precompiled applications also apply. For example, all references to a given cursor must appear in the same source
vc++数据库开发资源包 都是过时的技术。 我自己学习用的。 ------------------------- ADO270.CHI ADO270.CHM ADOSQL.CHI ADOSQL.CHM COM.CHM DBLIBC.CHI DBLIBC.CHM DBLIBC.chw ODBCSQL.CHM ODECORE.CHI OLEDB.CHI OLEDB.CHM OLEDBSQL.CHI OLEDBSQL.CHM ─INCLUDE DB2CONST.H DBMCONST.H DTMCONST.H DTSCONST.H DTSFFILE.H DTSPKG.H DTSPUMP.H EQMCONST.H GENCONST.H IFXCONST.H MDSCONST.H MSDADC.H MSDAGUID.H MSDASC.H MSDASQL.H OCLCONST.H ODBCINST.H ODBCOR_G.BAS ODBCSS.H ODBEXT_G.BAS OLEDB.H OLEDBERR.H OLPCONST.H REPAPI.H REPAUTO.H REPENG.BAS REPERR.H REPLDIST.H REPLDSTX.C REPLERRI.C REPLERRX.H REPLINIX.C REPLMRGX.C REPTIM.H REPTIM2.H REPTIM3.H SIMCONST.H SQL.H SQLCA.H SQLCONST.H SQLDA.H SQLDB.H SQLDISTX.H SQLDMO.H SQLDMOID.H SQLEXT.H SQLFRONT.H SQLINITX.H SQLMERGX.H SQLNSDEF.H SQLNSX.H SQLOLEDB.H SQLRES.H SQLRES.IDL SQLRESID.H SQLTYPES.H SQLUCODE.H SRV.H SRVAPI.H SRVCONST.H SRVDBTYP.H SRVMISC.H SRVSTRUC.H SRVTOK.H SRVTYPES.H TFMCONST.H TRANSACT.H TXCOORD.H TXDTC.H UMLCONST.H UMXCONST.H VDI.H VDIERROR.H VDIGUID.H WN95SCM.H XACTOMSG.H XOLEHLP.H ─SAMPLES ├─ADO │ UNZIP_AD │ ├─BACKUP │ UNZIP_BA │ ├─DBLIB │ UNZIP_DB │ ├─DESKTOP │ SAMPLE.M │ SAMPLEUP │ UNZIP_DE │ ├─DTS │ UNZIP_DT │ ├─ESQLC │ UNZIP_ES │ ├─MISC │ UNZIP_MI │ ├─MSDTC │ UNZIP_MS │ ├─ODBC │ UNZIP_OD │ ├─ODS │ UNZIP_OD │ ├─OLEAUTO │ UNZIP_OL │ ├─SQLDMO │ UNZIP_SQ │ ├─SQLNS │ UNZIP_SQ │ ├─SQLREPL │ UNZIP_SQ │ ├─UTILS │ UNZIP_UT │ └─XML UNZIP_XM ─SDK MDACSDKLITE. XMLSDK.MSI ─X86LIB ADME.LIB CAW32.LIB DACDLL.LIB DTCCFG.LIB DTCCM.LIB DTCHELP.LIB DTCTRACE.LIB DTCUIC.LIB DTCUIS.LIB DTCUTIL.LIB LOGMGR.LIB MSDASC.LIB MSDTC.LIB MSDTCPRX.LIB MSDTCTM.LIB NTWDBLIB.LIB ODBC32.LIB ODBCBCP.LIB ODBCCP32.LIB OLEDB.LIB OLEDBD.LIB OPENDS60.LIB SAMPDTCR.LIB SQLAKW32.LIB SVCSRVL.LIB UTIL.LIB W95SCM.LIB XOLEHLP.LIB
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值