Index: uppsrc/Oracle/Oci8.cpp =================================================================== --- uppsrc/Oracle/Oci8.cpp (revision 2421) +++ uppsrc/Oracle/Oci8.cpp (working copy) @@ -69,7 +69,7 @@ struct Item { T_OCI8& oci8; int type; - int16 len; + int len; sb2 ind; ub2 rl; ub2 rc; @@ -142,6 +142,7 @@ 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 @@ 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 @@ 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,21 +853,36 @@ | OCI_THREADED #endif ; - if(oci8.OCIEnvCreate) { - if(oci8.OCIEnvCreate(&envhp, accessmode, 0, 0, 0, 0, 0, 0)) { - OCIInitError(*this, "OCIEnvCreate"); - return false; - } + + // ILUPASCU(tojocky): try to put utf8 charset + 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_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)&&(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; } - else { - if(oci8.OCIInitialize(accessmode, 0, 0, 0, 0)) { - OCIInitError(*this, "OCIInitialize"); - return 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(oci8.OCIEnvInit(&envhp, OCI_DEFAULT, 0, 0)) { - OCIInitError(*this, "OCIEnvInit"); - return false; - } } if(!AllocOciHandle(&errhp, OCI_HTYPE_ERROR)) { OCIInitError(*this, "OCI_HTYPE_ERROR"); Index: uppsrc/Oracle/Oci8.dli =================================================================== --- uppsrc/Oracle/Oci8.dli (revision 2421) +++ uppsrc/Oracle/Oci8.dli (working copy) @@ -18,6 +18,19 @@ 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), \ Index: uppsrc/Oracle/OciCommon.h =================================================================== --- uppsrc/Oracle/OciCommon.h (revision 2421) +++ uppsrc/Oracle/OciCommon.h (working copy) @@ -36,6 +36,9 @@ // 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