DCL 4.1
Loading...
Searching...
No Matches
IFXField Class Reference

#include <IFXField.h>

Inheritance diagram for IFXField:
SQL::Field Object

Public Member Functions

 IFXField ()
virtual ~IFXField ()
bool init (SQL::Query *_query, ifx_sqlvar_t *_sqlvar)
bool onAfterFetch ()
virtual bool isNull () const
virtual const wchar_t * serverDataTypeName () const
virtual bool __getDataSize (size_t *_size, bool _maxSize)
virtual bool __getData (void *_pv, size_t *_size, SQL::DataType _dataType)
Public Member Functions inherited from Object
virtual String toString () const
virtual void destroy ()
String className () const
bool isInstanceOf (const std::type_info &typeinfo) const
virtual const std::type_info & typeInfo () const

Protected Member Functions

void setErrorStatus (SQL::Error _error, long _SQLCODE, const wchar_t *_filename, int _line)
void setErrorStatus (const ByteString &_message, const wchar_t *_filename, int _line)
IFXQueryquery () const
bool getInteger (void *_pv, size_t *_size)
bool getUInteger (void *_pv, size_t *_size)
bool getFloat (void *_pv, size_t *_size)
Protected Member Functions inherited from SQL::Field
 Field (Query *_queryHandle)
virtual ~Field ()
Protected Member Functions inherited from Object
virtual ~Object ()
 Object ()

Additional Inherited Members

Protected Attributes inherited from SQL::Field
Query__queryHandle
String __name
DataType __dataType
short __precision
short __scale

Detailed Description

Definition at line 8 of file IFXField.h.

Constructor & Destructor Documentation

◆ IFXField()

IFXField::IFXField ( )

◆ ~IFXField()

IFXField::~IFXField ( )
virtual

Definition at line 63 of file IFXField.cpp.

64{
65 if (__sqlvar) {
66 if (__SQLTYPE_IS(SQLTEXT) || __SQLTYPE_IS(SQLBYTES)) {
67 loc_t* loc = (loc_t*)(__sqlvar->sqldata);
68 if (loc->loc_buffer)
69 ndebug_free(loc->loc_buffer);
70 }
71#if __USE_IFX_VAR
72 if (__SQLTYPE_IS(SQLLVARCHAR)) {
73 mint r = ifx_var_dealloc((void**)(__sqlvar->sqldata));
74 __DCL_TRACE1_N(L"ifx_var_dealloc[%d]\n", r);
75 }
76#endif
77 }
78// __DCL_TRACE1("~IFXField: %s", Field::__name.data());
79}
#define __DCL_TRACE1_N(fmt, arg)
#define __SQLTYPE_IS(_sqltype)
Definition IFXField.cpp:61
int mint
Definition IFXParam.cpp:11
#define ndebug_free(_p)
Definition IFXUtils.h:23
ByteString r

Member Function Documentation

◆ __getData()

bool IFXField::__getData ( void * _pv,
size_t * _size,
SQL::DataType _dataType )
virtual

Implements SQL::Field.

Definition at line 384 of file IFXField.cpp.

