DCL 3.7.4
Loading...
Searching...
No Matches
IFXParam Class Reference

#include <IFXParam.h>

Inheritance diagram for IFXParam:
SQL::Param SQL::Field Object

Public Member Functions

bool init (SQL::Query *_query, ifx_sqlvar_t *_sqlvar)
bool onAfterExecute ()
 IFXParam ()
virtual ~IFXParam ()
virtual const wchar_t * serverDataTypeName () const
virtual void setNull ()
virtual bool __setData (_CONST void *_val, size_t _size, SQL::DataType _valType, SQL::DataType _sqlType)
bool setInteger (const void *_val, size_t _size)
bool setUInteger (const void *_val, size_t _size)
bool setBytes (const void *_val, size_t _size, SQL::DataType _sqlType)
bool setInputStream (const void *_val, size_t _size, SQL::DataType _sqlType)
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

IFXQueryquery () const
IFXConnectionconn () const
Protected Member Functions inherited from SQL::Param
 Param (Query *_queryHandle)
virtual ~Param ()
virtual bool __setOutputType (DataType _sqlType)
virtual bool __getDataSize (size_t *_size, bool _maxsize)
virtual bool __getData (void *_buf, size_t *_size, DataType _bufType)
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 6 of file IFXParam.h.

Constructor & Destructor Documentation

◆ IFXParam()

IFXParam::IFXParam ( )

◆ ~IFXParam()

IFXParam::~IFXParam ( )
virtual

Definition at line 62 of file IFXParam.cpp.

63{
64}

Member Function Documentation

◆ __setData()

bool IFXParam::__setData ( _CONST void * _val,
size_t _size,
SQL::DataType _valType,
SQL::DataType _sqlType )
virtual

Implements SQL::Param.

Definition at line 115 of file IFXParam.cpp.

121{
122 bool r = true;
123 switch(_valType) {
124 case SQL::typeInteger : {
125 r = setInteger(_val, _size);
126 break;
127 }
128 case SQL::typeUInteger: {
129 r = setUInteger(_val, _size);
130 break;
131 }
132 case SQL::typeFloat: {
133 if (_size == sizeof(float)) {
134 __data.f32 = *(float*)_val;
135 __sqlvar->sqldata = (char*)&__data;
136 __sqlvar->sqltype = CFLOATTYPE;
137 __sqlvar->sqllen = sizeof(float);
138 }
139 else if (_size == sizeof(double)) {
140 __data.f64 = *(double*)_val;
141 __sqlvar->sqldata = (char*)&__data;
142 __sqlvar->sqltype = CDOUBLETYPE;
143 __sqlvar->sqllen = sizeof(double);
144 }
145 else {
147 return false;
148 }
149 break;
150 }
151 case SQL::typeDate: {
152 if (_size == sizeof(SQL::Date)) {
153 const SQL::Date* p = (const SQL::Date*)_val;
154 short mdy[3];
155 mdy[0] = p->month;
156 mdy[1] = p->day;
157 mdy[2] = p->year;
158
159 int r = rmdyjul(mdy, &__data.date);
160 if (r) {
162 return false;
163 }
164 __sqlvar->sqldata = (char*)&__data;
165 __sqlvar->sqltype = CDATETYPE;
166 __sqlvar->sqllen = sizeof(long);
167 }
168 else {
170 return false;
171 }
172 break;
173 }
174 case SQL::typeTime: {
175 if (_size == sizeof(SQL::Time)) {
176 const SQL::Time* p = (const SQL::Time*)_val;
177 int r = __encode_dtime(p, &__data.dtime);
178 if (r) {
180 return false;
181 }
182
183 __sqlvar->sqldata = (char*)&__data;
184 __sqlvar->sqltype = CDTIMETYPE;
185 __sqlvar->sqllen = sizeof(dtime_t);
186 }
187 else {
189 return false;
190 }
191 break;
192 }
193 case SQL::typeTimeStamp: {
194 if (_size == sizeof(SQL::TimeStamp)) {
195 const SQL::TimeStamp* p = (const SQL::TimeStamp*)_val;
196 int r = __encode_dtime(p, &__data.dtime);
197 if (r) {
199 return false;
200 }
201
202 __sqlvar->sqldata = (char*)&__data;
203 __sqlvar->sqltype = CDTIMETYPE;
204 __sqlvar->sqllen = sizeof(dtime_t);
205 }
206 else {
208 return false;
209 }
210 break;
211 }
212 case SQL::typeInterval: {
213 if (_size == sizeof(SQL::Interval)) {
214 int r = __encode_intrvl(
215 (const SQL::Interval*)_val,
216 _sqlType,
217 &__data.ival
218 );
219 if (r) {
221 return false;
222 }
223
224 __sqlvar->sqldata = (char*)&__data;
225 __sqlvar->sqltype = CINVTYPE;
226 __sqlvar->sqllen = sizeof(intrvl_t);
227 }
228 else {
230 return false;
231 }
232 break;
233 }
234 case SQL::typeText : {
235 if (_sqlType == SQL::typeNumeric) {
236 if (_size > 0) {
237 int r = deccvasc((char*)_val, _size, &__data.dec);
238 if (r) {
240 return false;
241 }
242 __sqlvar->sqldata = (char*)&__data;
243 __sqlvar->sqltype = CDECIMALTYPE;
244 __sqlvar->sqllen = sizeof(dec_t);
245 }
246 else {
248 return false;
249 }
250 break;
251 }
252 }
253 case SQL::typeBinary: {
254 r = setBytes(_val, _size, _sqlType);
255 break;
256 }
258 r = setInputStream(_val, _size, _sqlType);
259 break;
260 }
261 default: {
263 return false;
264 }
265 }
266
267 if (r) {
268 __indicator = 0;
269 Param::__dataType = _sqlType;
270 }
271
272 return true;
273}
#define __SET_ERROR_HANDLE(_SQLCODE)
int __encode_intrvl(const SQL::Interval *_s, SQL::DataType _sqlType, intrvl_t *_r)
Definition IFXTypes.cpp:400
int __encode_dtime(const SQL::TimeStamp *_s, dtime_t *_r)
Definition IFXTypes.cpp:337
IOException *size_t r
Definition MediaInfo.cpp:82
#define __SET_ERROR(_errorCode)
Definition SQLCore.cpp:149
bool setInteger(const void *_val, size_t _size)
Definition IFXParam.cpp:275
bool setInputStream(const void *_val, size_t _size, SQL::DataType _sqlType)
Definition IFXParam.cpp:468
bool setUInteger(const void *_val, size_t _size)
Definition IFXParam.cpp:311
bool setBytes(const void *_val, size_t _size, SQL::DataType _sqlType)
Definition IFXParam.cpp:395
@ typeBinary
Definition SQLCore.h:74
@ typeNumeric
Definition SQLCore.h:64
@ typeTime
Definition SQLCore.h:66
@ typeUInteger
Definition SQLCore.h:62
@ typeTimeStamp
Definition SQLCore.h:68
@ typeInputStream
Definition SQLCore.h:81
@ typeInterval
Definition SQLCore.h:70
@ typeDate
Definition SQLCore.h:65
@ typeText
Definition SQLCore.h:73
@ typeFloat
Definition SQLCore.h:63
@ typeInteger
Definition SQLCore.h:61
@ eNotSupportDataType
Definition SQLCore.h:48
@ eInvalidDataSize
Definition SQLCore.h:55
int16_t year
Definition SQLCore.h:96
uint8_t month
Definition SQLCore.h:97
uint8_t day
Definition SQLCore.h:98

