equal
deleted
inserted
replaced
91 enum { QOCIEncoding = 2002 }; // AL16UTF16LE |
91 enum { QOCIEncoding = 2002 }; // AL16UTF16LE |
92 #else |
92 #else |
93 enum { QOCIEncoding = 2000 }; // AL16UTF16 |
93 enum { QOCIEncoding = 2000 }; // AL16UTF16 |
94 #endif |
94 #endif |
95 |
95 |
96 static const ub1 CSID_NCHAR = SQLCS_NCHAR; |
96 // Always set the OCI_ATTR_CHARSET_FORM to SQLCS_NCHAR is safe |
|
97 // because Oracle server will deal with the implicit Conversion |
|
98 // Between CHAR and NCHAR. |
|
99 // see: http://download.oracle.com/docs/cd/A91202_01/901_doc/appdev.901/a89857/oci05bnd.htm#422705 |
|
100 static const ub1 qOraCharsetForm = SQLCS_NCHAR; |
|
101 |
|
102 #if defined (OCI_UTF16ID) |
|
103 static const ub2 qOraCharset = OCI_UTF16ID; |
|
104 #else |
97 static const ub2 qOraCharset = OCI_UCS2ID; |
105 static const ub2 qOraCharset = OCI_UCS2ID; |
|
106 #endif |
98 |
107 |
99 typedef QVarLengthArray<sb2, 32> IndicatorArray; |
108 typedef QVarLengthArray<sb2, 32> IndicatorArray; |
100 typedef QVarLengthArray<ub2, 32> SizeArray; |
109 typedef QVarLengthArray<ub2, 32> SizeArray; |
101 |
110 |
102 static QByteArray qMakeOraDate(const QDateTime& dt); |
111 static QByteArray qMakeOraDate(const QDateTime& dt); |
207 |
216 |
208 r = OCIAttrSet(hbnd, |
217 r = OCIAttrSet(hbnd, |
209 OCI_HTYPE_BIND, |
218 OCI_HTYPE_BIND, |
210 // this const cast is safe since OCI doesn't touch |
219 // this const cast is safe since OCI doesn't touch |
211 // the charset. |
220 // the charset. |
|
221 const_cast<void *>(static_cast<const void *>(&qOraCharsetForm)), |
|
222 0, |
|
223 OCI_ATTR_CHARSET_FORM, |
|
224 err); |
|
225 if (r != 0) |
|
226 qOraWarning("QOCIResultPrivate::setCharset: Couldn't set OCI_ATTR_CHARSET_FORM: ", err); |
|
227 |
|
228 r = OCIAttrSet(hbnd, |
|
229 OCI_HTYPE_BIND, |
|
230 // this const cast is safe since OCI doesn't touch |
|
231 // the charset. |
212 const_cast<void *>(static_cast<const void *>(&qOraCharset)), |
232 const_cast<void *>(static_cast<const void *>(&qOraCharset)), |
213 0, |
233 0, |
214 OCI_ATTR_CHARSET_ID, |
234 OCI_ATTR_CHARSET_ID, |
215 err); |
235 err); |
216 if (r != 0) |
236 if (r != 0) |
217 qOraWarning("QOCIResultPrivate::setCharset: Couldn't set OCI_ATTR_CHARSET_ID: ", err); |
237 qOraWarning("QOCIResultPrivate::setCharset: Couldn't set OCI_ATTR_CHARSET_ID: ", err); |
|
238 |
218 } |
239 } |
219 |
240 |
220 int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, int pos, |
241 int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, int pos, |
221 const QVariant &val, dvoid *indPtr, ub2 *tmpSize, QList<QByteArray> &tmpStorage) |
242 const QVariant &val, dvoid *indPtr, ub2 *tmpSize, QList<QByteArray> &tmpStorage) |
222 { |
243 { |
646 return ba; |
667 return ba; |
647 } |
668 } |
648 |
669 |
649 QDateTime qMakeDate(const char* oraDate) |
670 QDateTime qMakeDate(const char* oraDate) |
650 { |
671 { |
651 int century = oraDate[0]; |
672 int century = uchar(oraDate[0]); |
652 if(century >= 100){ |
673 if(century >= 100){ |
653 int year = uchar(oraDate[1]); |
674 int year = uchar(oraDate[1]); |
654 year = ((century-100)*100) + (year-100); |
675 year = ((century-100)*100) + (year-100); |
655 int month = oraDate[2]; |
676 int month = oraDate[2]; |
656 int day = oraDate[3]; |
677 int day = oraDate[3]; |
937 |
958 |
938 r = OCIAttrSet(dfn, |
959 r = OCIAttrSet(dfn, |
939 OCI_HTYPE_DEFINE, |
960 OCI_HTYPE_DEFINE, |
940 // this const cast is safe since OCI doesn't touch |
961 // this const cast is safe since OCI doesn't touch |
941 // the charset. |
962 // the charset. |
|
963 const_cast<void *>(static_cast<const void *>(&qOraCharsetForm)), |
|
964 0, |
|
965 OCI_ATTR_CHARSET_FORM, |
|
966 d->err); |
|
967 if (r != 0) |
|
968 qOraWarning("QOCIResultPrivate::setCharset: Couldn't set OCI_ATTR_CHARSET_FORM: ", d->err); |
|
969 |
|
970 r = OCIAttrSet(dfn, |
|
971 OCI_HTYPE_DEFINE, |
|
972 // this const cast is safe since OCI doesn't touch |
|
973 // the charset. |
942 const_cast<void *>(static_cast<const void *>(&qOraCharset)), |
974 const_cast<void *>(static_cast<const void *>(&qOraCharset)), |
943 0, |
975 0, |
944 OCI_ATTR_CHARSET_ID, |
976 OCI_ATTR_CHARSET_ID, |
945 d->err); |
977 d->err); |
946 if (r != 0) |
978 if (r != 0) |