DCL 3.7.4
Loading...
Searching...
No Matches
ODBCParam.cpp
Go to the documentation of this file.
1#include <dcl/Config.h>
2
3#include <string.h> // memset
4#include <stdlib.h> // malloc
5
6#ifdef _MSC_VER
7#include <windows.h>
8#endif
9#include <sql.h>
10#include <sqlext.h>
11#include <msodbcsql.h>
12
13#include <dcl/Object.h>
14#if __DCL_HAVE_ALLOC_DEBUG
15#undef __DCL_ALLOC_LEVEL
16#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
17#endif
18
19#include <dcl/size_t.h>
20#include <dcl/SQLCore.h>
21#include <dcl/Numeric.h>
22#include <dcl/InputStream.h>
23#include <dcl/Charset.h>
24
25#include "ODBCConnection.h"
26#include "ODBCQuery.h"
27#include "ODBCData.h"
28#include "ODBCParam.h"
29
30#define __TRACE_THIS 0
31#if __TRACE_THIS
32#define __DCL_TRACE0_N __DCL_TRACE0
33#define __DCL_TRACE1_N __DCL_TRACE1
34#define __DCL_TRACE2_N __DCL_TRACE2
35#define __DCL_TRACE3_N __DCL_TRACE3
36#define __DCL_TRACE4_N __DCL_TRACE4
37#else
38#define __DCL_TRACE0_N(fmt)
39#define __DCL_TRACE1_N(fmt, arg)
40#define __DCL_TRACE2_N(fmt, arg1, arg2)
41#define __DCL_TRACE3_N(fmt, arg1, arg2, arg3)
42#define __DCL_TRACE4_N(fmt, arg1, arg2, arg3, arg4)
43#endif
44
45#undef __THIS_FILE__
46static const char_t __THIS_FILE__[] = __T("dcl/sql/ODBCParam.cpp");
47
48__DCL_BEGIN_NAMESPACE
49
50#define __SET_ERROR(_error) \
51 connection()->setErrorStatus(_error, __THIS_FILE__, __LINE__)
52#define __SET_ERROR_MSG(_msg) \
53 conn()->setErrorMessage(_msg, __THIS_FILE__, __LINE__)
54#define __SET_ERROR_HANDLE(_rc, _htype, _handle) \
55 conn()->setErrorHandle(_rc, _htype, _handle, __THIS_FILE__, __LINE__)
56
58
60 : Param(NULL)
61{
62 __val = NULL;
63 __outputType = SQL::typeUnknown;
64}
65
67{
68 // __DCL_TRACE1_N(L"~ODBCParam [%ls]\n", Field::__name.data());
69}
70
72{
73 return (ODBCQuery*)Param::__queryHandle;
74}
75
76bool ODBCParam::init(SQL::Query* _query, BIND* _bind)
77{
78 __DCL_ASSERT(Param::__queryHandle == NULL);
79 Param::__queryHandle = _query;
80 Param::__dataType = ODBCData::init(_bind);
81
82 if (Param::__dataType == SQL::typeUnknown) {
84 return false;
85 }
86 return true;
87}
88
90{
91 SQLSMALLINT paramType = SQL_PARAM_TYPE_UNKNOWN;
92 SQLPOINTER valuePtr = NULL;
93 if (__outputType == SQL::typeUnknown) {
94 if (__val) {
95 switch (__valType) {
96 case SQL::typeText:
97 case SQL::typeBinary: {
98 valuePtr = __val;
99 __bind->lenORind = (SQLLEN)__valSize;
100 break;
101 }
103 valuePtr = this;
104 __bind->lenORind = SQL_DATA_AT_EXEC;
105 break;
106 }
107 default: {
108 valuePtr = __bind->valuePtr;
109 }
110 }
111 }
112 else {
113 __bind->lenORind = SQL_NULL_DATA;
114 }
115 paramType = SQL_PARAM_INPUT;
116 }
117 else if (__bind->size) {
118 if (__val) {
119 switch (__valType) {
120 case SQL::typeText:
121 case SQL::typeBinary: {
122 __DCL_ASSERT(__valSize <= (size_t)__bind->valueMax);
123 memcpy(__bind->valuePtr, __val, __valSize);
124 __bind->lenORind = (SQLLEN)__valSize;
125 break;
126 }
128 size_t read = ((InputStream*)__val)->read(
129 __bind->valuePtr, __bind->valueMax);
130 __DCL_ASSERT(read <= (size_t)__bind->valueMax);
131 __bind->lenORind = (SQLLEN)read;
132 break;
133 }
134 default: {
135 // 그 외에는 모두 __bind->valuePtr에 있다.
136 }
137 }
138 paramType = SQL_PARAM_INPUT_OUTPUT;
139 }
140 else {
141 paramType = SQL_PARAM_OUTPUT;
142 }
143 valuePtr = __bind->valuePtr;
144 }
145 else {
146 // VARCHAR(MAX), NVARCHAR(MAX) VARBINARY(MAX),
147 // CLOB, NCLOB, BLOB
148 if (__val) {
149 switch (__valType) {
150 case SQL::typeText:
151 case SQL::typeBinary: {
152 __bind->lenORind = SQL_LEN_DATA_AT_EXEC((SQLLEN)__valSize);
153 break;
154 }
156 __bind->lenORind = SQL_DATA_AT_EXEC;
157 break;
158 }
159 default: {
161 return false;
162 }
163 }
164 valuePtr = this;
165 paramType = SQL_PARAM_INPUT_OUTPUT_STREAM;
166 }
167 else {
168 __bind->lenORind = SQL_NULL_DATA;
169 paramType = SQL_PARAM_OUTPUT_STREAM;
170 }
171 }
172
173 SQLRETURN rc = SQLBindParameter(
174 query()->stmtHandle(), __bind->number,
175 paramType, __bind->valueType,
176 __bind->type, __bind->size, __bind->scale,
177 valuePtr, __bind->valueMax, &(__bind->lenORind)
178 );
179 if (rc != SQL_SUCCESS) {
180 __DCL_TRACE4_N(L"[%d][%d][%d][%d]\n",
181 rc, __bind->number, __bind->type, __bind->valueType);
182 __SET_ERROR_HANDLE(rc, SQL_HANDLE_STMT, query()->stmtHandle());
183 return false;
184 }
185
186 return true;
187}
188
190{
191 __DCL_ASSERT(__val != NULL);
192 switch (__valType) {
193 case SQL::typeText:
194 case SQL::typeBinary: {
195 __DCL_TRACE4_N(L"SQLPutData bind [%2d %5d] val [%p, %zd]\n",
196 __bind->number, __bind->size, __val, __valSize);
197 SQLRETURN rc = SQLPutData(query()->stmtHandle(), __val, (SQLLEN)__valSize);
198 if (rc != SQL_SUCCESS) {
199 __SET_ERROR_HANDLE(rc, SQL_HANDLE_STMT, query()->stmtHandle());
200 return false;
201 }
202 break;
203 }
205 try {
206 InputStream* input = (InputStream*)__val;
207 char buf[4096];
208 size_t __UNUSED__ total = 0;
209 for ( ; ; ) {
210 SQLLEN read = sizeof(buf);
211 if ((read = input->read(buf, read))) {
212 SQLRETURN rc = SQLPutData(query()->stmtHandle(), buf, read);
213 if (rc != SQL_SUCCESS) {
214 __SET_ERROR_HANDLE(rc, SQL_HANDLE_STMT, query()->stmtHandle());
215 return false;
216 }
217 total += read;
218 }
219 else {
220 __DCL_TRACE3_N(L"SQLPutData bind [%2d %5d] total [%zd]\n",
221 __bind->number, __bind->size, total);
222 break;
223 }
224 }
225 }
226 catch (IOException* e) {
227 __SET_ERROR_MSG(UTF8Encoder::encode(e->toStringAll()));
228 e->destroy();
229 return false;
230 }
231 break;
232 }
233 default: {
234 __DCL_ASSERT(false);
235 }
236 }
237
238 return true;
239}
240
242{
243 // output 데이터가 있을 수 있을 수 있으므로, setNull을 하면 안된다.
244 // setData를 통해 설정된 값만 NULL 로 한다.
245 __val = NULL;
246 return true;
247}
248
249const wchar_t* ODBCParam::serverDataTypeName() const
250{
252}
253
254bool ODBCParam::__getDataSize(size_t* _size, bool _maxsize)
255{
256 return ODBCData::__getDataSize(_size, _maxsize);
257}
258
260 void* _buf,
261 size_t* _size,
262 SQL::DataType _bufType
263)
264{
265 return ODBCData::__getData(_buf, _size, _bufType);
266}
267
268// output parameter support
270 SQL::DataType _sqlType
271)
272{
273 // __setData에서 설정한 값은 수정하지 않는다.
274 // 만약 __setOutputType 호출 후, __setData가 호출되면
275 // __bind->valueType은 변경될 것이다.
276 switch (_sqlType) {
277 case SQL::typeInteger: {
278 if (__bind->valueType == SQL_C_DEFAULT) {
279 __bind->valueType = SQL_C_SLONG;
280 __bind->lenORind = sizeof(int32_t);
281 }
282 break;
283 }
284 case SQL::typeUInteger: {
285 if (__bind->valueType == SQL_C_DEFAULT) {
286 __bind->valueType = SQL_C_ULONG;
287 __bind->lenORind = sizeof(uint32_t);
288 }
289 break;
290 }
291 case SQL::typeFloat: {
292 if (__bind->valueType == SQL_C_DEFAULT) {
293 __bind->valueType = SQL_C_DOUBLE;
294 __bind->lenORind = sizeof(double);
295 }
296 break;
297 }
298 case SQL::typeNumeric: {
299 if (__bind->valueType == SQL_C_DEFAULT) {
300 __bind->valueType = SQL_C_CHAR;
301 __bind->lenORind = __bind->valueMax;
302 }
303 break;
304 }
305 case SQL::typeDate: {
306 if (__bind->valueType == SQL_C_DEFAULT) {
307 __bind->valueType = SQL_C_TYPE_DATE;
308 __bind->lenORind = sizeof(DATE_STRUCT);
309 }
310 break;
311 }
312 case SQL::typeTime:
313 case SQL::typeTimeTz: {
314 if (__bind->valueType == SQL_C_DEFAULT) {
315 __bind->valueType = SQL_C_TYPE_TIME;
316 __bind->lenORind = sizeof(TIME_STRUCT);
317 }
318 break;
319 }
322 if (__bind->valueType == SQL_C_DEFAULT) {
323 __bind->valueType = SQL_C_TYPE_TIMESTAMP;
324 __bind->lenORind = sizeof(TIMESTAMP_STRUCT);
325 }
326 break;
327 }
328 case SQL::typeIntervalYm: {
329 if (__bind->valueType == SQL_C_DEFAULT) {
330 __bind->valueType = SQL_C_INTERVAL_YEAR_TO_MONTH;
331 __bind->lenORind = sizeof(SQL_INTERVAL_STRUCT);
332 }
333 break;
334 }
336 case SQL::typeIntervalDs: {
337 if (__bind->valueType == SQL_C_DEFAULT) {
338 __bind->valueType = SQL_C_INTERVAL_DAY_TO_SECOND;
339 __bind->lenORind = sizeof(SQL_INTERVAL_STRUCT);
340 }
341 break;
342 }
343 case SQL::typeText:
345 case SQL::typeClob: {
346 if (__bind->valueType == SQL_C_DEFAULT) {
347 __bind->valueType = SQL_C_CHAR;
348 __bind->lenORind = __bind->valueMax;
349 }
350 break;
351 }
352 case SQL::typeBinary:
354 case SQL::typeBlob: {
355 if (__bind->valueType == SQL_C_DEFAULT) {
356 __bind->valueType = SQL_C_BINARY;
357 __bind->lenORind = __bind->valueMax;
358 }
359 break;
360 }
361 default: {
362 __DCL_ASSERT(false);
363 }
364 }
365
366 Param::__dataType = __outputType = _sqlType;
367 return true;
368}
369
371{
372 Param::__dataType = SQL::typeUnknown;
373 // 파라미터가 NULL인 경우에도 valueType은 SQL_UNKNOWN이 될 수 없다.
374 // See. ODBCQuery::initParams
375 __bind->valueType = SQL_C_DEFAULT;
376 __bind->lenORind = SQL_NULL_DATA;
377 __val = NULL;
378}
379
381 _CONST void* _val,
382 size_t _size,
383 SQL::DataType _valType,
384 SQL::DataType _sqlType
385)
386{
387 __DCL_ASSERT(__bind && __bind->valuePtr
388 && ((size_t)__bind->valueMax >= sizeof(PARAM_BUFFER_MINIMAL))
389 );
390
391 switch(_valType) {
392 case SQL::typeInteger: {
393 if (!setInteger(_val, _size))
394 return false;
395 break;
396 }
397 case SQL::typeUInteger : {
398 if (!setUInteger(_val, _size))
399 return false;
400 break;
401 }
402 case SQL::typeFloat: {
403 switch (_size) {
404 case sizeof(float) : {
405 *(double*)__bind->valuePtr = (double) * (float*)_val;
406 break;
407 }
408 case sizeof(double) : {
409 *(double*)__bind->valuePtr = *(double*)_val;
410 break;
411 }
412 default: {
414 return false;
415 }
416 }
417 __bind->valueType = SQL_C_DOUBLE;
418 __bind->lenORind = sizeof(double);
419 break;
420 }
421 case SQL::typeDate: {
422 if (_size == sizeof(SQL::Date)) {
423 const SQL::Date* p = (const SQL::Date*)_val;
424 DATE_STRUCT* date = (DATE_STRUCT*)__bind->valuePtr;
425 date->year = p->year;
426 date->month = p->month;
427 date->day = p->day;
428 __bind->valueType = SQL_C_TYPE_DATE;
429 __bind->lenORind = sizeof(DATE_STRUCT);
430 }
431 else {
433 return false;
434 }
435 break;
436 }
437 case SQL::typeTime: {
438 if (_size == sizeof(SQL::Time)) {
439 const SQL::Time* p = (const SQL::Time*)_val;
440 if (p->frac && __bind->type == SQL_SS_TIME2) {
441 SQL_SS_TIME2_STRUCT* time =
442 (SQL_SS_TIME2_STRUCT*)__bind->valuePtr;
443 time->hour = p->hour;
444 time->minute = p->min;
445 time->second = p->sec;
446 time->fraction = p->frac;
447 __bind->valueType = SQL_C_SS_TIME2;
448 __bind->lenORind = sizeof(SQL_SS_TIME2_STRUCT);
449 }
450 else {
451 TIME_STRUCT* time = (TIME_STRUCT*)__bind->valuePtr;
452 time->hour = p->hour;
453 time->minute = p->min;
454 time->second = p->sec;
455 __bind->valueType = SQL_C_TYPE_TIME;
456 __bind->lenORind = sizeof(TIME_STRUCT);
457 }
458 }
459 else {
461 return false;
462 }
463 break;
464 }
465 case SQL::typeTimeStamp: {
466 if (_size == sizeof(SQL::TimeStamp)) {
467 const SQL::TimeStamp* p = (const SQL::TimeStamp*)_val;
468 if (p->tzoff != INT16_MIN && __bind->type == SQL_SS_TIMESTAMPOFFSET) {
469 SQL_SS_TIMESTAMPOFFSET_STRUCT* ts =
470 (SQL_SS_TIMESTAMPOFFSET_STRUCT*)__bind->valuePtr;
471 ts->year = p->year;
472 ts->month = p->month;
473 ts->day = p->day;
474 ts->hour = p->hour;
475 ts->minute = p->min;
476 ts->second = p->sec;
477 ts->fraction = p->frac;
478 ts->timezone_hour = p->tzoff / 60;
479 ts->timezone_minute = p->tzoff % 60;
480 __bind->valueType = SQL_C_SS_TIMESTAMPOFFSET;
481 __bind->lenORind = sizeof(SQL_SS_TIMESTAMPOFFSET_STRUCT);
482 }
483 else {
484 TIMESTAMP_STRUCT* ts =
485 (TIMESTAMP_STRUCT*)__bind->valuePtr;
486 ts->year = p->year;
487 ts->month = p->month;
488 ts->day = p->day;
489 ts->hour = p->hour;
490 ts->minute = p->min;
491 ts->second = p->sec;
492 ts->fraction = p->frac;
493 __bind->valueType = SQL_C_TYPE_TIMESTAMP;
494 __bind->lenORind = sizeof(TIMESTAMP_STRUCT);
495 }
496 }
497 else {
499 return false;
500 }
501 break;
502 }
503 case SQL::typeInterval: {
504 if (_size == sizeof(SQL::Interval)) {
505#define __ABS(n) (n < 0) ? -n : n
506 const SQL::Interval* p = (const SQL::Interval*)_val;
507 SQL_INTERVAL_STRUCT* iv =
508 (SQL_INTERVAL_STRUCT*)__bind->valuePtr;
509 if (_sqlType == SQL::typeIntervalYm) {
510 iv->interval_type = SQL_IS_YEAR_TO_MONTH;
511 iv->interval_sign = p->years < 0 || p->months < 0 ? 1 : 0;
512 SQL_YEAR_MONTH_STRUCT& ym = iv->intval.year_month;
513 ym.year = __ABS(p->years);
514 ym.month = __ABS(p->months);
515 __bind->valueType = SQL_C_INTERVAL_YEAR_TO_MONTH;
516 __bind->lenORind = sizeof(SQL_INTERVAL_STRUCT);
517 }
518 else {
519 iv->interval_type = SQL_IS_DAY_TO_SECOND;
520 iv->interval_sign = p->days
521 || p->hours < 0 || p->mins || p->secs || p->fracs < 0 ? 1 : 0;
522 SQL_DAY_SECOND_STRUCT& ds = iv->intval.day_second;
523 ds.day = __ABS(p->days);
524 ds.hour = __ABS(p->hours);
525 ds.minute = __ABS(p->mins);
526 ds.second = __ABS(p->secs);
527 ds.fraction = __ABS(p->fracs);
528 __bind->valueType = SQL_C_INTERVAL_DAY_TO_SECOND;
529 __bind->lenORind = sizeof(SQL_INTERVAL_STRUCT);
530 }
531#undef __ABS
532 }
533 else {
535 return false;
536 }
537 break;
538 }
539 case SQL::typeText:
540 case SQL::typeBinary:
542 if (__bind->size && _size != (size_t)-1) {
543 size_t size;
544 switch (__bind->type) {
545 case SQL_WCHAR:
546 case SQL_WVARCHAR:
547 case SQL_WLONGVARCHAR:
548 size = __bind->size * 3;
549 break;
550 default:
551 size = __bind->size;
552 }
553 if (size < _size) {
555 return false;
556 }
557 }
558 switch (_sqlType) {
559 case SQL::typeText:
561 case SQL::typeClob: {
562 __bind->valueType = SQL_C_CHAR;
563 break;
564 }
565 case SQL::typeBinary:
567 case SQL::typeBlob: {
568 __bind->valueType = SQL_C_BINARY;
569 break;
570 }
571 default: {
572 __DCL_ASSERT(false);
574 return false;
575 }
576 }
577 // case SQL::typeInputStream 으로 다음 문장은 의미가 없다.
578 // onBeforeExecute SQLBindParameter 직전에서 처리한다.
579 // __bind->lenORind = (SQLLEN)_size;
580 break;
581 }
582 default: {
584 return false;
585 }
586 }
587
588 __val = _val;
589 __valSize = _size;
590 __valType = _valType;
591 SQL::Param::__dataType = _sqlType;
592 return true;
593}
594
595// implementation
596bool ODBCParam::setInteger(const void* _val, size_t _size)
597{
598 switch (__bind->valueType) {
599 // __outputType에 먼저 맞춘다.
600 case SQL_C_SBIGINT: {
601 switch (_size) {
602 case sizeof(int8_t) : {
603 *(int64_t*)__bind->valuePtr = (int64_t) * (int8_t*)_val;
604 break;
605 }
606 case sizeof(int16_t) : {
607 *(int64_t*)__bind->valuePtr = (int64_t) * (int16_t*)_val;
608 break;
609 }
610 case sizeof(int32_t) : {
611 *(int64_t*)__bind->valuePtr = (int64_t) * (int32_t*)_val;
612 break;
613 }
614 case sizeof(int64_t) : {
615 *(int64_t*)__bind->valuePtr = (int64_t) * (int64_t*)_val;
616 break;
617 }
618 default: {
620 return false;
621 }
622 }
623 __bind->lenORind = sizeof(int64_t);
624 break;
625 }
626 case SQL_C_UBIGINT: {
627 switch (_size) {
628 case sizeof(int8_t) : {
629 *(uint64_t*)__bind->valuePtr = (uint64_t) * (int8_t*)_val;
630 break;
631 }
632 case sizeof(int16_t) : {
633 *(uint64_t*)__bind->valuePtr = (uint64_t) * (int16_t*)_val;
634 break;
635 }
636 case sizeof(int32_t) : {
637 *(uint64_t*)__bind->valuePtr = (uint64_t) * (int32_t*)_val;
638 break;
639 }
640 case sizeof(int64_t) : {
641 *(uint64_t*)__bind->valuePtr = (uint64_t) * (int64_t*)_val;
642 break;
643 }
644 default: {
646 return false;
647 }
648 }
649 __bind->lenORind = sizeof(uint64_t);
650 break;
651 }
652 case SQL_C_DEFAULT: // OR ...
653 default: {
654 switch (_size) {
655 case sizeof(int8_t) : {
656 *(int32_t*)__bind->valuePtr = (int32_t) * (int8_t*)_val;
657 __bind->valueType = SQL_C_SLONG;
658 __bind->lenORind = sizeof(int32_t);
659 break;
660 }
661 case sizeof(int16_t) : {
662 *(int32_t*)__bind->valuePtr = (int32_t) * (int16_t*)_val;
663 __bind->valueType = SQL_C_SLONG;
664 __bind->lenORind = sizeof(int32_t);
665 break;
666 }
667 case sizeof(int32_t) : {
668 *(int32_t*)__bind->valuePtr = (int32_t) * (int32_t*)_val;
669 __bind->valueType = SQL_C_SLONG;
670 __bind->lenORind = sizeof(int32_t);
671 break;
672 }
673 case sizeof(int64_t) : {
674 *(int64_t*)__bind->valuePtr = (int64_t) * (int64_t*)_val;
675 __bind->valueType = SQL_C_SBIGINT;
676 __bind->lenORind = sizeof(int64_t);
677 break;
678 }
679 default: {
681 return false;
682 }
683 }
684 }
685 }
686
687 return true;
688}
689bool ODBCParam::setUInteger(const void* _val, size_t _size)
690{
691 switch (__bind->valueType) {
692 // __outputType에 먼저 맞춘다.
693 case SQL_C_SBIGINT: {
694 switch (_size) {
695 case sizeof(int8_t) : {
696 *(int64_t*)__bind->valuePtr = (int64_t) * (int8_t*)_val;
697 break;
698 }
699 case sizeof(int16_t) : {
700 *(int64_t*)__bind->valuePtr = (int64_t) * (int16_t*)_val;
701 break;
702 }
703 case sizeof(int32_t) : {
704 *(int64_t*)__bind->valuePtr = (int64_t) * (int32_t*)_val;
705 break;
706 }
707 case sizeof(int64_t) : {
708 *(int64_t*)__bind->valuePtr = (int64_t) * (int64_t*)_val;
709 break;
710 }
711 default: {
713 return false;
714 }
715 }
716 __bind->lenORind = sizeof(int64_t);
717 break;
718 }
719 case SQL_C_UBIGINT: {
720 switch (_size) {
721 case sizeof(int8_t) : {
722 *(uint64_t*)__bind->valuePtr = (uint64_t) * (int8_t*)_val;
723 break;
724 }
725 case sizeof(int16_t) : {
726 *(uint64_t*)__bind->valuePtr = (uint64_t) * (int16_t*)_val;
727 break;
728 }
729 case sizeof(int32_t) : {
730 *(uint64_t*)__bind->valuePtr = (uint64_t) * (int32_t*)_val;
731 break;
732 }
733 case sizeof(int64_t) : {
734 *(uint64_t*)__bind->valuePtr = (uint64_t) * (int64_t*)_val;
735 break;
736 }
737 default: {
739 return false;
740 }
741 }
742 __bind->lenORind = sizeof(uint64_t);
743 break;
744 }
745 case SQL_C_DEFAULT: // OR ...
746 default: {
747 switch (_size) {
748 case sizeof(uint8_t) : {
749 *(uint32_t*)__bind->valuePtr = (uint32_t) * (uint8_t*)_val;
750 __bind->valueType = SQL_C_ULONG;
751 __bind->lenORind = sizeof(uint32_t);
752 break;
753 }
754 case sizeof(uint16_t) : {
755 *(uint32_t*)__bind->valuePtr = (uint32_t) * (uint16_t*)_val;
756 __bind->valueType = SQL_C_ULONG;
757 __bind->lenORind = sizeof(uint32_t);
758 break;
759 }
760 case sizeof(uint32_t) : {
761 *(uint32_t*)__bind->valuePtr = (uint32_t) * (uint32_t*)_val;
762 __bind->valueType = SQL_C_ULONG;
763 __bind->lenORind = sizeof(uint32_t);
764 break;
765 }
766 case sizeof(uint64_t) : {
767 *(uint64_t*)__bind->valuePtr = (uint64_t) * (uint64_t*)_val;
768 __bind->valueType = SQL_C_UBIGINT;
769 __bind->lenORind = sizeof(uint64_t);
770 break;
771 }
772 default: {
774 return false;
775 }
776 }
777 }
778 }
779 return true;
780}
781
782__DCL_END_NAMESPACE
#define __THIS_FILE__
Definition _trace.h:14
#define NULL
Definition Config.h:312
#define __UNUSED__
Definition Config.h:341
wchar_t char_t
Definition Config.h:247
#define _CONST
Definition Config.h:325
#define INT16_MIN
Definition Config.h:284
#define __DCL_TRACE3_N(fmt, arg1, arg2, arg3)
#define __DCL_TRACE4_N(fmt, arg1, arg2, arg3, arg4)
#define __SET_ERROR_MSG(_message)
#define __SET_ERROR_HANDLE(_SQLCODE)
#define __ABS(n)
Definition MyParam.cpp:145
__DCL_BEGIN_NAMESPACE union __PARAM_BUFFER_MINIMAL PARAM_BUFFER_MINIMAL
struct __BIND BIND
#define __DCL_ASSERT(expr)
Definition Object.h:394
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
Definition Object.h:245
#define __T(str)
Definition Object.h:60
#define __SET_ERROR(_errorCode)
Definition SQLCore.cpp:149
virtual void destroy()
Definition Exception.cpp:74
String toStringAll() const
Definition Exception.cpp:45
bool __getData(void *_buf, size_t *_size, SQL::DataType _bufType)
Definition ODBCData.cpp:561
SQL::DataType init(BIND *_bind)
Definition ODBCData.cpp:64
const wchar_t * serverDataTypeName() const
Definition ODBCData.cpp:449
bool __getDataSize(size_t *_size, bool _maxsize)
Definition ODBCData.cpp:454
BIND * __bind
Definition ODBCData.h:11
virtual bool __getData(void *_buf, size_t *_size, SQL::DataType _bufType)
virtual bool __setData(_CONST void *_val, size_t _size, SQL::DataType _valType, SQL::DataType _sqlType)
virtual bool __getDataSize(size_t *_size, bool _maxsize)
bool setInteger(const void *_val, size_t _size)
virtual ODBCQuery * query() const
Definition ODBCParam.cpp:71
bool setUInteger(const void *_val, size_t _size)
bool onNeedData()
virtual void setNull()
virtual ~ODBCParam()
Definition ODBCParam.cpp:66
bool init(SQL::Query *_query, BIND *_bind)
Definition ODBCParam.cpp:76
virtual const wchar_t * serverDataTypeName() const
virtual bool __setOutputType(SQL::DataType _sqlType)
bool onBeforeExecute()
Definition ODBCParam.cpp:89
bool onAfterExecute()
DataType __dataType
Definition SQLCore.h:188
DataType
Definition SQLCore.h:59
@ typeBinary
Definition SQLCore.h:74
@ typeClob
Definition SQLCore.h:77
@ typeNumeric
Definition SQLCore.h:64
@ typeTime
Definition SQLCore.h:66
@ typeLongBinary
Definition SQLCore.h:76
@ typeUInteger
Definition SQLCore.h:62
@ typeUnknown
Definition SQLCore.h:60
@ typeTimeStamp
Definition SQLCore.h:68
@ typeBlob
Definition SQLCore.h:78
@ typeInputStream
Definition SQLCore.h:81
@ typeTimeStampTz
Definition SQLCore.h:69
@ typeInterval
Definition SQLCore.h:70
@ typeIntervalDs
Definition SQLCore.h:72
@ typeDate
Definition SQLCore.h:65
@ typeText
Definition SQLCore.h:73
@ typeTimeTz
Definition SQLCore.h:67
@ typeFloat
Definition SQLCore.h:63
@ typeInteger
Definition SQLCore.h:61
@ typeIntervalYm
Definition SQLCore.h:71
@ typeLongText
Definition SQLCore.h:75
@ eInvalidData
Definition SQLCore.h:54
@ eNotSupportDataType
Definition SQLCore.h:48
@ eInvalidDataSize
Definition SQLCore.h:55
@ eBytesTruncated
Definition SQLCore.h:53
int16_t year
Definition SQLCore.h:96
uint8_t month
Definition SQLCore.h:97
uint8_t day
Definition SQLCore.h:98
int32_t years
Definition SQLCore.h:126
int32_t days
Definition SQLCore.h:128
int8_t hours
Definition SQLCore.h:129
int8_t mins
Definition SQLCore.h:130
int32_t fracs
Definition SQLCore.h:132
int8_t months
Definition SQLCore.h:127
int8_t secs
Definition SQLCore.h:131
uint8_t hour
Definition SQLCore.h:103
uint8_t sec
Definition SQLCore.h:105
uint32_t frac
Definition SQLCore.h:106
uint8_t min
Definition SQLCore.h:104
uint32_t frac
Definition SQLCore.h:118
int16_t tzoff
Definition SQLCore.h:119
uint8_t min
Definition SQLCore.h:116
uint8_t sec
Definition SQLCore.h:117
uint8_t hour
Definition SQLCore.h:115
uint8_t day
Definition SQLCore.h:114
int16_t year
Definition SQLCore.h:112
uint8_t month
Definition SQLCore.h:113