◆ conn()

IFXConnection * IFXParam::conn ( ) const
inlineprotected

Definition at line 62 of file IFXParam.h.

63{
64 return query()->conn();
65}
IFXQuery * query() const
Definition IFXParam.h:57

◆ init()

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

Definition at line 66 of file IFXParam.cpp.

67{
68 __DCL_ASSERT((Param::__queryHandle == NULL) && (__sqlvar == NULL));
69
70 Param::__queryHandle = _queryHandle;
71
72 __sqltype = _sqlvar->sqltype;
73 __sqllen = _sqlvar->sqllen;
74 __indicator = -1; // set null
75 __sqlvar = _sqlvar;
76 __sqlvar->sqldata = NULL;
77 __sqlvar->sqlind = &__indicator;
78
79 return true;
80}
#define NULL
Definition Config.h:312
#define __DCL_ASSERT(expr)
Definition Object.h:394

◆ onAfterExecute()

bool IFXParam::onAfterExecute ( )

Definition at line 82 of file IFXParam.cpp.

83{
84 bool r = true;
85 if (__sqlvar->sqltype == CLOCATORTYPE && __sqlvar->sqldata) {
86 loc_t* loc = (loc_t*)(__sqlvar->sqldata);
87 if (loc->loc_status != 0) {
88 __SET_ERROR_HANDLE(loc->loc_status);
89 r = false;;
90 }
91 }
92
93 Param::__dataType = SQL::typeUnknown;
94 __indicator = -1; // set null
95 __sqlvar->sqldata = NULL;
96
97 return r;
98}
loc_t loc
Definition IFXParam.h:23
@ typeUnknown
Definition SQLCore.h:60

◆ query()

IFXQuery * IFXParam::query ( ) const
inlineprotected

Definition at line 57 of file IFXParam.h.

58{
59 return (IFXQuery*)Param::__queryHandle;
60}

◆ serverDataTypeName()