389{
390 if (!query()->inState(SQL::Query::stFetched)) {
392 return false;
393 }
394
395 switch(_dataType) {
396 case SQL::typeInteger: {
397 return getInteger(_pv, _size);
398 }
399 case SQL::typeUInteger: {
400 return getUInteger(_pv, _size);
401 }
402 case SQL::typeFloat: {
403 return getFloat(_pv, _size);
404 }
405 case SQL::typeDate: {
406 __DCL_ASSERT(__SQLTYPE_IS(SQLDATE));
407 short mdy[3];
408 __DCL_VERIFY(rjulmdy(*(long*)(__sqlvar->sqldata), mdy) == 0);
409 SQL::Date* p = (SQL::Date*)_pv;
410 p->month = (uint8_t)mdy[0];
411 p->day = (uint8_t)mdy[1];
412 p->year = mdy[2];
413 break;
414 }
415 case SQL::typeTime: {
416 __DCL_ASSERT(__SQLTYPE_IS(SQLDTIME));
418 (const dtime_t*)(__sqlvar->sqldata),
419 (SQL::Time*)_pv
420 );
421 break;
422 }
423 case SQL::typeTimeStamp: {
424 __DCL_ASSERT(__SQLTYPE_IS(SQLDTIME));
426 (const dtime_t*)(__sqlvar->sqldata),
427 (SQL::TimeStamp*)_pv
428 );
429 break;
430 }
431 case SQL::typeInterval: {
432 __DCL_ASSERT(__SQLTYPE_IS(SQLINTERVAL));
434 (const intrvl_t*)(__sqlvar->sqldata),
435 (SQL::Interval*)_pv
436 );
437 break;
438 }
439 case SQL::typeText: {
440 if (Field::__dataType == SQL::typeNumeric) {
441 __DCL_ASSERT(__SQLTYPE_IS(SQLDECIMAL)
442 || __SQLTYPE_IS(SQLMONEY));
443 if (*_size < __dataSize) {
445 return false;
446 }
447 char* ps = (char*)_pv;
448 if (dectoasc(
449 (dec_t*)(__sqlvar->sqldata),
450 ps,
451 *_size,
452 -1
453 )) {
454 // invalid buffer size
455 // __get_dec_strlen 함수 버그
456 __DCL_ASSERT(false);
457 }
458 size_t len = 0;
459 for (; len < *_size; len++) {
460 if (ps[len] == ' ')
461 break;
462 }
463 if (len < *_size) {
464 *_size = len;
465 ps[len] = '\0';
466 }
467 break;
468 }
469 }
470 case SQL::typeBinary: {
471 switch (__sqlvar->sqltype & SQLTYPE) {
472 case SQLLVARCHAR: {
473#if __USE_IFX_VAR
474 int nLen = ifx_var_getlen((void**)(__sqlvar->sqldata));
475 if (nLen < 0) {
477 return false;
478 }
479
480 void* pSrc = ifx_var_getdata((void**)(__sqlvar->sqldata));
481 if (nLen > 0 && *_size > 0 && pSrc != NULL) {
482 size_t nCopy = *_size;
483 if ((size_t)nLen < nCopy)
484 nCopy = (size_t)nLen;
485
486 memcpy(_pv, pSrc, nCopy);
487 if (nCopy < *_size) {
488 *((char*)_pv + nCopy) = '\0';
489 *_size = nCopy;
490 }
491 }
492 else {
493 *_size = 0;
494 }
495 break;
496#endif
497 }
498 case SQLCHAR:
499 case SQLNCHAR:
500 case SQLVCHAR:
501 case SQLNVCHAR: {
502 if (__sqlvar->sqllen > 0 && *_size > 0) {
503 size_t nCopy = *_size;
504 if ((size_t)(__sqlvar->sqllen) < nCopy)
505 nCopy = (size_t)(__sqlvar->sqllen);
506
507 memcpy(_pv, __sqlvar->sqldata, nCopy);
508
509 if (nCopy < *_size) {
510 *((char*)_pv + nCopy) = '\0';
511 *_size = nCopy;
512 }
513 }
514 else
515 *_size = 0;
516 break;
517 }
518 case SQLTEXT:
519 case SQLBYTES: {
520 if (((loc_t*)(__sqlvar->sqldata))->loc_size > 0
521 && *_size > 0) {
522 loc_t* loc = (loc_t*)(__sqlvar->sqldata);
523 size_t nCopy = *_size;
524 if ((size_t)(loc->loc_size) < nCopy)
525 nCopy = (size_t)(loc->loc_size);
526
527 memcpy(_pv, loc->loc_buffer, nCopy);
528 if (nCopy < *_size) {
529 *((char*)_pv + nCopy) = '\0';
530 *_size = nCopy;
531 }
532 }
533 else {
534 *_size = 0;
535 }
536 break;
537 }
538 default: {
539 __DCL_ASSERT(false);
540 }
541 }
542 break;
543 }
545 switch (__sqlvar->sqltype & SQLTYPE) {
546 case SQLCHAR:
547 case SQLNCHAR:
548 case SQLVCHAR:
549 case SQLNVCHAR: {
550 if (__sqlvar->sqllen > 0 && *_size > 0) {
551 if ((size_t)(__sqlvar->sqllen) < *_size)
552 *_size = (size_t)(__sqlvar->sqllen);
553
554 try {
555 ((OutputStream*)_pv)->write(
556 __sqlvar->sqldata, *_size);
557 }
558 catch (IOException* e) {
559 __SET_ERROR_MSG(UTF8Encoder::encode(e->toStringAll()));
560 e->destroy();
561 return false;
562 }
563 }
564 else {
565 *_size = 0;
566 }
567 break;
568 }
569 case SQLLVARCHAR: {
570 int nLen = ifx_var_getlen((void**)(__sqlvar->sqldata));
571 if (nLen < 0) {
573 return false;
574 }
575
576 void* pSrc = ifx_var_getdata((void**)(__sqlvar->sqldata));
577 if (nLen > 0 && *_size > 0 && pSrc != NULL) {
578 if ((size_t)nLen < *_size)
579 *_size = (size_t)nLen;
580
581 try {
582 ((OutputStream*)_pv)->write(
583 pSrc, *_size);
584 }
585 catch (IOException* e) {
586 __SET_ERROR_MSG(UTF8Encoder::encode(e->toStringAll()));
587 e->destroy();
588 return false;
589 }
590 }
591 else {
592 *_size = 0;
593 }
594 break;
595 }
596 case SQLTEXT:
597 case SQLBYTES: {
598 if (((loc_t*)(__sqlvar->sqldata))->loc_size > 0) {
599 loc_t* loc = (loc_t*)(__sqlvar->sqldata);
600
601 if ((size_t)(loc->loc_size) < *_size)
602 *_size = (size_t)(loc->loc_size);
603
604 if (*_size) {
605 try {
606 ((OutputStream*)_pv)->write(
607 loc->loc_buffer, *_size);
608 }
609 catch (IOException* e) {
610 __SET_ERROR_MSG(UTF8Encoder::encode(e->toStringAll()));
611 e->destroy();
612 return false;
613 }
614 }
615 }
616 else {
617 *_size = 0;
618 }
619 break;
620 }
621 default: {
622 __DCL_ASSERT(false);
623 }
624 }
625 break;
626 }
627 default: {
628 __DCL_ASSERT(false); // SQL::Field::getData bug
629 }
630 }
631 return true;
632}
#define NULL
Definition Config.h:340
#define __SET_ERROR_SQLCODE(SQLCODE)
#define __SET_ERROR_MSG(_message)
void __decode_dtime(const dtime_t *_s, SQL::TimeStamp *_r)
Definition IFXTypes.cpp:221
void __decode_intrvl(const intrvl_t *_s, SQL::Interval *_r)
Definition IFXTypes.cpp:118
#define __DCL_VERIFY(expr)
Definition Object.h:373
#define __DCL_ASSERT(expr)
Definition Object.h:371
size_t len
#define __SET_ERROR(_errorCode)
Definition SQLCore.cpp:153
virtual void destroy()
Definition Exception.cpp:74
String toStringAll() const
Definition Exception.cpp:45
IFXQuery * query() const
Definition IFXField.h:68
bool getFloat(void *_pv, size_t *_size)
Definition IFXField.cpp:916
bool getUInteger(void *_pv, size_t *_size)
Definition IFXField.cpp:775
bool getInteger(void *_pv, size_t *_size)
Definition IFXField.cpp:634
@ typeBinary
Definition SQLCore.h:77
@ typeNumeric
Definition SQLCore.h:67
@ 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
@ eInvalidBufferSize
Definition SQLCore.h:50
@ eNotFetched
Definition SQLCore.h:43
int16_t year
Definition SQLCore.h:97
uint8_t month
Definition SQLCore.h:98
uint8_t day
Definition SQLCore.h:99

