Oracle: Oci8 fixes by tojocky

git-svn-id: svn://ultimatepp.org/upp/trunk@2445 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2010-05-30 20:03:55 +00:00
parent f8f3b73e4d
commit 41928c6af2
4 changed files with 74 additions and 15 deletions

View file

@ -1794,6 +1794,25 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int nCmdSh
\
void GuiMainFn_()
#define DLL_APP_MAIN \
void _DllMainAppInit(); \
\
BOOL WINAPI DllMain(HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpReserved) \
{ \
if(fdwReason == DLL_PROCESS_ATTACH) { \
Ctrl::InitWin32(AppGetHandle()); \
AppInitEnvironment__(); \
_DllMainAppInit(); \
} \
else \
if(fdwReason == DLL_PROCESS_DETACH) { \
Ctrl::ExitWin32(); \
} \
return true; \
} \
\
void _DllMainAppInit()
#endif
#endif

View file

@ -69,7 +69,7 @@ protected:
struct Item {
T_OCI8& oci8;
int type;
int16 len;
int len;
sb2 ind;
ub2 rl;
ub2 rc;
@ -142,6 +142,7 @@ protected:
void SetParam(int i, Date d);
void SetParam(int i, Time d);
void SetParam(int i, Sql& refcursor);
void SetRawParam(int i, const String& s);
void AddColumn(int type, int len);
void GetColumn(int i, String& s) const;
@ -296,6 +297,13 @@ void OCI8Connection::SetParam(int i, OracleRef r) {
PrepareParam(i, r.GetOraType(), r.GetMaxLen(), 0, r.GetType());
}
void OCI8Connection::SetRawParam(int i, const String& s) {
int l = s.GetLength();
Item& p = PrepareParam(i, SQLT_LBI, l, 0, VOID_V);
memcpy(p.Data(), s, l);
p.ind = l ? 0 : -1;
}
class Oracle8RefCursorStub : public SqlSource {
public:
Oracle8RefCursorStub(SqlConnection *cn) : cn(cn) {}
@ -320,6 +328,9 @@ void OCI8Connection::SetParam(int i, const Value& q) {
SetParam(i, String());
else
switch(q.GetType()) {
case SQLRAW_V:
SetRawParam(i, SqlRaw(q));
break;
case STRING_V:
case WSTRING_V:
SetParam(i, String(q));
@ -842,20 +853,33 @@ bool Oracle8::Login(const char *name, const char *pwd, const char *db, bool use_
| OCI_THREADED
#endif
;
if(oci8.OCIEnvCreate) {
if(oci8.OCIEnvCreate(&envhp, accessmode, 0, 0, 0, 0, 0, 0)) {
OCIInitError(*this, "OCIEnvCreate");
return false;
}
}
else {
if(oci8.OCIInitialize(accessmode, 0, 0, 0, 0)) {
OCIInitError(*this, "OCIInitialize");
return false;
}
if(oci8.OCIEnvInit(&envhp, OCI_DEFAULT, 0, 0)) {
OCIInitError(*this, "OCIEnvInit");
return false;
bool v_without_NLS = true;
if(oci8.OCIEnvNlsCreate) {
if((v_without_NLS)&&(oci8.OCIEnvNlsCreate(&envhp, accessmode, 0, 0, 0, 0, 0, 0, OCI_NLS_NCHARSET_ID_AL32UT8, OCI_NLS_NCHARSET_ID_AL32UT8))){
LLOG("OCI8: error on initialization utf8 NLS");
v_without_NLS = true;
}else v_without_NLS = false;
if((v_without_NLS)&&(oci8.OCIEnvNlsCreate(&envhp, accessmode, 0, 0, 0, 0, 0, 0, OCI_NLS_NCHARSET_ID_UT8, OCI_NLS_NCHARSET_ID_UT8))){
LLOG("OCI8: error on initialization utf8 NLS");
v_without_NLS = true;
}else v_without_NLS = false;
}
if(v_without_NLS){
if(oci8.OCIEnvCreate){
if(oci8.OCIEnvCreate(&envhp, accessmode, 0, 0, 0, 0, 0, 0)) {
OCIInitError(*this, "OCIEnvCreate");
return false;
}
} else {
if(oci8.OCIInitialize(accessmode, 0, 0, 0, 0)) {
OCIInitError(*this, "OCIInitialize");
return false;
}
if(oci8.OCIEnvInit(&envhp, OCI_DEFAULT, 0, 0)) {
OCIInitError(*this, "OCIEnvInit");
return false;
}
}
}
if(!AllocOciHandle(&errhp, OCI_HTYPE_ERROR)) {

View file

@ -18,6 +18,19 @@ FN(sword, OCIDescriptorFree, (dvoid *descp, ub4 type))
FN(sword, OCIEnvInit, (UPP::OCIEnv **envp, ub4 mode, size_t xtramem_sz, dvoid **usrmempp))
FN0(sword, OCIEnvNlsCreate, (OCIEnv **envp, ub4 mode, const dvoid *ctxp, \
const dvoid *(*malocfp)(dvoid *ctxp, size_t size), \
const dvoid *(*ralocfp)(dvoid *ctxp, dvoid *memptr, size_t newsize), \
const void (*mfreexp)(dvoid *ctxp, dvoid *memptr), \
size_t xtramem_sz, dvoid **usrmempp, ub2 charset, ub2 ncharset))
FN0(sword, OCINlsEnvironmentVariableGet, (dvoid *val, size_t size, ub2 item,\
ub2 charset, size_t *rsize))
FN0(ub2, OCINlsCharSetNameToId, (dvoid *hndl, const OraText *name))
FN0(sword, OCINlsCharSetIdToName, (dvoid *hndl, OraText *buf, size_t buflen, ub2 id))
FN0(sword, OCIEnvCreate, (OCIEnv **envp, ub4 mode, const dvoid *ctxp, \
const dvoid *(*malocfp)(dvoid *ctxp, size_t size), \
const dvoid *(*ralocfp)(dvoid *ctxp, dvoid *memptr, size_t newsize), \

View file

@ -36,6 +36,9 @@ enum
// The following *TWO* are only valid for OCICreateEnvironment call
OCI_NO_UCB = 0x40, // No user callback called during init
OCI_NO_MUTEX = 0x80, // the environment handle will not be
// NLS
OCI_NLS_NCHARSET_ID_UT8 = 871, /* AL32UTF8 charset id */
OCI_NLS_NCHARSET_ID_AL32UT8 = 873, /* AL32UTF8 charset id */
// protected by a mutex internally
OCI_SHARED_EXT = 0x100, // Used for shared forms
OCI_CACHE = 0x200, // used by iCache