const wchar_t * IFXParam::serverDataTypeName ( ) const
virtual

Implements SQL::Field.

Definition at line 103 of file IFXParam.cpp.

104{
105 return __dataTypeName(__sqlvar);
106}
const wchar_t * __dataTypeName(const ifx_sqlvar_t *_sqlvar)
Definition IFXField.cpp:304

◆ setBytes()

bool IFXParam::setBytes ( const void * _val,
size_t _size,
SQL::DataType _sqlType )

Definition at line 395 of file IFXParam.cpp.

397{
398 switch (__sqltype & SQLTYPE) {
399 case SQLTEXT:
400 case SQLBYTES: {
401 if (_size > INT32_MAX) {
403 return false;
404 }
405 switch (_sqlType) {
406 case SQL::typeText:
408 case SQL::typeClob: {
409 __data.loc.loc_type = SQLTEXT;
410 break;
411 }
412 case SQL::typeBinary:
414 case SQL::typeBlob: {
415 __data.loc.loc_type = SQLBYTES;
416 break;
417 }
418 default: {
420 return false;
421 }
422 }
423 __data.loc.loc_loctype = LOCMEMORY;
424 __data.loc.loc_indicator = 0;
425 // __data.loc.loc_type = SQLTEXT or SQLBYTES;
426 __data.loc.loc_mflags = 0;
427 __data.loc.loc_oflags = LOC_WONLY;
428
429 __data.loc.loc_buffer = (char*)_val;
430 __data.loc.loc_bufsize = _size;
431 __data.loc.loc_size = _size;
432
433 __sqlvar->sqltype = CLOCATORTYPE;
434 __sqlvar->sqllen = sizeof(loc_t);
435 __sqlvar->sqldata = (char*)&__data.loc;
436 break;
437 }
438 default: {
439 switch (_sqlType) {
440 case SQL::typeText:
442 case SQL::typeClob: {
443 __sqlvar->sqltype = CFIXCHARTYPE;
444 break;
445 }
446 case SQL::typeBinary:
448 case SQL::typeBlob: {
449 __sqlvar->sqltype = CFIXBINTYPE;
450 break;
451 }
452 default: {
454 return false;
455 }
456 }
457 __sqlvar->sqldata = (char*)_val;
458 __sqlvar->sqllen = _size;
459 }
460 }
461 return true;
462}
#define INT32_MAX
Definition Config.h:290
@ typeClob
Definition SQLCore.h:77
@ typeLongBinary
Definition SQLCore.h:76
@ typeBlob
Definition SQLCore.h:78
@ typeLongText
Definition SQLCore.h:75

◆ setInputStream()

bool IFXParam::setInputStream ( const void * _val,
size_t _size,
SQL::DataType _sqlType )

Definition at line 468 of file IFXParam.cpp.

470{
471 if (_size != (size_t)-1 && _size > INT32_MAX) {
473 return false;
474 }
475
476 switch (_sqlType) {
477 case SQL::typeText:
479 case SQL::typeClob: {
480 __data.loc.loc_type = SQLTEXT;
481 break;
482 }
483 case SQL::typeBinary:
485 case SQL::typeBlob: {
486 __data.loc.loc_type = SQLBYTES;
487 break;
488 }
489 default: {
491 return false;
492 }
493 }
494
495 __data.loc.loc_open = on_loc_open;
496 __data.loc.loc_read = on_loc_read;
497 __data.loc.loc_close = on_loc_close;
498 __data.loc.loc_write = NULL;
499
500 __data.loc.loc_loctype = LOCUSER;
501 __data.loc.loc_indicator = 0;
502 // __data.loc.loc_type = SQLTEXT or SQLBYTES;
503 __data.loc.loc_mflags = 0;
504 __data.loc.loc_oflags = LOC_WONLY;
505
506 __data.loc.loc_user_env = (char*)_val;
507 __data.loc.loc_size = _size;
508
509 __sqlvar->sqldata = (char*)&__data;
510 __sqlvar->sqltype = CLOCATORTYPE;
511 __sqlvar->sqllen = sizeof(loc_t);
512
513 return true;
514}

◆ setInteger()

bool IFXParam::setInteger ( const void * _val,
size_t _size )

Definition at line 275 of file IFXParam.cpp.