◆ __getDataSize()

bool IFXField::__getDataSize ( size_t * _size,
bool _maxSize )
virtual

Implements SQL::Field.

Definition at line 345 of file IFXField.cpp.

346{
347 if (_maxSize) {
348 *_size = __maxDataSize;
349 return true;
350 }
351
352 if (!query()->inState(SQL::Query::stFetched)) {
354 return false;
355 }
356
357 if (!isNull()) {
358 // not null
359 switch(__sqlvar->sqltype & SQLTYPE) {
360 case SQLDECIMAL:
361 case SQLMONEY:
362 case SQLCHAR:
363 case SQLNCHAR:
364 case SQLVCHAR:
365 case SQLNVCHAR:
366 case SQLLVARCHAR:
367 case SQLTEXT:
368 case SQLBYTES: {
369 *_size = __dataSize;
370 break;
371 }
372 default: {
373 *_size = __maxDataSize;
374 }
375 }
376 }
377 else {
378 *_size = 0;
379
380 }
381 return true;
382}
virtual bool isNull() const
Definition IFXField.cpp:337

◆ getFloat()

bool IFXField::getFloat ( void * _pv,
size_t * _size )
protected

Definition at line 916 of file IFXField.cpp.

917{
918 switch(__sqlvar->sqltype & SQLTYPE) {
919 case SQLSMFLOAT: {
920 switch (*_size) {
921 case sizeof(float) : {
922 *(float*)_pv = *(float*)(__sqlvar->sqldata);
923 break;
924 }
925 case sizeof(double) : {
926 *(double*)_pv = *(float*)(__sqlvar->sqldata);
927 break;
928 }
929 default: {
930 *_size = sizeof(float);
932 return false;
933 }
934 }
935 break;
936 }
937 case SQLFLOAT: {
938 switch (*_size) {
939 case sizeof(double) : {
940 *(double*)_pv = *(double*)(__sqlvar->sqldata);
941 break;
942 }
943 default: {
944 *_size = sizeof(double);
946 return false;
947 }
948 }
949 break;
950 }
951 case SQLDECIMAL:
952 case SQLMONEY: {
953 double d;
954 if (dectodbl((dec_t*)__sqlvar->sqldata, &d)) {
956 return false;
957 }
958
959 switch (*_size) {
960 case sizeof(float) : {
961 if (d < FLT_MIN || FLT_MAX < d) {
963 return false;
964 }
965 *(float*)_pv = (float)d;
966 break;
967 }
968 case sizeof(double) : {
969 *(double*)_pv = d;
970 break;
971 }
972 default: {
973 *_size = sizeof(double);
975 return false;
976 }
977 }
978 break;
979 }
980 default: {
981 __DCL_ASSERT(false);
982 }
983 }
984
985 return true;
986}
@ eOutOfRange
Definition SQLCore.h:52

