DCL 4.0
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 *_pv, size_t _size, SQL::DataType _dataType, SQL::DataType _assignType)
bool setInteger (const void *_pv, size_t _size)
bool setUInteger (const void *_pv, size_t _size)
bool setBytes (const void *_pv, size_t _size, SQL::DataType _assignType)
bool setInputStream (const void *_pv, size_t _size, SQL::DataType _assignType)
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
Protected Member Functions inherited from SQL::Param
 Param (Query *_queryHandle)
virtual ~Param ()
virtual bool isNull () const
virtual bool __setDataType (DataType _dataType)
virtual bool __getDataSize (size_t *_pn, bool _maxSize)
virtual bool __getData (void *_pv, size_t *_pn, DataType _dataType)
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 55 of file IFXParam.cpp.

56{
57}

Member Function Documentation

◆ __setData()

bool IFXParam::__setData ( _CONST void * _pv,
size_t _size,
SQL::DataType _dataType,
SQL::DataType _assignType )
virtual

Implements SQL::Param.

Definition at line 109 of file IFXParam.cpp.

115{
116 bool r = true;
117 switch(_dataType) {
118 case SQL::typeInteger : {
119 r = setInteger(_pv, _size);
120 break;
121 }
122 case SQL::typeUInteger: {
123 r = setUInteger(_pv, _size);
124 break;
125 }
126 case SQL::typeFloat: {
127 if (_size == sizeof(float)) {
128 __data.f32 = *(float*)_pv;
129 __sqlvar->sqldata = (char*)&__data;
130 __sqlvar->sqltype = CFLOATTYPE;
131 __sqlvar->sqllen = sizeof(float);
132 }
133 else if (_size == sizeof(double)) {
134 __data.f64 = *(double*)_pv;
135 __sqlvar->sqldata = (char*)&__data;
136 __sqlvar->sqltype = CDOUBLETYPE;
137 __sqlvar->sqllen = sizeof(double);
138 }
139 else {
141 return false;
142 }
143 break;
144 }
145 case SQL::typeDate: {
146 if (_size == sizeof(SQL::Date)) {
147 const SQL::Date* p = (const SQL::Date*)_pv;
148 short mdy[3];
149 mdy[0] = p->nMonth;
150 mdy[1] = p->nDay;
151 mdy[2] = p->nYear;
152
153 int r = rmdyjul(mdy, &__data.date);
154 if (r) {
156 return false;
157 }
158 __sqlvar->sqldata = (char*)&__data;
159 __sqlvar->sqltype = CDATETYPE;
160 __sqlvar->sqllen = sizeof(long);
161 }
162 else {
164 return false;
165 }
166 break;
167 }
168 case SQL::typeTime: {
169 if (_size == sizeof(SQL::Time)) {
170 const SQL::Time* p = (const SQL::Time*)_pv;
171 int r = __encode_dtime(p, &__data.dtime);
172 if (r) {
174 return false;
175 }
176
177 __sqlvar->sqldata = (char*)&__data;
178 __sqlvar->sqltype = CDTIMETYPE;
179 __sqlvar->sqllen = sizeof(dtime_t);
180 }
181 else {
183 return false;
184 }
185 break;
186 }
187 case SQL::typeTimeStamp: {
188 if (_size == sizeof(SQL::TimeStamp)) {
189 const SQL::TimeStamp* p = (const SQL::TimeStamp*)_pv;
190 if (p->nTzMin) {
192 return false;
193 }
194
195 int r = __encode_dtime(p, &__data.dtime);
196 if (r) {
198 return false;
199 }
200
201 __sqlvar->sqldata = (char*)&__data;
202 __sqlvar->sqltype = CDTIMETYPE;
203 __sqlvar->sqllen = sizeof(dtime_t);
204 }
205 else {
207 return false;
208 }
209 break;
210 }
213 case SQL::typeIntervalDs: {
214 if (_size == sizeof(SQL::Interval)) {
215 int r = __encode_intrvl(
216 (const SQL::Interval*)_pv,
217 _dataType,
218 &__data.ival
219 );
220 if (r) {
222 return false;
223 }
224
225 __sqlvar->sqldata = (char*)&__data;
226 __sqlvar->sqltype = CINVTYPE;
227 __sqlvar->sqllen = sizeof(intrvl_t);
228 }
229 else {
231 return false;
232 }
233 break;
234 }
235 case SQL::typeText : {
236 if (_assignType == SQL::typeNumeric) {
237 if (_size > 0) {
238 int r = deccvasc((char*)_pv, _size, &__data.dec);
239 if (r) {
241 return false;
242 }
243 __sqlvar->sqldata = (char*)&__data;
244 __sqlvar->sqltype = CDECIMALTYPE;
245 __sqlvar->sqllen = sizeof(dec_t);
246 }
247 else {
249 return false;
250 }
251 break;
252 }
253 }
254 case SQL::typeBinary: {
255 r = setBytes(_pv, _size, _assignType);
256 break;
257 }
259 r = setInputStream(_pv, _size, _assignType);
260 break;
261 }
262 default: {
264 return false;
265 }
266 }
267
268 if (r) {
269 __indicator = 0;
270 Param::__dataType = _assignType;
271 }
272
273 return true;
274}
#define __SET_ERROR_SQLCODE(SQLCODE)
int __encode_dtime(const SQL::TimeStamp *_s, dtime_t *_r)
Definition IFXTypes.cpp:336
int __encode_intrvl(const SQL::Interval *_s, SQL::DataType _dataType, intrvl_t *_r)
Definition IFXTypes.cpp:399
ByteString r
#define __SET_ERROR(_errorCode)
Definition SQLCore.cpp:150
bool setBytes(const void *_pv, size_t _size, SQL::DataType _assignType)
Definition IFXParam.cpp:396
bool setInteger(const void *_pv, size_t _size)
Definition IFXParam.cpp:276
bool setUInteger(const void *_pv, size_t _size)
Definition IFXParam.cpp:312
bool setInputStream(const void *_pv, size_t _size, SQL::DataType _assignType)
Definition IFXParam.cpp:469
@ typeBinary
Definition SQLCore.h:76
@ typeNumeric
Definition SQLCore.h:67
@ typeTime
Definition SQLCore.h:69
@ typeUInteger
Definition SQLCore.h:65
@ typeTimeStamp
Definition SQLCore.h:70
@ typeInputStream
Definition SQLCore.h:83
@ typeInterval
Definition SQLCore.h:72
@ typeIntervalDs
Definition SQLCore.h:74
@ typeDate
Definition SQLCore.h:68
@ typeText
Definition SQLCore.h:75
@ typeFloat
Definition SQLCore.h:66
@ typeInteger
Definition SQLCore.h:64
@ typeIntervalYm
Definition SQLCore.h:73
@ eInvalidData
Definition SQLCore.h:55
@ eNotSupportDataType
Definition SQLCore.h:48
@ eInvalidDataSize
Definition SQLCore.h:57
uint8_t nMonth
Definition SQLCore.h:97
int16_t nYear
Definition SQLCore.h:96
uint8_t nDay
Definition SQLCore.h:98
int16_t nTzMin
Definition SQLCore.h:118

