DCL 4.1
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 }
230 case SQL::typeDate: {
231 if (*_size != sizeof(SQL::Date)) {
232 *_size = sizeof(SQL::Date);
234 return false;
235 }
237 size_t size = sizeof(ts);
238 bool r = getTimeStamp(&ts);
239 if (r) {
240 SQL::Date* p = (SQL::Date*)_pv;
241 p->year = ts.year;
242 p->month = ts.month;
243 p->day = ts.day;
244 }
245 return r;
246 }
247 case SQL::typeTime: {
248 if (*_size != sizeof(SQL::typeTime)) {
249 *_size = sizeof(SQL::typeTime);
251 return false;
252 }
254 size_t size = sizeof(ts);
255 bool r = getTimeStamp(&ts);
256 if (r) {
257 SQL::Time* p = (SQL::Time*)_pv;
258 p->hour = ts.hour;
259 p->min = ts.min;
260 p->sec = ts.sec;
261 p->frac = ts.frac;
262 p->tzoff = ts.tzoff;
263 }
264 return r;
265 }
266 case SQL::typeTimeStamp: {
267 if (*_size != sizeof(SQL::TimeStamp)) {
268 *_size = sizeof(SQL::TimeStamp);
270 return false;
271 }
272 return getTimeStamp((SQL::TimeStamp*)_pv);
273 }
274 case SQL::typeInterval: {
275 if (*_size != sizeof(SQL::Interval)) {
276 *_size = sizeof(SQL::Interval);
278 return false;
279 }
280 return getInterval((SQL::Interval*)_pv);
281 }
282 case SQL::typeText: {
283 if (__dataType == SQLT_VNU)
284 return getNumericText((char*)_pv, _size);
285 }
286 case SQL::typeBinary: {
287 return getBytes((byte_t*)_pv, _size);
288 }
290 return writeTo((OutputStream*)_pv, _size);
291 }
292 // case SQL::typeDate :
293 // case SQL::typeTime :
294 default: {
295 __DCL_ASSERT(false); // SQL::Field::getData bug
296 }
297 }
298
299 return true;
300}
301
302bool OciData::getInteger(void* _pv, size_t* _size, SQL::DataType _dataType)
303{
304 __DCL_ASSERT(__dataType == SQLT_VNU); // OciField::init bug
305
306 OCIError* pError = conn()->errorHandle();
307 sword status = OCI_SUCCESS;
308 if (*_size <= sizeof(int64_t /* 2025-02-03 월 int32_t */)) {
309 status = ::OCINumberToInt(
310 pError, // OCIError *err,
311 (CONST OCINumber*)__value, // CONST OCINumber *number,
312 *_size, // uword rsl_length,
313 _dataType == SQL::typeInteger ? // uword rsl_flag,
314 OCI_NUMBER_SIGNED : OCI_NUMBER_UNSIGNED,
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(int64_t);
325 return false;
326 }
327
328 return true;
329}
330
331bool OciData::getFloat(void* _pv, size_t* _size)
332{
333 __DCL_ASSERT(__dataType == SQLT_VNU); // OciField::init bug
334
335 OCIError* pError = conn()->errorHandle();
336 if (*_size <= sizeof(long double)) {
337 // long double 의 storage size
338 // MSVC/WIN32 8
339 // GCC/Linux 12
340 sword status = ::OCINumberToReal(
341 pError, // OCIError *err,
342 (CONST OCINumber*)__value, // CONST OCINumber *number,
343 *_size, // uword rsl_length,
344 _pv // dvoid *rsl
345 );
346 if (status != OCI_SUCCESS) {
347 __SET_ERROR(SQL::eServerError, status, pError);
348 return false;
349 }
350 }
351 else {
352 *_size = sizeof(double);
354 return false;
355 }
356
357 return true;
358}
359
360bool OciData::getNumericText(char* pBuf, size_t* _size)
361{
362 __DCL_ASSERT(__dataType == SQLT_VNU); // OciField::init bug
363
364 OCIError* pError = conn()->errorHandle();
365 ub4 n = 133;
366 ByteBuffer* buf = ByteBuffer::create_e(n);
367 sword status = ::OCINumberToText(
368 pError, // OCIError *err,
369 (CONST OCINumber*)__value, // CONST OCINumber *number,
370 (const OraText*)"TM", // CONST OraText *fmt,
371 2, // ub4 fmt_length,
372 NULL, // CONST OraText *nls_params,
373 0, // ub4 nls_p_length,
374 &n, // ub4 *buf_size,
375 (text*)buf->data() // text *buf
376 );
377 if (status != OCI_SUCCESS) {
378 if (buf->__allocLength < n) {
379 ByteBuffer::extend(buf, n);
380 }
381 status = ::OCINumberToText(
382 pError, // OCIError *err,
383 (CONST OCINumber*)__value, // CONST OCINumber *number,
384 (CONST OraText*)"TM", // CONST OraText *fmt,
385 2, // ub4 fmt_length,
386 NULL, // CONST OraText *nls_params,
387 0, // ub4 nls_p_length,
388 &n, // ub4 *buf_size,
389 (text*)buf->data() // text *buf
390 );
391 }
392 if (status != OCI_SUCCESS) {
393 buf->release();
394 __SET_ERROR(SQL::eServerError, status, pError);
395 return false;
396 }
397
398 buf->__dataLength = n;
399 ByteString s = buf;
400 buf->release();
401
402 if (*_size < (size_t)s.length()) {
403 *_size = (size_t)s.length();
405 return false;
406 }
407
408 strncpy(pBuf, s.data(), s.length());
409 if (*_size > (size_t)s.length()) {
410 *_size = (size_t)s.length();
411 pBuf[*_size] = '\0';
412 }
413
414 return true;
415}
416
417
419{
420 OCISession* pSession = conn()->sessionHandle();
421 OCIError* pError = conn()->errorHandle();
422
423 sb2 nYear = 0;
424 ub1 nMonth = 0;
425 ub1 nDay = 0;
426 ub1 nHour = 0;
427 ub1 nMin = 0;
428 ub1 nSec = 0;
429 ub4 nFSec = 0;
430
431 _pv->tzoff = INT16_MIN;
432
433 sword status = OCI_SUCCESS;
434
435 switch(__dataType) {
436 // case SQLT_DAT :
437 case SQLT_ODT: {
438 OCIDateGetDate(
439 (CONST OCIDate*)__value,
440 &nYear,
441 &nMonth,
442 &nDay
443 );
444 OCIDateGetTime(
445 (CONST OCIDate*)__value,
446 &nHour,
447 &nMin,
448 &nSec
449 );
450 break;
451 }
452 case SQLT_TIMESTAMP :
453 case SQLT_TIMESTAMP_TZ :
454 case SQLT_TIMESTAMP_LTZ: {
455 status = ::OCIDateTimeGetDate(
456 pSession, // dvoid *hndl,
457 pError, // OCIError *err,
458 *(CONST OCIDateTime**)__value, // CONST OCIDateTime *datetime,
459 &nYear, // sb2 *year,
460 &nMonth, // ub1 *month,
461 &nDay // ub1 *day
462 );
463 if (status == OCI_SUCCESS)
464 status = ::OCIDateTimeGetTime(
465 pSession, // dvoid *hndl,
466 pError, // OCIError *err,
467 *(OCIDateTime**)__value, // OCIDateTime *datetime,
468 &nHour, // ub1 *hour,
469 &nMin, // ub1 *min,
470 &nSec, // ub1 *sec,
471 &nFSec // ub4 *fsec
472 );
473 if (status == OCI_SUCCESS && __dataType != SQLT_TIMESTAMP) {
474 sb1 tzHour = 0;
475 sb1 tzMin = 0;
476
477 status = ::OCIDateTimeGetTimeZoneOffset(
478 pSession, // dvoid *hndl,
479 pError, // OCIError *err,
480 *(CONST OCIDateTime**)__value, // CONST OCIDateTime *datetime,
481 &tzHour, // sb1 *hour,
482 &tzMin // sb1 *min,
483 );
484 if (status != OCI_SUCCESS) {
485 __SET_ERROR(SQL::eServerError, status, pError);
486 return false;
487 }
488 // __DCL_TRACE2_N("TZ : %+03d:%02d\n", hour, min);
489 _pv->tzoff = tzHour * 60 + tzMin;
490 }
491 break;
492 }
493 default: {
494 __DCL_ASSERT(false); // OciField::init bug
495 }
496 }
497
498 _pv->year = nYear;
499 _pv->month = nMonth;
500 _pv->day = nDay;
501 _pv->hour = nHour;
502 _pv->min = nMin;
503 _pv->sec = nSec;
504 _pv->frac = nFSec;
505
506 return true;
507}
508
510{
511 OCISession* pSession = conn()->sessionHandle();
512 OCIError* pError = conn()->errorHandle();
513
514 sb4 nYear = 0;
515 sb4 nMonth = 0;
516 sb4 nDay = 0;
517 sb4 nHour = 0;
518 sb4 nMin = 0;
519 sb4 nSec = 0;
520 sb4 nFSec = 0;
521 sword status = OCI_SUCCESS;
522
523 switch(__dataType) {
524 case SQLT_INTERVAL_YM :
525 status = OCIIntervalGetYearMonth(
526 pSession, // dvoid *hndl,
527 pError, // OCIError *err,
528 &nYear, // sb4 *yr,
529 &nMonth, // sb4 *mnth,
530 *(CONST OCIInterval**)__value // CONST OCIInterval *interval
531 );
532 break;
533 case SQLT_INTERVAL_DS :
534 status = OCIIntervalGetDaySecond(
535 pSession, // dvoid *hndl,
536 pError, // OCIError *err,
537 &nDay, // sb4 *dy,
538 &nHour, // sb4 *hr,
539 &nMin, // sb4 *mm,
540 &nSec, // sb4 *ss,
541 &nFSec, // sb4 *fsec,
542 *(CONST OCIInterval**)__value // CONST OCIInterval *interval
543 );
544 break;
545 default :
546 __DCL_ASSERT(false); // OciField::init bug
547 }
548
549 if (status != OCI_SUCCESS) {
550 __SET_ERROR(SQL::eServerError, status, pError);
551 return false;
552 }
553
554 _pv->years = nYear;
555 _pv->months = nMonth;
556 _pv->days = nDay;
557 _pv->hours = nHour;
558 _pv->mins = nMin;
559 _pv->secs = nSec;
560 _pv->fracs = nFSec;
561 return true;
562}
563
564inline size_t __MIN(size_t x, size_t y)
565{
566 return x < y ? x : y;
567}
568
569bool OciData::getBytes(byte_t* _pv, size_t* _size)
570{
571 switch(__dataType) {
572 case SQLT_RDD: {
573 if (*_size < __dataSize) {
574 *_size = __dataSize;
576 return false;
577 }
578 }
579 case SQLT_CHR :
580 case SQLT_AFC :
581 case SQLT_BIN :
582 case SQLT_LNG :
583 case SQLT_LBI: {
584 size_t nTotalSize = __MIN(__dataSize, *_size);
585 size_t nTotalCopy = 0;
586 if (nTotalSize) {
587 size_t nCopy = 0;
588 if (__bytesOutput) {
589 nCopy = __MIN(nTotalSize - nTotalCopy, __bytesOutput->size());
590 if (nCopy) {
591 memcpy(_pv, __bytesOutput->data(), nCopy);
592 nTotalCopy = nCopy;
593 }
594 }
595
596 nCopy = __MIN(nTotalSize - nTotalCopy, __callbackActualLength);
597 if (nCopy) {
598 memcpy(_pv + nTotalCopy, __value, nCopy);
599 nTotalCopy += nCopy;
600 }
601
602 if (nTotalCopy < *_size)
603 *(_pv + nTotalCopy) = '\0';
604 }
605 *_size = nTotalCopy;
606 break;
607 }
608 case SQLT_CLOB:
609 case SQLT_BLOB:
610 case SQLT_CFILE:
611 case SQLT_BFILE: {
612 if (*_size && __dataSize)
613 return getBytesFromLob(_pv, _size);
614 else
615 *_size = 0;
616 break;
617 }
618 default: {
619 __DCL_ASSERT(false); // OciField::init bug
620 }
621 }
622
623 return true;
624}
625
626bool OciData::writeTo(OutputStream* pOutput, size_t* _size)
627{
628 switch(__dataType) {
629 case SQLT_RDD :
630 case SQLT_CHR :
631 case SQLT_AFC :
632 case SQLT_BIN :
633 case SQLT_LNG :
634 case SQLT_LBI: {
635 try {
636 size_t nTotalSize = __MIN(__dataSize, *_size);
637 size_t nTotalWritten = 0;
638 if (nTotalSize) {
639 size_t nWrite = 0;
640 if (__bytesOutput) {
641 nWrite = __MIN(nTotalSize - nTotalWritten, __bytesOutput->size());
642 if (nWrite) {
643 pOutput->write(__bytesOutput->data(), nWrite);
644 nTotalWritten += nWrite;
645 }
646 }
647
648 nWrite = __MIN(nTotalSize - nTotalWritten, __callbackActualLength);
649 if (nWrite) {
650 pOutput->write(__value, nWrite);
651 nTotalWritten += nWrite;
652 }
653 }
654
655 *_size = nTotalWritten;
656 }
657 catch (IOException* e) {
658 e->destroy();
659 return false;
660 }
661 break;
662 }
663 case SQLT_CLOB :
664 case SQLT_BLOB :
665 case SQLT_CFILE :
666 case SQLT_BFILE: {
667 if (*_size && __dataSize)
668 return writeToFromLob(pOutput, _size);
669 else
670 *_size = 0;
671 break;
672 }
673 default: {
674 __DCL_ASSERT(false); // OciField::init bug
675 }
676 }
677
678 return true;
679}
680
681bool OciData::getBytesFromLob(byte_t* _pbuf, size_t* _size)
682{
683 __DCL_ASSERT(__dataType == SQLT_CLOB
684 || __dataType == SQLT_BLOB
685 || __dataType == SQLT_BFILE
686 || __dataType == SQLT_CFILE
687 );
688
689 OCISvcCtx* pSvcCtx = conn()->svcctxHandle();
690 OCIError* pError = conn()->errorHandle();
691 sword status = OCI_SUCCESS;
692 if (__descType == OCI_DTYPE_FILE) {
693 status = ::OCILobFileOpen(
694 pSvcCtx,
695 pError,
696 *(OCILobLocator**)__value,
697 OCI_FILE_READONLY
698 );
699 if (status != OCI_SUCCESS) {
700 __SET_ERROR(SQL::eServerError, status, pError);
701 return false;
702 }
703 }
704
705 bool bResult = true;
706 size_t nTotalRead = 0;
707 ub4 nRead = 0;
708 while(nTotalRead < *_size) {
709 nRead = *_size - nTotalRead;
710 status = ::OCILobRead(
711 pSvcCtx,
712 pError,
713 *((OCILobLocator**)__value),
714 &nRead,
715 1 + nTotalRead, // offset
716 _pbuf, // bufp,
717 nRead, // bufl,
718 NULL, // ctxp
719 (OCICallbackLobRead)NULL,
720 0,
721 SQLCS_IMPLICIT);
722 if (status == OCI_ERROR) {
723 __SET_ERROR(SQL::eServerError, status, pError);
724 bResult = false;
725 break;
726 }
727
728 // OCI_SUCCESS, OCI_NEED_DATA
729 if (nRead) {
730 nTotalRead += nRead;
731 _pbuf += nRead;
732 }
733 else
734 break; // done
735
736// if (status != OCI_NEED_DATA)
737// break;
738 }
739
740 if (__descType == OCI_DTYPE_FILE) {
741 if (bResult) {
742 status = ::OCILobFileClose(
743 pSvcCtx,
744 pError,
745 *(OCILobLocator**)__value);
746 if (status != OCI_SUCCESS) {
747 __SET_ERROR(SQL::eServerError, status, pError);
748 return false;
749 }
750 }
751 else {
752 // 이전에 에러가 발생했다. Close 만 시킨다.
753 status = ::OCILobFileClose(
754 pSvcCtx,
755 conn()->errorHandle2(),
756 *(OCILobLocator**)__value);
757 if (status != OCI_SUCCESS) {
758 __DCL_TRACE0(__T("Warning - OCILobFileClose Fail!\n"));
759 }
760 }
761 }
762
763 if (*_size > nTotalRead)
764 *(_pbuf + nTotalRead) = '\0';
765
766 *_size = nTotalRead;
767
768 return bResult;
769}
770
771bool OciData::writeToFromLob(OutputStream* pOutput, size_t* _size)
772{
773 __DCL_ASSERT(__dataType == SQLT_CLOB
774 || __dataType == SQLT_BLOB
775 || __dataType == SQLT_BFILE
776 || __dataType == SQLT_CFILE
777 );
778
779 OCISvcCtx* pSvcCtx = conn()->svcctxHandle();
780 OCIError* pError = conn()->errorHandle();
781 sword status = OCI_SUCCESS;
782 if (__descType == OCI_DTYPE_FILE) {
783 status = ::OCILobFileOpen(
784 pSvcCtx,
785 pError,
786 *(OCILobLocator**)__value,
787 OCI_FILE_READONLY
788 );
789 if (status != OCI_SUCCESS) {
790 __SET_ERROR(SQL::eServerError, status, pError);
791 return false;
792 }
793 }
794
795 bool bResult = true;
796 size_t nTotalRead = 0;
797 ub4 nRead = 0;
798 char buf[4096];
799 while(nTotalRead < *_size) {
800 nRead = __MIN(*_size - nTotalRead, sizeof(buf));
801 status = ::OCILobRead(
802 pSvcCtx,
803 pError,
804 *((OCILobLocator**)__value),
805 &nRead,
806 1 + nTotalRead, // offset
807 buf, // bufp
808 nRead, // bufl
809 NULL, // ctxp
810 (OCICallbackLobRead)NULL,
811 0,
812 SQLCS_IMPLICIT);
813 if (status == OCI_ERROR) {
814 __SET_ERROR(SQL::eServerError, status, pError);
815 bResult = false;
816 break;
817 }
818
819 if (nRead) {
820 try {
821 pOutput->write(buf, nRead);
822 }
823 catch(IOException* e) {
824 e->destroy();
825 bResult = false;
826 break;
827 }
828
829 nTotalRead += nRead;
830 }
831 else {
832 break; // done
833 }
834
835// if (status != OCI_NEED_DATA)
836// break;
837 }
838
839 if (__descType == OCI_DTYPE_FILE) {
840 if (bResult) {
841 status = ::OCILobFileClose(
842 pSvcCtx,
843 pError,
844 *(OCILobLocator**)__value);
845 if (status != OCI_SUCCESS) {
846 __SET_ERROR(SQL::eServerError, status, pError);
847 return false;
848 }
849 }
850 else {
851 // 이전에 에러가 발생했다. Close 만 시킨다.
852 status = ::OCILobFileClose(
853 pSvcCtx,
854 conn()->errorHandle2(),
855 *(OCILobLocator**)__value);
856 if (status != OCI_SUCCESS) {
857 __DCL_TRACE0(__T("Warning - OCILobFileClose Fail!\n"));
858 }
859 }
860 }
861
862 *_size = nTotalRead;
863 return bResult;
864}
865
866//#ifdef __DCL_DEBUG
867//#define SQLTYPE_NAME(_dataType, name) case _dataType : return #_dataType "-" name
868//#else
869#define SQLTYPE_NAME(_dataType, name) case _dataType : return L ## name
870//#endif
871
872const wchar_t* OciData::dataTypeName(ub2 _dataType)
873{
874 switch(_dataType) {
875 SQLTYPE_NAME(SQLT_NUM, "NUMBER");
876 SQLTYPE_NAME(SQLT_VNU, "NUMBER"); // for OciParam
877 SQLTYPE_NAME(SQLT_DAT, "DATE");
878 SQLTYPE_NAME(SQLT_ODT, "DATE"); // for OciParam
879 SQLTYPE_NAME(SQLT_TIMESTAMP, "TIMESTAMP");
880 SQLTYPE_NAME(SQLT_TIMESTAMP_TZ, "TIMESTAMP WITH TIME ZONE");
881 SQLTYPE_NAME(SQLT_TIMESTAMP_LTZ, "TIMESTAMP WITH LOCAL TIME ZONE");
882 SQLTYPE_NAME(SQLT_INTERVAL_YM, "INTERVAL YEAR TO MONTH");
883 SQLTYPE_NAME(SQLT_INTERVAL_DS, "INTERVAL DAY TO SECOND");
884 SQLTYPE_NAME(SQLT_CHR, "VARCHAR2");
885 SQLTYPE_NAME(SQLT_AFC, "CHAR");
886 SQLTYPE_NAME(SQLT_BIN, "RAW");
887 SQLTYPE_NAME(SQLT_LNG, "LONG");
888 SQLTYPE_NAME(SQLT_LBI, "LONG RAW");
889 SQLTYPE_NAME(SQLT_CLOB, "CLOB");
890 SQLTYPE_NAME(SQLT_BLOB, "BLOB");
891 SQLTYPE_NAME(SQLT_BFILE, "BFILE");
892 SQLTYPE_NAME(SQLT_CFILE, "CFILE");
893 SQLTYPE_NAME(SQLT_RDD, "ROWID");
894 }
895 return L"Unknown Type: Driver is not Support";
896}
897
898__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 INT16_MIN
Definition Config.h:312
#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:564
ByteString r
ByteBuffer * buf
#define __SET_ERROR(_errorCode)
Definition SQLCore.cpp:153
void CharsetConvertException *size_t n
Definition SQLField.cpp:254
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:681
ub2 __dataType
Definition OciData.h:21
sb4 __valueSize
Definition OciData.h:23
OciData()
Definition OciData.cpp:47
bool getInterval(SQL::Interval *_pv)
Definition OciData.cpp:509
bool getTimeStamp(SQL::TimeStamp *_pv)
Definition OciData.cpp:418
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:302
bool onAfterFetch()
Definition OciData.cpp:83
ub4 __dynamicMode
Definition OciData.h:19
static const wchar_t * dataTypeName(ub2 _dataType)
Definition OciData.cpp:872
bool getNumericText(char *_pv, size_t *_size)
Definition OciData.cpp:360
bool getBytes(byte_t *_pv, size_t *_size)
Definition OciData.cpp:569
bool getDataSize(size_t *_size, bool _maxSize)
Definition OciData.cpp:172
bool getFloat(void *_pv, size_t *_size)
Definition OciData.cpp:331
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:771
ub4 __callbackActualLength
Definition OciData.h:26
size_t __maxDataSize
Definition OciData.h:31
~OciData()
Definition OciData.cpp:67
OciConnection * conn() const
Definition OciData.h:64
ub4 __descType
Definition OciData.h:18
void * __value
Definition OciData.h:22
bool writeTo(OutputStream *_pv, size_t *_size)
Definition OciData.cpp:626
BytesOutputStream * __bytesOutput
Definition OciData.h:29
DataType
Definition SQLCore.h:62
@ typeBinary
Definition SQLCore.h:77
@ typeTime
Definition SQLCore.h:69
@ typeUInteger
Definition SQLCore.h:65
@ typeTimeStamp
Definition SQLCore.h:71
@ typeInterval
Definition SQLCore.h:73
@ typeDate
Definition SQLCore.h:68
@ typeOutputStream
Definition SQLCore.h:85
@ typeText
Definition SQLCore.h:76
@ typeFloat
Definition SQLCore.h:66
@ typeInteger
Definition SQLCore.h:64
@ 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
int16_t year
Definition SQLCore.h:97
uint8_t month
Definition SQLCore.h:98
uint8_t day
Definition SQLCore.h:99
int32_t years
Definition SQLCore.h:127
int32_t days
Definition SQLCore.h:129
int8_t hours
Definition SQLCore.h:130
int8_t mins
Definition SQLCore.h:131
int32_t fracs
Definition SQLCore.h:133
int8_t months
Definition SQLCore.h:128
int8_t secs
Definition SQLCore.h:132
uint8_t hour
Definition SQLCore.h:104
uint8_t sec
Definition SQLCore.h:106
uint32_t frac
Definition SQLCore.h:107
uint8_t min
Definition SQLCore.h:105
int16_t tzoff
Definition SQLCore.h:108
uint32_t frac
Definition SQLCore.h:119
int16_t tzoff
Definition SQLCore.h:120
uint8_t min
Definition SQLCore.h:117
uint8_t sec
Definition SQLCore.h:118
uint8_t hour
Definition SQLCore.h:116
uint8_t day
Definition SQLCore.h:115
int16_t year
Definition SQLCore.h:113
uint8_t month
Definition SQLCore.h:114