◆ getInteger()

bool IFXField::getInteger ( void * _pv,
size_t * _size )
protected

Definition at line 634 of file IFXField.cpp.

635{
636 switch(__sqlvar->sqltype & SQLTYPE) {
637 case SQLSMINT: {
638 switch (*_size) {
639 case sizeof(int16_t) : {
640 *(int16_t*)_pv = *(int16_t*)(__sqlvar->sqldata);
641 break;
642 }
643 case sizeof(int32_t) : {
644 *(int32_t*)_pv = (int32_t) * (int16_t*)(__sqlvar->sqldata);
645 break;
646 }
647 case sizeof(int64_t) : {
648 *(int64_t*)_pv = (int64_t) * (int16_t*)(__sqlvar->sqldata);
649 break;
650 }
651 default: {
652 *_size = sizeof(int16_t);
654 return false;
655 }
656 }
657 break;
658 }
659 case SQLINT:
660 case SQLSERIAL: {
661 switch (*_size) {
662 case sizeof(int32_t) : {
663 *(int32_t*)_pv = *(int32_t*)(__sqlvar->sqldata);
664 break;
665 }
666 case sizeof(int64_t) : {
667 *(int64_t*)_pv = (int64_t) * (int32_t*)(__sqlvar->sqldata);
668 break;
669 }
670 default: {
671 *_size = sizeof(int32_t);
673 return false;
674 }
675 }
676 break;
677 }
678 case SQLINFXBIGINT:
679 case SQLBIGSERIAL: {
680 switch (*_size) {
681 case sizeof(int64_t) : {
682 *(int64_t*)_pv = (int64_t) * (int64_t*)(__sqlvar->sqldata);
683 break;
684 }
685 default: {
686 *_size = sizeof(int64_t);
688 return false;
689 }
690 }
691 break;
692 }
693 case SQLINT8:
694 case SQLSERIAL8: {
695 if (*_size == sizeof(int64_t)) {
696 const ifx_int8_t* p = (const ifx_int8_t*)__sqlvar->sqldata;
697 __DCL_ASSERT(p->sign != 0); // assert(not null)
698 if (p->sign == 1)
699 *(int64_t*)_pv = (int64_t) * (uint64_t*)(p->data);
700 else // -1
701 *(int64_t*)_pv = -((int64_t) * (uint64_t*)(p->data));
702 }
703 else {
704 *_size = sizeof(int64_t);
706 return false;
707 }
708 break;
709 }
710 case SQLDECIMAL :
711 case SQLMONEY: {
712 if (*_size <= sizeof(int32_t)) {
713 int4 n;
714 if (dectolong((dec_t*)__sqlvar->sqldata, &n)) {
715 // -1200
717 return false;
718 }
719
720 switch (*_size) {
721 case sizeof(int8_t) : {
722 if (n < INT8_MIN || INT8_MAX < n) {
724 return false;
725 }
726 *(int8_t*)_pv = (int8_t)n;
727 break;
728 }
729 case sizeof(int16_t) : {
730 if (n < INT16_MIN || INT16_MAX < n) {
732 return false;
733 }
734 *(int16_t*)_pv = (int16_t)n;
735 break;
736 }
737 case sizeof(int32_t) : {
738 *(int32_t*)_pv = (int32_t)n;
739 break;
740 }
741 default: {
742 *_size = sizeof(int32_t);
744 return false;
745 }
746 }
747 }
748 else if (*_size == sizeof(int64_t)) {
749 ifx_int8_t n;
750 if (ifx_int8cvdec((dec_t*)__sqlvar->sqldata, &n)) {
752 return false;
753 }
754
755 __DCL_ASSERT(n.sign != 0); // assert(not null)
756 if (n.sign == 1)
757 *(int64_t*)_pv = (int64_t) * (uint64_t*)(n.data);
758 else // -1
759 *(int64_t*)_pv = -((int64_t) * (uint64_t*)(n.data));
760 }
761 else {
762 *_size = sizeof(int64_t);
764 return false;
765 }
766 break;
767 }
768 default: {
769 __DCL_ASSERT(false);
770 }
771 }
772 return true;
773}
#define INT8_MIN
Definition Config.h:311
#define INT8_MAX
Definition Config.h:316
#define INT16_MAX
Definition Config.h:317
#define INT16_MIN
Definition Config.h:312
void CharsetConvertException *size_t n
Definition SQLField.cpp:254