276{
277 switch (_size) {
278 case sizeof(int8_t) : {
279 __data.i32 = (int32_t) * (int8_t*)_val;
280 __sqlvar->sqltype = CLONGTYPE;
281 __sqlvar->sqllen = sizeof(int32_t);
282 break;
283 }
284 case sizeof(int16_t) : {
285 __data.i32 = (int32_t) * (int16_t*)_val;
286 __sqlvar->sqltype = CLONGTYPE;
287 __sqlvar->sqllen = sizeof(int32_t);
288 break;
289 }
290 case sizeof(int32_t) : {
291 __data.i32 = *(int32_t*)_val;
292 __sqlvar->sqltype = CLONGTYPE;
293 __sqlvar->sqllen = sizeof(int32_t);
294 break;
295 }
296 case sizeof(int64_t) : {
297 __data.i64 = *(int64_t*)_val;
298 __sqlvar->sqltype = CBIGINTTYPE;
299 __sqlvar->sqllen = sizeof(bigint);
300 break;
301 }
302 default: {
304 return false;
305 }
306 }
307 __sqlvar->sqldata = (char*)&__data;
308 return true;
309}

◆ setNull()

void IFXParam::setNull ( )
virtual

Implements SQL::Param.

Definition at line 108 of file IFXParam.cpp.

109{
110 Param::__dataType = SQL::typeUnknown;
111 __indicator = -1; // set null
112 __sqlvar->sqldata = NULL;
113}

◆ setUInteger()

bool IFXParam::setUInteger ( const void * _val,
size_t _size )

Definition at line 311 of file IFXParam.cpp.

312{
313 switch (__sqltype & SQLTYPE) {
314 case SQLSMINT:
315 case SQLINT:
316 case SQLSERIAL: {
317 switch (_size) {
318 case sizeof(uint8_t) : {
319 __data.i32 = (int32_t) * (uint8_t*)_val;
320 __sqlvar->sqltype = CLONGTYPE;
321 __sqlvar->sqllen = sizeof(int32_t);
322 break;
323 }
324 case sizeof(uint16_t) : {
325 __data.i32 = (int32_t) * (uint16_t*)_val;
326 __sqlvar->sqltype = CLONGTYPE;
327 __sqlvar->sqllen = sizeof(int32_t);
328 break;
329 }
330 case sizeof(uint32_t) : {
331 __data.i32 = (int32_t) * (uint32_t*)_val;
332 __sqlvar->sqltype = CLONGTYPE;
333 __sqlvar->sqllen = sizeof(int32_t);
334 break;
335 }
336 case sizeof(uint64_t) : {
337 __data.i64 = (int64_t) * (uint32_t*)_val;
338 __sqlvar->sqltype = CBIGINTTYPE;
339 __sqlvar->sqllen = sizeof(bigint);
340 break;
341 }
342 default: {
344 return false;
345 }
346 }
347 break;
348 }
349 case SQLINT8:
350 case SQLSERIAL8:
351 case SQLINFXBIGINT:
352 case SQLBIGSERIAL: {
353 switch (_size) {
354 case sizeof(uint8_t) : {
355 __data.i64 = (int64_t) * (uint8_t*)_val;
356 __sqlvar->sqltype = CBIGINTTYPE;
357 __sqlvar->sqllen = sizeof(int32_t);
358 break;
359 }
360 case sizeof(uint16_t) : {
361 __data.i64 = (int64_t) * (uint16_t*)_val;
362 __sqlvar->sqltype = CBIGINTTYPE;
363 __sqlvar->sqllen = sizeof(int32_t);
364 break;
365 }
366 case sizeof(uint32_t) : {
367 __data.i64 = (int64_t) * (uint32_t*)_val;
368 __sqlvar->sqltype = CBIGINTTYPE;
369 __sqlvar->sqllen = sizeof(int32_t);
370 break;
371 }
372 case sizeof(uint64_t) : {
373 __data.i64 = (int64_t) * (uint32_t*)_val;
374 __sqlvar->sqltype = CBIGINTTYPE;
375 __sqlvar->sqllen = sizeof(bigint);
376 break;
377 }
378 default: {
380 return false;
381 }
382 }
383 break;
384 }
385 default: {
387 return false;
388 }
389 }
390
391 __sqlvar->sqldata = (char*)&__data;
392 return true;
393}
@ eInvalidDataType
Definition SQLCore.h:49

Member Data Documentation

◆ date

int4 IFXParam::date

Definition at line 20 of file IFXParam.h.

◆ dec

dec_t IFXParam::dec

Definition at line 19 of file IFXParam.h.

◆ dtime

dtime_t IFXParam::dtime

Definition at line 21 of file IFXParam.h.

◆ f32

float IFXParam::f32

Definition at line 17 of file IFXParam.h.

◆ f64

double IFXParam::f64

Definition at line 18 of file IFXParam.h.

◆ i32

int32_t IFXParam::i32

Definition at line 15 of file IFXParam.h.

◆ i64

int64_t IFXParam::i64

Definition at line 16 of file IFXParam.h.

◆ ival

intrvl_t IFXParam::ival

Definition at line 22 of file IFXParam.h.

◆ loc

loc_t IFXParam::loc

Definition at line 23 of file IFXParam.h.


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