◆ init()

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

Definition at line 59 of file IFXParam.cpp.

60{
61 __DCL_ASSERT((Param::__queryHandle == NULL) && (__sqlvar == NULL));
62
63 Param::__queryHandle = _queryHandle;
64
65 __sqltype = _sqlvar->sqltype;
66 __sqllen = _sqlvar->sqllen;
67 __indicator = -1; // set null
68 __sqlvar = _sqlvar;
69 __sqlvar->sqldata = NULL;
70 __sqlvar->sqlind = &__indicator;
71
72 return true;
73}
#define NULL
Definition Config.h:340
#define __DCL_ASSERT(expr)
Definition Object.h:371

◆ onAfterExecute()

bool IFXParam::onAfterExecute ( )

Definition at line 75 of file IFXParam.cpp.

76{
77 bool r = true;
78 if (__sqlvar->sqltype == CLOCATORTYPE && __sqlvar->sqldata) {
79 loc_t* loc = (loc_t*)(__sqlvar->sqldata);
80 if (loc->loc_status != 0) {
81 __SET_ERROR_SQLCODE(loc->loc_status);
82 r = false;;
83 }
84 }
85
86 Param::__dataType = SQL::typeUnknown;
87 __indicator = -1; // set null
88 __sqlvar->sqldata = NULL;
89
90 return r;
91}
loc_t loc
Definition IFXParam.h:23
@ typeUnknown
Definition SQLCore.h:63

◆ query()

IFXQuery * IFXParam::query ( ) const
inlineprotected

Definition at line 81 of file IFXParam.h.

82{
83 return (IFXQuery*)Param::__queryHandle;
84}

◆ serverDataTypeName()

const wchar_t * IFXParam::serverDataTypeName ( ) const
virtual

Implements SQL::Field.

Definition at line 96 of file IFXParam.cpp.

97{
98 return __dataTypeName(__sqlvar);
99}
const wchar_t * __dataTypeName(const ifx_sqlvar_t *_sqlvar)
Definition IFXField.cpp:290

◆ setBytes()

bool IFXParam::setBytes ( const void * _pv,
size_t _size,
SQL::DataType _assignType )

Definition at line 396 of file IFXParam.cpp.

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

◆ setErrorStatus() [1/2]

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

Definition at line 71 of file IFXParam.h.

73{
74 ((IFXConnection*)Param::connection())->setErrorStatus(
75 _message,
76 _filename,
77 _line
78 );
79}

◆ setErrorStatus() [2/2]

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

Definition at line 60 of file IFXParam.h.

62{
63 ((IFXConnection*)Param::connection())->setErrorStatus(
64 _error,
65 _SQLCODE,
66 _filename,
67 _line
68 );
69}

◆ setInputStream()

bool IFXParam::setInputStream ( const void * _pv,
size_t _size,
SQL::DataType _assignType )

Definition at line 469 of file IFXParam.cpp.

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

◆ setInteger()

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

Definition at line 276 of file IFXParam.cpp.

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

◆ setNull()

void IFXParam::setNull ( )
virtual

Implements SQL::Param.

Definition at line 102 of file IFXParam.cpp.

103{
104 Param::__dataType = SQL::typeUnknown;
105 __indicator = -1; // set null
106 __sqlvar->sqldata = NULL;
107}

◆ setUInteger()

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

Definition at line 312 of file IFXParam.cpp.

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