◆ getUInteger()

bool IFXField::getUInteger ( void * _pv,
size_t * _size )
protected

Definition at line 775 of file IFXField.cpp.

776{
777 switch(__sqlvar->sqltype & SQLTYPE) {
778 case SQLSMINT :
779 switch(*_size) {
780 case sizeof(uint16_t) : {
781 *(uint16_t*)_pv = (uint16_t) * (int16_t*)(__sqlvar->sqldata);
782 break;
783 }
784 case sizeof(uint32_t) : {
785 *(uint32_t*)_pv = (uint32_t) * (int16_t*)(__sqlvar->sqldata);
786 break;
787 }
788 case sizeof(uint64_t) : {
789 *(uint64_t*)_pv = (uint64_t) * (int16_t*)(__sqlvar->sqldata);
790 break;
791 }
792 default: {
793 *_size = sizeof(uint16_t);
795 return false;
796 }
797 }
798 break;
799 case SQLINT:
800 case SQLSERIAL: {
801 switch (*_size) {
802 case sizeof(uint32_t) : {
803 *(uint32_t*)_pv = (uint32_t) * (int32_t*)(__sqlvar->sqldata);
804 break;
805 }
806 case sizeof(int64_t) : {
807 *(uint64_t*)_pv = (uint64_t) * (int32_t*)(__sqlvar->sqldata);
808 break;
809 }
810 default: {
811 *_size = sizeof(int32_t);
813 return false;
814 }
815 }
816 break;
817 }
818 case SQLINFXBIGINT:
819 case SQLBIGSERIAL: {
820 switch (*_size) {
821 case sizeof(int64_t) : {
822 *(uint64_t*)_pv = (uint64_t) * (int64_t*)(__sqlvar->sqldata);
823 break;
824 }
825 default: {
826 *_size = sizeof(uint64_t);
828 return false;
829 }
830 }
831 break;
832 }
833 case SQLINT8:
834 case SQLSERIAL8: {
835 if (*_size == sizeof(int64_t)) {
836 const ifx_int8_t* p = (const ifx_int8_t*)__sqlvar->sqldata;
837 __DCL_ASSERT(p->sign != 0); // assert(not null)
838 if (p->sign == 1)
839 *(uint64_t*)_pv = *(uint64_t*)(p->data);
840 else // -1
841 *(uint64_t*)_pv = (uint64_t)(-((int64_t) * (uint64_t*)(p->data)));
842 }
843 else {
844 *_size = sizeof(int64_t);
846 return false;
847 }
848 break;
849 }
850 case SQLDECIMAL :
851 case SQLMONEY: {
852 if (*_size <= sizeof(uint32_t)) {
853 int4 n;
854 if (dectolong((dec_t*)__sqlvar->sqldata, &n)) {
855 // -1200
857 return false;
858 }
859
860 switch (*_size) {
861 case sizeof(uint8_t) : {
862 if (n < INT8_MIN || INT8_MAX < n) {
864 return false;
865 }
866 *(uint8_t*)_pv = (uint8_t)n;
867 break;
868 }
869 case sizeof(uint16_t) : {
870 if (n < INT16_MIN || INT16_MAX < n) {
872 return false;
873 }
874 *(uint16_t*)_pv = (uint16_t)n;
875 break;
876 }
877 case sizeof(uint32_t) : {
878 *(uint32_t*)_pv = (uint32_t)n;
879 break;
880 }
881 default: {
882 *_size = sizeof(uint32_t);
884 return false;
885 }
886 }
887 }
888 else if (*_size == sizeof(uint64_t)) {
889 ifx_int8_t n;
890 if (ifx_int8cvdec((dec_t*)__sqlvar->sqldata, &n)) {
892 return false;
893 }
894
895 __DCL_ASSERT(n.sign != 0); // assert(not null)
896 if (n.sign == 1)
897 *(uint64_t*)_pv = *(uint64_t*)(n.data);
898 else // -1
899 *(uint64_t*)_pv = (uint64_t)(-((int64_t) * (uint64_t*)(n.data)));
900 }
901 else {
902 *_size = sizeof(int64_t);
904 return false;
905 }
906 break;
907 }
908 default: {
909 __DCL_ASSERT(false); // IFXField::init bug
910 }
911 }
912
913 return true;
914}

