DCL 4.0
Loading...
Searching...
No Matches
OciData.cpp
Go to the documentation of this file.
1#include <dcl/Config.h>
2
3#include <oci.h>
4
5#include <stdlib.h> // strtoll, strtoull
6#include <string.h> // memcpy, strncpy
7
8#include <dcl/Object.h>
9#if __DCL_HAVE_ALLOC_DEBUG
10#undef __DCL_ALLOC_LEVEL
11#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
12#endif
13
14#include <dcl/Numeric.h>
16#include <dcl/SQLCore.h>
17
18#include "OciConnection.h"
19#include "OciQuery.h"
20#include "OciData.h"
21
22#define __TRACE_THIS 0
23#if __TRACE_THIS
24#define __DCL_TRACE0_N __DCL_TRACE0
25#define __DCL_TRACE1_N __DCL_TRACE1
26#define __DCL_TRACE2_N __DCL_TRACE2
27#define __DCL_TRACE3_N __DCL_TRACE3
28#define __DCL_TRACE4_N __DCL_TRACE4
29#else
30#define __DCL_TRACE0_N(fmt)
31#define __DCL_TRACE1_N(fmt, arg)
32#define __DCL_TRACE2_N(fmt, arg1, arg2)
33#define __DCL_TRACE3_N(fmt, arg1, arg2, arg3)
34#define __DCL_TRACE4_N(fmt, arg1, arg2, arg3, arg4)
35#endif
36
37#undef __THIS_FILE__
38static const wchar_t __THIS_FILE__[] = __T("dcl/sql/OciData.cpp");
39
40__DCL_BEGIN_NAMESPACE
41
42#undef __SET_ERROR
43#define __SET_ERROR(_error, status, pError) \
44 conn()->setErrorStatus(_error, status, pError, \
45 true, __THIS_FILE__, __LINE__)
46
48{
50 __position = 0;
51 __descType = 0;
52 __dynamicMode = OCI_DEFAULT;
53
54 __dataType = SQLT_CHR;
55 __value = NULL;
56 __valueSize = 0;
57 __indicator = -1; // null
60 __returnCode = 0;
61
63 __dataSize = 0;
64 __maxDataSize = 0;
65}
66
68{
71 // OciData::__bytesOutput = NULL;
72 }
73}
74
75#ifdef __DCL_DEBUG
77{
79 return __queryHandle->conn();
80}
81#endif
82
84{
85 // after fetch
86 // after execute in outbind
87
88 if (__indicator == -1)
89 return true;
90
91 OciConnection* pConnection = conn();
92 OCIError* pError = pConnection->errorHandle();
93 sword status = OCI_SUCCESS;
94
95 switch(__dataType) {
96 case SQLT_CHR :
97 case SQLT_AFC :
98 case SQLT_BIN :
99 case SQLT_LNG :
100 // case SQLT_RDD : SQLT_CHR로 OciField.cpp(213)
101 case SQLT_LBI: {
102 if (__dynamicMode == OCI_DEFAULT)
104
105 if (__bytesOutput)
106 __dataSize = __bytesOutput->size();
107 else
108 __dataSize = 0;
110 break;
111 }
112 case SQLT_CLOB :
113 case SQLT_BLOB :
114 case SQLT_CFILE :
115 case SQLT_BFILE: {
116 OCISvcCtx* pSvcCtx = pConnection->svcctxHandle();
117 ub8 nLength = 0;
118 if (__descType == OCI_DTYPE_FILE) {
119 status = ::OCILobFileOpen(
120 pSvcCtx,
121 pError,
122 *(OCILobLocator**)__value,
123 OCI_FILE_READONLY
124 );
125 if (status != OCI_SUCCESS) {
126 __SET_ERROR(SQL::eServerError, status, pError);
127 return false;
128 }
129 }
130
131 status = ::OCILobGetLength2(
132 pSvcCtx,
133 pError,
134 *(OCILobLocator**)__value,
135 &nLength
136 );
137 if (status != OCI_SUCCESS) {
138 __SET_ERROR(SQL::eServerError, status, pError);
139 return false;
140 }
141
142 if (__descType == OCI_DTYPE_FILE) {
143 status = ::OCILobFileClose(
144 pSvcCtx,
145 pError,
146 *(OCILobLocator**)__value
147 );
148 if (status != OCI_SUCCESS) {
149 __SET_ERROR(SQL::eServerError, status, pError);
150 return false;
151 }
152 }
153
154 switch (__dataType) {
155 case SQLT_CLOB:
156 case SQLT_CFILE:
157 __dataSize = nLength * 3; // UTF-8
158 break;
159 default:
160 __dataSize = nLength;
161 }
162 break;
163 }
164 default: {
166 }
167 }
168
169 return true;
170}
171
172bool OciData::getDataSize(size_t* _size, bool _maxSize)
173{
174 if (_maxSize) {
175 *_size = OciData::__maxDataSize;
176 return true;
177 }
178 else {
179 if (__queryHandle->stmtType() == OCI_STMT_SELECT) {
180 if (!__queryHandle->inState(SQL::Query::stFetched)) {
182 return false;
183 }
184 }
185 else {
186 if (!__queryHandle->inState(SQL::Query::stExecuted)) {
188 return false;
189 }
190 }
191
192 if (__indicator == -1) {
194 return false;
195 }
196 *_size = OciData::__dataSize;
197 }
198
199 return true;
200}
201
202bool OciData::getData(void* _pv, size_t* _size, SQL::DataType _dataType)
203{
204 if (__queryHandle->stmtType() == OCI_STMT_SELECT) {
205 if (!__queryHandle->inState(SQL::Query::stFetched)) {
207 return false;
208 }
209 }
210 else {
211 if (!__queryHandle->inState(SQL::Query::stExecuted)) {
213 return false;
214 }
215 }
216
217 if (__indicator == -1) {
219 return false;
220 }
221
222 switch(_dataType) {
223 case SQL::typeInteger:
224 case SQL::typeUInteger: {
225 return getInteger(_pv, _size, _dataType);
226 }
227 case SQL::typeFloat: {
228 return getFloat(_pv, _size);
229 }
232 if (*_size == sizeof(SQL::TimeStamp))
233 return getTimeStamp((SQL::TimeStamp*)_pv, _size);
234 else {
235 *_size = sizeof(SQL::TimeStamp);
237 return false;
238 }
239 }
242 case SQL::typeIntervalDs: {
243 if (*_size == sizeof(SQL::Interval))
244 return getInterval((SQL::Interval*)_pv, _size);
245 else {
246 *_size = sizeof(SQL::Interval);
248 return false;
249 }
250 }
251 case SQL::typeText: {
252 if (__dataType == SQLT_VNU)
253 return getNumericText((char*)_pv, _size);
254 }
255 case SQL::typeBinary:
257 case SQL::typeLongBinary: {
258 return getBytes((byte_t*)_pv, _size);
259 }
261 return writeTo((OutputStream*)_pv, _size);
262 }
263 // case SQL::typeDate :
264 // case SQL::typeTime :
265 default: {
266 __DCL_ASSERT(false); // SQL::Field::getData bug
267 }
268 }
269
270 return true;
271}
272
273bool OciData::getInteger(void* _pv, size_t* _size, SQL::DataType _dataType)
274{
275 __DCL_ASSERT(__dataType == SQLT_VNU); // OciField::init bug
276
277 OCIError* pError = conn()->errorHandle();
278 sword status = OCI_SUCCESS;
279 if (*_size <= sizeof(int64_t /* 2025-02-03 월 int32_t */)) {
280 status = ::OCINumberToInt(
281 pError, // OCIError *err,
282 (CONST OCINumber*)__value, // CONST OCINumber *number,
283 *_size, // uword rsl_length,
284 _dataType == SQL::typeInteger ? // uword rsl_flag,
285 OCI_NUMBER_SIGNED : OCI_NUMBER_UNSIGNED,
286 _pv // dvoid *rsl
287 );
288 if (status != OCI_SUCCESS) {
289 __SET_ERROR(SQL::eServerError, status, pError);
290 return false;
291 }
292 }
293 else {
294 *_size = sizeof(int64_t);
296 return false;
297 }
298
299 return true;
300}
301
302bool OciData::getFloat(void* _pv, size_t* _size)
303{
304 __DCL_ASSERT(__dataType == SQLT_VNU); // OciField::init bug
305
306 OCIError* pError = conn()->errorHandle();
307 if (*_size <= sizeof(long double)) {
308 // long double 의 storage size
309 // MSVC/WIN32 8
310 // GCC/Linux 12
311 sword status = ::OCINumberToReal(
312 pError, // OCIError *err,
313 (CONST OCINumber*)__value, // CONST OCINumber *number,
314 *_size, // uword rsl_length,
315 _pv // dvoid *rsl
316 );
317 if (status != OCI_SUCCESS) {
318 __SET_ERROR(SQL::eServerError, status, pError);
319 return false;
320 }
321 }
322 else {
323 *_size = sizeof(double);
325 return false;
326 }
327
328 return true;
329}
330
331bool OciData::getNumericText(char* pBuf, size_t* _size)
332{
333 __DCL_ASSERT(__dataType == SQLT_VNU); // OciField::init bug
334
335 OCIError* pError = conn()->errorHandle();
336 ub4 n = 133;
337 ByteBuffer* buf = ByteBuffer::create_e(n);
338 sword status = ::OCINumberToText(
339 pError, // OCIError *err,
340 (CONST OCINumber*)__value, // CONST OCINumber *number,
341 (const OraText*)"TM", // CONST OraText *fmt,
342 2, // ub4 fmt_length,
343 NULL, // CONST OraText *nls_params,
344 0, // ub4 nls_p_length,
345 &n, // ub4 *buf_size,
346 (text*)buf->data() // text *buf
347 );
348 if (status != OCI_SUCCESS) {
349 if (buf->__allocLength < n) {
350 ByteBuffer::extend(buf, n);
351 }
352 status = ::OCINumberToText(
353 pError, // OCIError *err,
354 (CONST OCINumber*)__value, // CONST OCINumber *number,
355 (CONST OraText*)"TM", // CONST OraText *fmt,
356 2, // ub4 fmt_length,
357 NULL, // CONST OraText *nls_params,
358 0, // ub4 nls_p_length,
359 &n, // ub4 *buf_size,
360 (text*)buf->data() // text *buf
361 );
362 }
363 if (status != OCI_SUCCESS) {
364 buf->release();
365 __SET_ERROR(SQL::eServerError, status, pError);
366 return false;
367 }
368
369 buf->__dataLength = n;
370 ByteString s = buf;
371 buf->release();
372
373 if (*_size < (size_t)s.length()) {
374 *_size = (size_t)s.length();
376 return false;
377 }
378
379 strncpy(pBuf, s.data(), s.length());
380 if (*_size > (size_t)s.length()) {
381 *_size = (size_t)s.length();
382 pBuf[*_size] = '\0';
383 }
384
385 return true;
386}
387
388
389bool OciData::getTimeStamp(SQL::TimeStamp* _pv, size_t* _size)
390{
391 OCISession* pSession = conn()->sessionHandle();
392 OCIError* pError = conn()->errorHandle();
393
394 sb2 nYear = 0;
395 ub1 nMonth = 0;
396 ub1 nDay = 0;
397 ub1 nHour = 0;
398 ub1 nMin = 0;
399 ub1 nSec = 0;
400 ub4 nFSec = 0;
401
402 _pv->nTzMin = 0;
403
404 sword status = OCI_SUCCESS;
405
406 switch(__dataType) {
407 // case SQLT_DAT :
408 case SQLT_ODT: {
409 OCIDateGetDate((CONST OCIDate*)__value,
410 &nYear,
411 &nMonth,
412 &nDay
413 );
414 OCIDateGetTime(
415 (CONST OCIDate*)__value,
416 &nHour,
417 &nMin,
418 &nSec
419 );
420 break;
421 }
422 case SQLT_TIMESTAMP :
423 case SQLT_TIMESTAMP_TZ :
424 case SQLT_TIMESTAMP_LTZ: {
425 status = ::OCIDateTimeGetDate(
426 pSession, // dvoid *hndl,
427 pError, // OCIError *err,
428 *(CONST OCIDateTime**)__value, // CONST OCIDateTime *datetime,
429 &nYear, // sb2 *year,
430 &nMonth, // ub1 *month,
431 &nDay // ub1 *day
432 );
433 if (status == OCI_SUCCESS)
434 status = ::OCIDateTimeGetTime(
435 pSession, // dvoid *hndl,
436 pError, // OCIError *err,
437 *(OCIDateTime**)__value, // OCIDateTime *datetime,
438 &nHour, // ub1 *hour,
439 &nMin, // ub1 *min,
440 &nSec, // ub1 *sec,
441 &nFSec // ub4 *fsec
442 );
443 if (status == OCI_SUCCESS && __dataType != SQLT_TIMESTAMP) {
444 sb1 nTzHour = 0;
445 sb1 nTzMin = 0;
446
447 status = ::OCIDateTimeGetTimeZoneOffset(
448 pSession, // dvoid *hndl,
449 pError, // OCIError *err,
450 *(CONST OCIDateTime**)__value, // CONST OCIDateTime *datetime,
451 &nTzHour, // sb1 *hour,
452 &nTzMin // sb1 *min,
453 );
454 if (status != OCI_SUCCESS) {
455 __SET_ERROR(SQL::eServerError, status, pError);
456 return false;
457 }
458 // __DCL_TRACE2_N("TZ : %+03d:%02d\n", nTzHour, nTzMin);
459 _pv->nTzMin = nTzHour * 60 + nTzMin;
460 }
461
462 // __DCL_TRACE3_N("_pv: %d, s: %d, %d\n", m_nPrecision, m_nScale, nFSec);
463 break;
464 }
465 default: {
466 __DCL_ASSERT(false); // OciField::init bug
467 }
468 }
469
470 _pv->nYear = nYear;
471 _pv->nMonth = nMonth;
472 _pv->nDay = nDay;
473 _pv->nHour = nHour;
474 _pv->nMin = nMin;
475 _pv->nSec = nSec;
476 _pv->nFrac = nFSec;
477
478 return true;
479}
480
481bool OciData::getInterval(SQL::Interval* _pv, size_t* _size)
482{
483 OCISession* pSession = conn()->sessionHandle();
484 OCIError* pError = conn()->errorHandle();
485
486 sb4 nYear = 0;
487 sb4 nMonth = 0;
488 sb4 nDay = 0;
489 sb4 nHour = 0;
490 sb4 nMin = 0;
491 sb4 nSec = 0;
492 sb4 nFSec = 0;
493 sword status = OCI_SUCCESS;
494
495 switch(__dataType) {
496 case SQLT_INTERVAL_YM :
497 status = OCIIntervalGetYearMonth(
498 pSession, // dvoid *hndl,
499 pError, // OCIError *err,
500 &nYear, // sb4 *yr,
501 &nMonth, // sb4 *mnth,
502 *(CONST OCIInterval**)__value // CONST OCIInterval *interval
503 );
504 break;
505 case SQLT_INTERVAL_DS :
506 status = OCIIntervalGetDaySecond(
507 pSession, // dvoid *hndl,
508 pError, // OCIError *err,
509 &nDay, // sb4 *dy,
510 &nHour, // sb4 *hr,
511 &nMin, // sb4 *mm,
512 &nSec, // sb4 *ss,
513 &nFSec, // sb4 *fsec,
514 *(CONST OCIInterval**)__value // CONST OCIInterval *interval
515 );
516 break;
517 default :
518 __DCL_ASSERT(false); // OciField::init bug
519 }
520
521 if (status != OCI_SUCCESS) {
522 __SET_ERROR(SQL::eServerError, status, pError);
523 return false;
524 }
525
526 _pv->nYears = nYear;
527 _pv->nMonths = nMonth;
528 _pv->nDays = nDay;
529 _pv->nHours = nHour;
530 _pv->nMins = nMin;
531 _pv->nSecs = nSec;
532 _pv->nFracs = nFSec;
533 return true;
534}
535
536inline size_t __MIN(size_t x, size_t y)
537{
538 return x < y ? x : y;
539}
540
541bool OciData::getBytes(byte_t* _pv, size_t* _size)
542{
543 switch(__dataType) {
544 case SQLT_RDD: {
545 if (*_size < __dataSize) {
546 *_size = __dataSize;
548 return false;
549 }
550 }
551 case SQLT_CHR :
552 case SQLT_AFC :
553 case SQLT_BIN :
554 case SQLT_LNG :
555 case SQLT_LBI: {
556 size_t nTotalSize = __MIN(__dataSize, *_size);
557 size_t nTotalCopy = 0;
558 if (nTotalSize) {
559 size_t nCopy = 0;
560 if (__bytesOutput) {
561 nCopy = __MIN(nTotalSize - nTotalCopy, __bytesOutput->size());
562 if (nCopy) {
563 memcpy(_pv, __bytesOutput->data(), nCopy);
564 nTotalCopy = nCopy;
565 }
566 }
567
568 nCopy = __MIN(nTotalSize - nTotalCopy, __callbackActualLength);
569 if (nCopy) {
570 memcpy(_pv + nTotalCopy, __value, nCopy);
571 nTotalCopy += nCopy;
572 }
573
574 if (nTotalCopy < *_size)
575 *(_pv + nTotalCopy) = '\0';
576 }
577 *_size = nTotalCopy;
578 break;
579 }
580 case SQLT_CLOB:
581 case SQLT_BLOB:
582 case SQLT_CFILE:
583 case SQLT_BFILE: {
584 if (*_size && __dataSize)
585 return getBytesFromLob(_pv, _size);
586 else
587 *_size = 0;
588 break;
589 }
590 default: {
591 __DCL_ASSERT(false); // OciField::init bug
592 }
593 }
594
595 return true;
596}
597
598bool OciData::writeTo(OutputStream* pOutput, size_t* _size)
599{
600 switch(__dataType) {
601 case SQLT_RDD :
602 case SQLT_CHR :
603 case SQLT_AFC :
604 case SQLT_BIN :
605 case SQLT_LNG :
606 case SQLT_LBI: {
607 try {
608 size_t nTotalSize = __MIN(__dataSize, *_size);
609 size_t nTotalWritten = 0;
610 if (nTotalSize) {
611 size_t nWrite = 0;
612 if (__bytesOutput) {
613 nWrite = __MIN(nTotalSize - nTotalWritten, __bytesOutput->size());
614 if (nWrite) {
615 pOutput->write(__bytesOutput->data(), nWrite);
616 nTotalWritten += nWrite;
617 }
618 }
619
620 nWrite = __MIN(nTotalSize - nTotalWritten, __callbackActualLength);
621 if (nWrite) {
622 pOutput->write(__value, nWrite);
623 nTotalWritten += nWrite;
624 }
625 }
626
627 *_size = nTotalWritten;
628 }
629 catch (IOException* e) {
630 e->destroy();
631 return false;
632 }
633 break;
634 }
635 case SQLT_CLOB :
636 case SQLT_BLOB :
637 case SQLT_CFILE :
638 case SQLT_BFILE: {
639 if (*_size && __dataSize)
640 return writeToFromLob(pOutput, _size);
641 else
642 *_size = 0;
643 break;
644 }
645 default: {
646 __DCL_ASSERT(false); // OciField::init bug
647 }
648 }
649
650 return true;
651}
652
653bool OciData::getBytesFromLob(byte_t* _pbuf, size_t* _size)
654{
655 __DCL_ASSERT(__dataType == SQLT_CLOB
656 || __dataType == SQLT_BLOB
657 || __dataType == SQLT_BFILE
658 || __dataType == SQLT_CFILE
659 );
660
661 OCISvcCtx* pSvcCtx = conn()->svcctxHandle();
662 OCIError* pError = conn()->errorHandle();
663 sword status = OCI_SUCCESS;
664 if (__descType == OCI_DTYPE_FILE) {
665 status = ::OCILobFileOpen(
666 pSvcCtx,
667 pError,
668 *(OCILobLocator**)__value,
669 OCI_FILE_READONLY
670 );
671 if (status != OCI_SUCCESS) {
672 __SET_ERROR(SQL::eServerError, status, pError);
673 return false;
674 }
675 }
676
677 bool bResult = true;
678 size_t nTotalRead = 0;
679 ub4 nRead = 0;
680 while(nTotalRead < *_size) {
681 nRead = *_size - nTotalRead;
682 status = ::OCILobRead(
683 pSvcCtx,
684 pError,
685 *((OCILobLocator**)__value),
686 &nRead,
687 1 + nTotalRead, // offset
688 _pbuf, // bufp,
689 nRead, // bufl,
690 NULL, // ctxp
691 (OCICallbackLobRead)NULL,
692 0,
693 SQLCS_IMPLICIT);
694 if (status == OCI_ERROR) {
695 __SET_ERROR(SQL::eServerError, status, pError);
696 bResult = false;
697 break;
698 }
699
700 // OCI_SUCCESS, OCI_NEED_DATA
701 if (nRead) {
702 nTotalRead += nRead;
703 _pbuf += nRead;
704 }
705 else
706 break; // done
707
708// if (status != OCI_NEED_DATA)
709// break;
710 }
711
712 if (__descType == OCI_DTYPE_FILE) {
713 if (bResult) {
714 status = ::OCILobFileClose(
715 pSvcCtx,
716 pError,
717 *(OCILobLocator**)__value);
718 if (status != OCI_SUCCESS) {
719 __SET_ERROR(SQL::eServerError, status, pError);
720 return false;
721 }
722 }
723 else {
724 // 이전에 에러가 발생했다. Close 만 시킨다.
725 status = ::OCILobFileClose(
726 pSvcCtx,
727 conn()->errorHandle2(),
728 *(OCILobLocator**)__value);
729 if (status != OCI_SUCCESS) {
730 __DCL_TRACE0(__T("Warning - OCILobFileClose Fail!\n"));
731 }
732 }
733 }
734
735 if (*_size > nTotalRead)
736 *(_pbuf + nTotalRead) = '\0';
737
738 *_size = nTotalRead;
739
740 return bResult;
741}
742
743bool OciData::writeToFromLob(OutputStream* pOutput, size_t* _size)
744{
745 __DCL_ASSERT(__dataType == SQLT_CLOB
746 || __dataType == SQLT_BLOB
747 || __dataType == SQLT_BFILE
748 || __dataType == SQLT_CFILE
749 );
750
751 OCISvcCtx* pSvcCtx = conn()->svcctxHandle();
752 OCIError* pError = conn()->errorHandle();
753 sword status = OCI_SUCCESS;
754 if (__descType == OCI_DTYPE_FILE) {
755 status = ::OCILobFileOpen(
756 pSvcCtx,
757 pError,
758 *(OCILobLocator**)__value,
759 OCI_FILE_READONLY
760 );
761 if (status != OCI_SUCCESS) {
762 __SET_ERROR(SQL::eServerError, status, pError);
763 return false;
764 }
765 }
766
767 bool bResult = true;
768 size_t nTotalRead = 0;
769 ub4 nRead = 0;
770 char buf[4096];
771 while(nTotalRead < *_size) {
772 nRead = __MIN(*_size - nTotalRead, sizeof(buf));
773 status = ::OCILobRead(
774 pSvcCtx,
775 pError,
776 *((OCILobLocator**)__value),
777 &nRead,
778 1 + nTotalRead, // offset
779 buf, // bufp
780 nRead, // bufl
781 NULL, // ctxp
782 (OCICallbackLobRead)NULL,
783 0,
784 SQLCS_IMPLICIT);
785 if (status == OCI_ERROR) {
786 __SET_ERROR(SQL::eServerError, status, pError);
787 bResult = false;
788 break;
789 }
790
791 if (nRead) {
792 try {
793 pOutput->write(buf, nRead);
794 }
795 catch(IOException* e) {
796 e->destroy();
797 bResult = false;
798 break;
799 }
800
801 nTotalRead += nRead;
802 }
803 else {
804 break; // done
805 }
806
807// if (status != OCI_NEED_DATA)
808// break;
809 }
810
811 if (__descType == OCI_DTYPE_FILE) {
812 if (bResult) {
813 status = ::OCILobFileClose(
814 pSvcCtx,
815 pError,
816 *(OCILobLocator**)__value);
817 if (status != OCI_SUCCESS) {
818 __SET_ERROR(SQL::eServerError, status, pError);
819 return false;
820 }
821 }
822 else {
823 // 이전에 에러가 발생했다. Close 만 시킨다.
824 status = ::OCILobFileClose(
825 pSvcCtx,
826 conn()->errorHandle2(),
827 *(OCILobLocator**)__value);
828 if (status != OCI_SUCCESS) {
829 __DCL_TRACE0(__T("Warning - OCILobFileClose Fail!\n"));
830 }
831 }
832 }
833
834 *_size = nTotalRead;
835 return bResult;
836}
837
838//#ifdef __DCL_DEBUG
839//#define SQLTYPE_NAME(_dataType, name) case _dataType : return #_dataType "-" name
840//#else
841#define SQLTYPE_NAME(_dataType, name) case _dataType : return L ## name
842//#endif
843
844const wchar_t* OciData::dataTypeName(ub2 _dataType)
845{
846 switch(_dataType) {
847 SQLTYPE_NAME(SQLT_NUM, "NUMBER");
848 SQLTYPE_NAME(SQLT_VNU, "NUMBER"); // for OciParam
849 SQLTYPE_NAME(SQLT_DAT, "DATE");
850 SQLTYPE_NAME(SQLT_ODT, "DATE"); // for OciParam
851 SQLTYPE_NAME(SQLT_TIMESTAMP, "TIMESTAMP");
852 SQLTYPE_NAME(SQLT_TIMESTAMP_TZ, "TIMESTAMP WITH TIME ZONE");
853 SQLTYPE_NAME(SQLT_TIMESTAMP_LTZ, "TIMESTAMP WITH LOCAL TIME ZONE");
854 SQLTYPE_NAME(SQLT_INTERVAL_YM, "INTERVAL YEAR TO MONTH");
855 SQLTYPE_NAME(SQLT_INTERVAL_DS, "INTERVAL DAY TO SECOND");
856 SQLTYPE_NAME(SQLT_CHR, "VARCHAR2");
857 SQLTYPE_NAME(SQLT_AFC, "CHAR");
858 SQLTYPE_NAME(SQLT_BIN, "RAW");
859 SQLTYPE_NAME(SQLT_LNG, "LONG");
860 SQLTYPE_NAME(SQLT_LBI, "LONG RAW");
861 SQLTYPE_NAME(SQLT_CLOB, "CLOB");
862 SQLTYPE_NAME(SQLT_BLOB, "BLOB");
863 SQLTYPE_NAME(SQLT_BFILE, "BFILE");
864 SQLTYPE_NAME(SQLT_CFILE, "CFILE");
865 SQLTYPE_NAME(SQLT_RDD, "ROWID");
866 }
867 return L"Unknown Type: Driver is not Support";
868}
869
870__DCL_END_NAMESPACE
#define __THIS_FILE__
Definition _trace.h:14
#define NULL
Definition Config.h:340
unsigned char byte_t
Definition Config.h:274
#define SQLTYPE_NAME(_dataType, name)
Definition IFXField.cpp:288
#define __DCL_TRACE0(psz)
Definition Object.h:375
#define __DCL_ASSERT(expr)
Definition Object.h:371
#define __T(str)
Definition Object.h:44
size_t __MIN(size_t x, size_t y)
Definition OciData.cpp:536
ByteBuffer * buf
#define __SET_ERROR(_errorCode)
Definition SQLCore.cpp:150
void CharsetConvertException *size_t n
Definition SQLField.cpp:253
virtual void destroy()
Definition Exception.cpp:74
OCISvcCtx * svcctxHandle() const
OCIError * errorHandle() const
OCISession * sessionHandle() const
sb2 __indicator
Definition OciData.h:24
bool getData(void *_pv, size_t *_size, SQL::DataType _dataType)
Definition OciData.cpp:202
bool getBytesFromLob(byte_t *_pv, size_t *_size)
Definition OciData.cpp:653
ub2 __dataType
Definition OciData.h:21
sb4 __valueSize
Definition OciData.h:23
OciData()
Definition OciData.cpp:47
ub2 __actualLength
Definition OciData.h:25
OciQuery * __queryHandle
Definition OciData.h:16
bool getInteger(void *_pv, size_t *_size, SQL::DataType _dataType)
Definition OciData.cpp:273
bool onAfterFetch()
Definition OciData.cpp:83
bool getInterval(SQL::Interval *_pv, size_t *_size)
Definition OciData.cpp:481
ub4 __dynamicMode
Definition OciData.h:19
static const wchar_t * dataTypeName(ub2 _dataType)
Definition OciData.cpp:844
bool getNumericText(char *_pv, size_t *_size)
Definition OciData.cpp:331
bool getBytes(byte_t *_pv, size_t *_size)
Definition OciData.cpp:541
bool getDataSize(size_t *_size, bool _maxSize)
Definition OciData.cpp:172
bool getFloat(void *_pv, size_t *_size)
Definition OciData.cpp:302
bool getTimeStamp(SQL::TimeStamp *_pv, size_t *_size)
Definition OciData.cpp:389
size_t __dataSize
Definition OciData.h:30
ub4 __position
Definition OciData.h:17
ub2 __returnCode
Definition OciData.h:27
bool writeToFromLob(OutputStream *_pv, size_t *_size)
Definition OciData.cpp:743
ub4 __callbackActualLength
Definition OciData.h:26
size_t __maxDataSize
Definition OciData.h:31
~OciData()
Definition OciData.cpp:67
OciConnection * conn() const
Definition OciData.h:62
ub4 __descType
Definition OciData.h:18
void * __value
Definition OciData.h:22
bool writeTo(OutputStream *_pv, size_t *_size)
Definition OciData.cpp:598
BytesOutputStream * __bytesOutput
Definition OciData.h:29
DataType
Definition SQLCore.h:62
@ typeBinary
Definition SQLCore.h:76
@ typeLongBinary
Definition SQLCore.h:78
@ typeUInteger
Definition SQLCore.h:65
@ typeTimeStamp
Definition SQLCore.h:70
@ typeTimeStampTz
Definition SQLCore.h:71
@ typeInterval
Definition SQLCore.h:72
@ typeIntervalDs
Definition SQLCore.h:74
@ typeOutputStream
Definition SQLCore.h:84
@ typeText
Definition SQLCore.h:75
@ typeFloat
Definition SQLCore.h:66
@ typeInteger
Definition SQLCore.h:64
@ typeIntervalYm
Definition SQLCore.h:73
@ typeLongText
Definition SQLCore.h:77
@ eNotExecuted
Definition SQLCore.h:42
@ eInvalidBufferSize
Definition SQLCore.h:50
@ eServerError
Definition SQLCore.h:21
@ eNotFetched
Definition SQLCore.h:43
@ eValueIsNull
Definition SQLCore.h:47
size_t __MIN(size_t x, size_t y)
Definition size_t.h:27
int8_t nHours
Definition SQLCore.h:128
int32_t nFracs
Definition SQLCore.h:131
int8_t nSecs
Definition SQLCore.h:130
int8_t nMins
Definition SQLCore.h:129
int32_t nYears
Definition SQLCore.h:125
int8_t nMonths
Definition SQLCore.h:126
int32_t nDays
Definition SQLCore.h:127
int16_t nYear
Definition SQLCore.h:111
uint8_t nDay
Definition SQLCore.h:113
uint8_t nHour
Definition SQLCore.h:114
int16_t nTzMin
Definition SQLCore.h:118
uint8_t nSec
Definition SQLCore.h:116
uint8_t nMonth
Definition SQLCore.h:112
uint8_t nMin
Definition SQLCore.h:115
uint32_t nFrac
Definition SQLCore.h:117