◆ init()

bool IFXField::init ( SQL::Query * _query,
ifx_sqlvar_t * _sqlvar )

Definition at line 81 of file IFXField.cpp.

82{
83 __DCL_ASSERT((Field::__queryHandle == NULL) && (__sqlvar == NULL));
84 __DCL_ASSERT((_sqlvar != NULL) && (_sqlvar->sqldata != NULL));
85
86 Field::__queryHandle = _queryHandle;
87 __sqlvar = _sqlvar;
88 __sqlvar->sqlind = &__indicator;
89
90 /*
91 2005.12.29 ByteString::makeUpper을 toUpperCase로 변경
92 Field::__name.assign(__sqlvar->sqlname);
93 Field::__name.makeUpper();
94 */
95 try {
96 Field::__name = UTF8Decoder::decode(__sqlvar->sqlname).toUpperCase();
97 }
98 catch (CharsetConvertException* _e) {
99 __SET_ERROR_MSG(UTF8Encoder::encode(_e->toStringAll()));
100 _e->destroy();
101 return false;
102 }
103
104 switch(__sqlvar->sqltype & SQLTYPE) {
105 case SQLSMINT: {
106 Field::__dataType = SQL::typeInteger;
107 __maxDataSize = sizeof(int16_t);
108 break;
109 }
110 case SQLINT:
111 case SQLSERIAL: {
112 Field::__dataType = SQL::typeInteger;
113 __maxDataSize = sizeof(int32_t);
114 break;
115 }
116 case SQLINT8:
117 case SQLSERIAL8:
118 case SQLINFXBIGINT:
119 case SQLBIGSERIAL: {
120 Field::__dataType = SQL::typeInteger;
121 __maxDataSize = sizeof(int64_t);
122 break;
123 }
124 case SQLSMFLOAT: {
125 Field::__dataType = SQL::typeFloat;
126 __maxDataSize = sizeof(float);
127 break;
128 }
129 case SQLFLOAT: {
130 Field::__dataType = SQL::typeFloat;
131 __maxDataSize = sizeof(double);
132 break;
133 }
134 case SQLDECIMAL:
135 case SQLMONEY: {
136 Field::__dataType = SQL::typeNumeric;
137 // float decimal
138 // max : 10^124 ==> 124, min : // 10^-130 : 130 + "-0." ESQL/C manual
139 // 10^(64 * 2) + "-0." 128 + 3 = 131 incl/esql/decimal.h
140 __maxDataSize = 133;
141 break;
142 }
143 case SQLDATE: {
144 Field::__dataType = SQL::typeDate;
145 __maxDataSize = sizeof(SQL::Date);
146 break;
147 }
148 case SQLDTIME: {
149 if (TU_START(__sqlvar->sqllen) >= TU_HOUR) {
150 Field::__dataType = SQL::typeTime;
151 __maxDataSize = sizeof(SQL::Time);
152 }
153 else {
154 Field::__dataType = SQL::typeTimeStamp;
155 __maxDataSize = sizeof(SQL::TimeStamp);
156 }
157 break;
158 }
159 case SQLINTERVAL: {
160 if (TU_START(__sqlvar->sqllen) >= TU_DAY)
161 Field::__dataType = SQL::typeIntervalDs;
162 else
163 Field::__dataType = SQL::typeIntervalYm;
164 __maxDataSize = sizeof(SQL::Interval);
165 break;
166 }
167 case SQLCHAR:
168 case SQLNCHAR: {
169 Field::__dataType = SQL::typeText;
170 __maxDataSize = 32767;
171 break;
172 }
173 case SQLVCHAR:
174 case SQLNVCHAR: {
175 Field::__dataType = SQL::typeText;
176 __maxDataSize = 255;
177 break;
178 }
179 case SQLLVARCHAR: {
180 Field::__dataType = SQL::typeText;
181 __maxDataSize = 32739;
182#if __USE_IFX_VAR
183 // automatic memory alloc
184 mint r = ifx_var_flag((void**)(__sqlvar->sqldata), 1);
185 __DCL_TRACE1_N(L"ifx_var_flag[%d]\n", r);
186 if (r) {
188 return false;
189 }
190#endif
191 break;
192 }
193 case SQLTEXT: {
194 Field::__dataType = SQL::typeLongText;
195 __maxDataSize = INT32_MAX;
196 // init locator
197 loc_t* loc = (loc_t*)(__sqlvar->sqldata);
198 loc->loc_loctype = LOCMEMORY;
199 loc->loc_buffer = NULL;
200 loc->loc_bufsize = -1;
201 loc->loc_size = -1;
202 loc->loc_mflags = 0;
203 loc->loc_oflags = 0;
204 loc->loc_indicator = 0;
205 break;
206 }
207 case SQLBYTES: {
208 Field::__dataType = SQL::typeLongBinary;
209 __maxDataSize = INT32_MAX;
210 // init locator
211 loc_t* loc = (loc_t*)(__sqlvar->sqldata);
212 loc->loc_loctype = LOCMEMORY;
213 loc->loc_buffer = NULL;
214 loc->loc_bufsize = -1;
215 loc->loc_size = -1;
216 loc->loc_mflags = 0;
217 loc->loc_oflags = 0;
218 loc->loc_indicator = 0;
219 break;
220 }
221 default: {
222 __DCL_TRACE2_N(L"[%hs][%d]\n",
223 Field::__name.data(), __sqlvar->sqltype & SQLTYPE);
224 __DCL_ASSERT(false);
225 }
226 }
227 return true;
228}
#define INT32_MAX
Definition Config.h:318
#define __DCL_TRACE2_N(fmt, arg1, arg2)
@ typeLongBinary
Definition SQLCore.h:79
@ typeIntervalDs
Definition SQLCore.h:75
@ typeIntervalYm
Definition SQLCore.h:74
@ typeLongText
Definition SQLCore.h:78

◆ isNull()

bool IFXField::isNull ( ) const
virtual

Implements SQL::Field.

Definition at line 337 of file IFXField.cpp.

338{
339 if (!query()->inState(SQL::Query::stFetched)) {
340 return true;
341 }
342 return __indicator == -1;
343}

◆ onAfterFetch()

bool IFXField::onAfterFetch ( )

Definition at line 230 of file IFXField.cpp.

231{
232#if __TRACE_THIS && 1
233 __DCL_TRACE4_N(L"[%ls] sqllen[%d] indicator[%d][%p]\n",
234 __name.data(), __sqlvar->sqllen, __indicator, __sqlvar->sqldata);
235#endif
236 if (__indicator != -1) {
237 // not null
238 switch (__sqlvar->sqltype & SQLTYPE) {
239 case SQLDECIMAL:
240 case SQLMONEY: {
241 __dataSize = __get_dec_strlen((const dec_t*)(__sqlvar->sqldata));
242 break;
243 }
244 case SQLCHAR:
245 case SQLNCHAR: {
246 __dataSize = __sqlvar->sqllen - 1;
247 break;
248 }
249 case SQLVCHAR:
250 case SQLNVCHAR: {
251 __dataSize = ByteString::length(__sqlvar->sqldata, __sqlvar->sqllen);
252 break;
253 }
254 case SQLLVARCHAR: {
255#if __USE_IFX_VAR
256 int n = ifx_var_getlen((void**)(__sqlvar->sqldata));
257 __DCL_TRACE1_N(L"ifx_var_getlen[%d]\n", n);
258 if (n < 0) {
260 return false;
261 }
262 __dataSize = n;
263#else
264 __dataSize = ByteString::length(__sqlvar->sqldata, __sqlvar->sqllen);
265#endif
266 break;
267 }
268 case SQLTEXT:
269 case SQLBYTES: {
270 loc_t* loc = (loc_t*)(__sqlvar->sqldata);
271 if (loc->loc_status != 0) {
272 __SET_ERROR_SQLCODE(loc->loc_status);
273 return false;
274 }
275 loc->loc_mflags = LOC_ALLOC;
276
277 if (loc->loc_indicator == -1)
278 __dataSize = 0;
279 else
280 __dataSize = loc->loc_size;
281 break;
282 }
283 }
284 }
285 return true;
286}
#define __DCL_TRACE4_N(fmt, arg1, arg2, arg3, arg4)
Definition IFXField.cpp:41
__DCL_BEGIN_NAMESPACE size_t __get_dec_strlen(const dec_t *p)
Definition IFXTypes.cpp:26
String __name
Definition SQLCore.h:185

◆ query()

IFXQuery * IFXField::query ( ) const
inlineprotected

Definition at line 68 of file IFXField.h.

69{
70 return (IFXQuery*)Field::__queryHandle;
71}

◆ serverDataTypeName()

const wchar_t * IFXField::serverDataTypeName ( ) const
virtual

Implements SQL::Field.

Definition at line 332 of file IFXField.cpp.

333{
334 return __dataTypeName(__sqlvar);
335}
const wchar_t * __dataTypeName(const ifx_sqlvar_t *_sqlvar)
Definition IFXField.cpp:290

◆ setErrorStatus() [1/2]

void IFXField::setErrorStatus ( const ByteString & _message,
const wchar_t * _filename,
int _line )
inlineprotected

Definition at line 58 of file IFXField.h.

60{
61 ((IFXConnection*)Field::connection())->setErrorStatus(
62 _message,
63 _filename,
64 _line
65 );
66}

◆ setErrorStatus() [2/2]

void IFXField::setErrorStatus ( SQL::Error _error,
long _SQLCODE,
const wchar_t * _filename,
int _line )
inlineprotected

Definition at line 47 of file IFXField.h.

49{
50 ((IFXConnection*)Field::connection())->setErrorStatus(
51 _error,
52 _SQLCODE,
53 _filename,
54 _line
55 );
56}

The documentation for this class was generated from the following files: