ibm_db 2.5.18-x86-mingw32 → 2.5.25-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,845 +1,845 @@
1
- /*
2
- +----------------------------------------------------------------------+
3
- | Licensed Materials - Property of IBM |
4
- | |
5
- | (C) Copyright IBM Corporation 2009, 2010, 2012 |
6
- +----------------------------------------------------------------------+
7
- | Authors: Praveen Devarao |
8
- +----------------------------------------------------------------------+
9
- */
10
-
11
-
12
- /*
13
- This C file contains functions that perform DB operations, which can take long time to complete.
14
- For Eg: - Like SQLConnect, SQLFetch etc.
15
-
16
- This file in general will contain functions that make CLI calls and
17
- depending on whether the call will be transferred to server or not the functions are termed long time comsuming or not.
18
-
19
- The functions which will contact the server and hence can be time consuming will be called by ruby's (1.9 onwards)
20
- rb_thread_blocking_region method, which inturn will release the GVL while these operations are being performed.
21
- With this the executing thread will become unblocking allowing concurrent threads perform operations simultaneously.
22
- */
23
-
24
- #include "ruby_ibm_db_cli.h"
25
-
26
- /*
27
- This function connects to the database using either SQLConnect or SQLDriverConnect CLI API
28
- depending on whether it is a cataloged or an uncataloged connection.
29
- */
30
- int _ruby_ibm_db_SQLConnect_helper(connect_args *data) {
31
- if(data->ctlg_conn == 1) {
32
- #ifndef UNICODE_SUPPORT_VERSION
33
- return SQLConnect( (SQLHDBC)*(data->hdbc), (SQLCHAR *)data->database,
34
- (SQLSMALLINT)data->database_len, (SQLCHAR *)data->uid, (SQLSMALLINT)data->uid_len,
35
- (SQLCHAR *)data->password, (SQLSMALLINT)data->password_len );
36
- #else
37
- return SQLConnectW( (SQLHDBC)*(data->hdbc), data->database,
38
- data->database_len, data->uid, data->uid_len,
39
- data->password, data->password_len );
40
- #endif
41
- } else {
42
- #ifndef UNICODE_SUPPORT_VERSION
43
- return SQLDriverConnect( (SQLHDBC) *(data->hdbc), (SQLHWND)NULL,
44
- (SQLCHAR*)data->database, SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPROMPT );
45
- #else
46
- return SQLDriverConnectW( (SQLHDBC) *(data->hdbc), (SQLHWND)NULL,
47
- data->database, SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPROMPT );
48
- #endif
49
- }
50
- }
51
-
52
- /*
53
- This function issues SQLDisconnect to disconnect from the Dataserver
54
- */
55
- int _ruby_ibm_db_SQLDisconnect_helper(SQLHANDLE *hdbc) {
56
- return SQLDisconnect( (SQLHDBC) *hdbc );
57
- }
58
-
59
- /*
60
- Connection level Unblock function. This function is called when a thread interruput is issued while executing a
61
- connection level SQL call
62
- */
63
- void _ruby_ibm_db_Connection_level_UBF(void *data) {
64
- return;
65
- }
66
-
67
- /*
68
- This function will commit and end the inprogress transaction by issuing a SQLCommit
69
- */
70
- int _ruby_ibm_db_SQLEndTran(end_tran_args *endtran_args) {
71
- return SQLEndTran( endtran_args->handleType, *(endtran_args->hdbc), endtran_args->completionType );
72
- }
73
-
74
- /*
75
- This function call the SQLDescribeParam cli call to get the description of the parameter in the sql specified
76
- */
77
- int _ruby_ibm_db_SQLDescribeParam_helper(describeparam_args *data) {
78
- int rc = 0;
79
- data->stmt_res->is_executing = 1;
80
-
81
- rc = SQLDescribeParam( (SQLHSTMT) data->stmt_res->hstmt, (SQLUSMALLINT)data->param_no, &(data->sql_data_type),
82
- &(data->sql_precision), &(data->sql_scale), &(data->sql_nullable) );
83
-
84
- data->stmt_res->is_executing = 0;
85
-
86
- return rc;
87
- }
88
-
89
- /*
90
- This function call the SQLDescribeCol cli call to get the description of the parameter in the sql specified
91
- */
92
- int _ruby_ibm_db_SQLDescribeCol_helper(describecol_args *data) {
93
- int i = data->col_no - 1;
94
- int rc = 0;
95
-
96
- data->stmt_res->is_executing = 1;
97
-
98
- #ifdef UNICODE_SUPPORT_VERSION
99
- rc = SQLDescribeColW( (SQLHSTMT)data->stmt_res->hstmt, (SQLSMALLINT)(data->col_no),
100
- data->stmt_res->column_info[i].name, data->buff_length, &(data->name_length),
101
- &(data->stmt_res->column_info[i].type), &(data->stmt_res->column_info[i].size),
102
- &(data->stmt_res->column_info[i].scale), &(data->stmt_res->column_info[i].nullable) );
103
- #else
104
- rc = SQLDescribeCol( (SQLHSTMT)data->stmt_res->hstmt, (SQLSMALLINT)(data->col_no),
105
- data->stmt_res->column_info[i].name, data->buff_length, &(data->name_length),
106
- &(data->stmt_res->column_info[i].type), &(data->stmt_res->column_info[i].size),
107
- &(data->stmt_res->column_info[i].scale), &(data->stmt_res->column_info[i].nullable) );
108
- #endif
109
-
110
- data->stmt_res->is_executing = 0;
111
-
112
- return rc;
113
- }
114
-
115
- /*
116
- This function call the SQLBindCol cli call to get the description of the parameter in the sql specified
117
- */
118
- int _ruby_ibm_db_SQLBindCol_helper(bind_col_args *data) {
119
- int rc = 0;
120
-
121
- data->stmt_res->is_executing = 1;
122
-
123
- rc = SQLBindCol( (SQLHSTMT) data->stmt_res->hstmt, (SQLUSMALLINT)(data->col_num),
124
- data->TargetType, data->TargetValuePtr, data->buff_length,
125
- data->out_length );
126
-
127
- data->stmt_res->is_executing = 0;
128
-
129
- return rc;
130
- }
131
-
132
- /*
133
- This function calls SQLColumnPrivileges cli call to get the list of columns and the associated privileges
134
- */
135
- int _ruby_ibm_db_SQLColumnPrivileges_helper(metadata_args *data) {
136
- int rc = 0;
137
-
138
- data->stmt_res->is_executing = 1;
139
-
140
- #ifndef UNICODE_SUPPORT_VERSION
141
- rc = SQLColumnPrivileges( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
142
- data->owner, data->owner_len, data->table_name, data->table_name_len,
143
- data->column_name, data->column_name_len );
144
- #else
145
- rc = SQLColumnPrivilegesW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
146
- data->owner, data->owner_len, data->table_name, data->table_name_len,
147
- data->column_name, data->column_name_len );
148
- #endif
149
-
150
- data->stmt_res->is_executing = 0;
151
-
152
- return rc;
153
-
154
- }
155
-
156
- /*
157
- This function calls SQLColumns cli call to get the list of columns and the associated metadata of the table
158
- */
159
- int _ruby_ibm_db_SQLColumns_helper(metadata_args *data) {
160
- int rc = 0;
161
-
162
- data->stmt_res->is_executing = 1;
163
-
164
- #ifndef UNICODE_SUPPORT_VERSION
165
- rc = SQLColumns( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
166
- data->owner, data->owner_len, data->table_name, data->table_name_len,
167
- data->column_name, data->column_name_len );
168
- #else
169
- rc = SQLColumnsW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
170
- data->owner, data->owner_len, data->table_name, data->table_name_len,
171
- data->column_name, data->column_name_len );
172
- #endif
173
-
174
- data->stmt_res->is_executing = 0;
175
-
176
- return rc;
177
- }
178
-
179
- /*
180
- This function calls SQLPrimaryKeys cli call to get the list of primay key columns and the associated metadata
181
- */
182
- int _ruby_ibm_db_SQLPrimaryKeys_helper(metadata_args *data) {
183
- int rc = 0;
184
-
185
- data->stmt_res->is_executing = 1;
186
-
187
- #ifndef UNICODE_SUPPORT_VERSION
188
- rc = SQLPrimaryKeys( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
189
- data->owner, data->owner_len, data->table_name, data->table_name_len );
190
- #else
191
- rc = SQLPrimaryKeysW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
192
- data->owner, data->owner_len, data->table_name, data->table_name_len );
193
- #endif
194
-
195
- data->stmt_res->is_executing = 0;
196
-
197
- return rc;
198
- }
199
-
200
- /*
201
- This function calls SQLForeignKeys cli call to get the list of foreign key columns and the associated metadata
202
- */
203
- int _ruby_ibm_db_SQLForeignKeys_helper(metadata_args *data) {
204
- int rc = 0;
205
-
206
- data->stmt_res->is_executing = 1;
207
-
208
- #ifndef UNICODE_SUPPORT_VERSION
209
- rc = SQLForeignKeys( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
210
- data->owner, data->owner_len, data->table_name , data->table_name_len, NULL, SQL_NTS,
211
- NULL, SQL_NTS, NULL, SQL_NTS );
212
- #else
213
- rc = SQLForeignKeysW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
214
- data->owner, data->owner_len, data->table_name , data->table_name_len, NULL, SQL_NTS,
215
- NULL, SQL_NTS, NULL, SQL_NTS );
216
- #endif
217
-
218
- data->stmt_res->is_executing = 0;
219
-
220
- return rc;
221
- }
222
-
223
- /*
224
- This function calls SQLProcedureColumns cli call to get the list of parameters
225
- and associated metadata of the stored procedure
226
- */
227
- int _ruby_ibm_db_SQLProcedureColumns_helper(metadata_args *data) {
228
- int rc = 0;
229
-
230
- data->stmt_res->is_executing = 1;
231
-
232
- #ifndef UNICODE_SUPPORT_VERSION
233
- rc = SQLProcedureColumns( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
234
- data->owner_len, data->proc_name, data->proc_name_len, data->column_name, data->column_name_len );
235
- #else
236
- rc = SQLProcedureColumnsW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
237
- data->owner_len, data->proc_name, data->proc_name_len, data->column_name, data->column_name_len );
238
- #endif
239
-
240
- data->stmt_res->is_executing = 0;
241
-
242
- return rc;
243
- }
244
-
245
- /*
246
- This function calls SQLProcedures cli call to get the list of stored procedures
247
- and associated metadata of the stored procedure
248
- */
249
- int _ruby_ibm_db_SQLProcedures_helper(metadata_args *data) {
250
- int rc = 0;
251
-
252
- data->stmt_res->is_executing = 1;
253
-
254
- #ifndef UNICODE_SUPPORT_VERSION
255
- rc = SQLProcedures( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
256
- data->owner_len, data->proc_name, data->proc_name_len );
257
- #else
258
- rc = SQLProceduresW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
259
- data->owner_len, data->proc_name, data->proc_name_len );
260
- #endif
261
-
262
- data->stmt_res->is_executing = 0;
263
-
264
- return rc;
265
- }
266
-
267
- /*
268
- This function calls SQLSpecialColumns cli call to get the metadata related to the special columns
269
- (Unique index or primary key column) and associated metadata
270
- */
271
- int _ruby_ibm_db_SQLSpecialColumns_helper(metadata_args *data) {
272
- int rc = 0;
273
-
274
- data->stmt_res->is_executing = 1;
275
-
276
- #ifndef UNICODE_SUPPORT_VERSION
277
- rc = SQLSpecialColumns( (SQLHSTMT) data->stmt_res->hstmt, SQL_BEST_ROWID, data->qualifier, data->qualifier_len,
278
- data->owner, data->owner_len, data->table_name, data->table_name_len,
279
- (SQLUSMALLINT)data->scope, SQL_NULLABLE );
280
- #else
281
- rc = SQLSpecialColumnsW( (SQLHSTMT) data->stmt_res->hstmt, SQL_BEST_ROWID, data->qualifier, data->qualifier_len,
282
- data->owner, data->owner_len, data->table_name, data->table_name_len,
283
- (SQLUSMALLINT)data->scope, SQL_NULLABLE );
284
- #endif
285
-
286
- data->stmt_res->is_executing = 0;
287
-
288
- return rc;
289
- }
290
-
291
- /*
292
- This function calls SQLStatistics cli call to get the index information for a given table.
293
- */
294
- int _ruby_ibm_db_SQLStatistics_helper(metadata_args *data) {
295
- int rc = 0;
296
-
297
- data->stmt_res->is_executing = 1;
298
-
299
- #ifndef UNICODE_SUPPORT_VERSION
300
- rc = SQLStatistics( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
301
- data->owner_len, data->table_name, data->table_name_len, (SQLUSMALLINT)data->unique, SQL_QUICK );
302
- #else
303
- rc = SQLStatisticsW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
304
- data->owner_len, data->table_name, data->table_name_len, (SQLUSMALLINT)data->unique, SQL_QUICK );
305
- #endif
306
-
307
- data->stmt_res->is_executing = 0;
308
-
309
- return rc;
310
- }
311
-
312
- /*
313
- This function calls SQLTablePrivileges cli call to retrieve list of tables and
314
- the asscociated privileges for each table.
315
- */
316
- int _ruby_ibm_db_SQLTablePrivileges_helper(metadata_args *data) {
317
- int rc = 0;
318
-
319
- data->stmt_res->is_executing = 1;
320
-
321
- #ifndef UNICODE_SUPPORT_VERSION
322
- rc = SQLTablePrivileges( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
323
- data->owner, data->owner_len, data->table_name, data->table_name_len );
324
- #else
325
- rc = SQLTablePrivilegesW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
326
- data->owner, data->owner_len, data->table_name, data->table_name_len );
327
- #endif
328
-
329
- data->stmt_res->is_executing = 0;
330
-
331
- return rc;
332
- }
333
-
334
- /*
335
- This function calls SQLTables cli call to retrieve list of tables in the specified schema and
336
- the asscociated metadata for each table.
337
- */
338
- int _ruby_ibm_db_SQLTables_helper(metadata_args *data) {
339
- int rc = 0;
340
-
341
- data->stmt_res->is_executing = 1;
342
-
343
- #ifndef UNICODE_SUPPORT_VERSION
344
- rc = SQLTables( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
345
- data->owner_len, data->table_name, data->table_name_len, data->table_type, data->table_type_len );
346
- #else
347
- rc = SQLTablesW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
348
- data->owner_len, data->table_name, data->table_name_len, data->table_type, data->table_type_len );
349
- #endif
350
-
351
- data->stmt_res->is_executing = 0;
352
-
353
- return rc;
354
- }
355
-
356
- /*
357
- This function calls SQLExecDirect cli call to execute a statement directly
358
- */
359
- int _ruby_ibm_db_SQLExecDirect_helper(exec_cum_prepare_args *data) {
360
- int rc = 0;
361
-
362
- data->stmt_res->is_executing = 1;
363
-
364
- #ifndef UNICODE_SUPPORT_VERSION
365
- rc = SQLExecDirect( (SQLHSTMT) data->stmt_res->hstmt, data->stmt_string, (SQLINTEGER)data->stmt_string_len );
366
- #else
367
- rc = SQLExecDirectW( (SQLHSTMT) data->stmt_res->hstmt, data->stmt_string, (SQLINTEGER)data->stmt_string_len );
368
- #endif
369
-
370
- data->stmt_res->is_executing = 0;
371
-
372
- return rc;
373
- }
374
-
375
- /*
376
- This function calls SQLCreateDb cli call
377
- */
378
- int _ruby_ibm_db_SQLCreateDB_helper(create_drop_db_args *data) {
379
- int rc = 0;
380
- #ifndef UNICODE_SUPPORT_VERSION
381
- #ifdef _WIN32
382
- HINSTANCE cliLib = NULL;
383
- FARPROC sqlcreatedb;
384
- cliLib = DLOPEN( LIBDB2 );
385
- sqlcreatedb = DLSYM( cliLib, "SQLCreateDb" );
386
- #elif _AIX
387
- void *cliLib = NULL;
388
- typedef int (*sqlcreatedbType)( SQLHDBC, SQLCHAR *, SQLINTEGER, SQLCHAR *, SQLINTEGER, SQLCHAR *, SQLINTEGER );
389
- sqlcreatedbType sqlcreatedb;
390
- /* On AIX CLI library is in archive. Hence we will need to specify flags in DLOPEN to load a member of the archive*/
391
- cliLib = DLOPEN( LIBDB2, RTLD_MEMBER | RTLD_LAZY );
392
- sqlcreatedb = (sqlcreatedbType) DLSYM( cliLib, "SQLCreateDb" );
393
- #else
394
- void *cliLib = NULL;
395
- typedef int (*sqlcreatedbType)( SQLHDBC, SQLCHAR *, SQLINTEGER, SQLCHAR *, SQLINTEGER, SQLCHAR *, SQLINTEGER );
396
- sqlcreatedbType sqlcreatedb;
397
- cliLib = DLOPEN( LIBDB2, RTLD_LAZY );
398
- sqlcreatedb = (sqlcreatedbType) DLSYM( cliLib, "SQLCreateDb" );
399
- #endif
400
- #else
401
- #ifdef _WIN32
402
- HINSTANCE cliLib = NULL;
403
- FARPROC sqlcreatedb;
404
- cliLib = DLOPEN( LIBDB2 );
405
- sqlcreatedb = DLSYM( cliLib, "SQLCreateDbW" );
406
- #elif _AIX
407
- void *cliLib = NULL;
408
- typedef int (*sqlcreatedbType)( SQLHDBC, SQLWCHAR *, SQLINTEGER, SQLWCHAR *, SQLINTEGER, SQLWCHAR *, SQLINTEGER );
409
- sqlcreatedbType sqlcreatedb;
410
- /* On AIX CLI library is in archive. Hence we will need to specify flags in DLOPEN to load a member of the archive*/
411
- cliLib = DLOPEN( LIBDB2, RTLD_MEMBER | RTLD_LAZY );
412
- sqlcreatedb = (sqlcreatedbType) DLSYM( cliLib, "SQLCreateDbW" );
413
- #else
414
- void *cliLib = NULL;
415
- typedef int (*sqlcreatedbType)( SQLHDBC, SQLWCHAR *, SQLINTEGER, SQLWCHAR *, SQLINTEGER, SQLWCHAR *, SQLINTEGER );
416
- sqlcreatedbType sqlcreatedb;
417
- cliLib = DLOPEN( LIBDB2, RTLD_LAZY );
418
- sqlcreatedb = (sqlcreatedbType) DLSYM( cliLib, "SQLCreateDbW" );
419
- #endif
420
- #endif
421
-
422
- rc = (*sqlcreatedb)( (SQLHSTMT) data->conn_res->hdbc, data->dbName, (SQLINTEGER)data->dbName_string_len,
423
- data->codeSet, (SQLINTEGER)data->codeSet_string_len,
424
- data->mode, (SQLINTEGER)data->mode_string_len );
425
- DLCLOSE( cliLib );
426
- return rc;
427
- }
428
-
429
- /*
430
- This function calls SQLDropDb cli call
431
- */
432
- int _ruby_ibm_db_SQLDropDB_helper(create_drop_db_args *data) {
433
- int rc = 0;
434
- #ifndef UNICODE_SUPPORT_VERSION
435
- #ifdef _WIN32
436
- HINSTANCE cliLib = NULL;
437
- FARPROC sqldropdb;
438
- cliLib = DLOPEN( LIBDB2 );
439
- sqldropdb = DLSYM( cliLib, "SQLDropDb" );
440
- #elif _AIX
441
- void *cliLib = NULL;
442
- typedef int (*sqldropdbType)( SQLHDBC, SQLCHAR *, SQLINTEGER);
443
- sqldropdbType sqldropdb;
444
- /* On AIX CLI library is in archive. Hence we will need to specify flags in DLOPEN to load a member of the archive*/
445
- cliLib = DLOPEN( LIBDB2, RTLD_MEMBER | RTLD_LAZY );
446
- sqldropdb = (sqldropdbType) DLSYM( cliLib, "SQLDropDb" );
447
- #else
448
- void *cliLib = NULL;
449
- typedef int (*sqldropdbType)( SQLHDBC, SQLCHAR *, SQLINTEGER);
450
- sqldropdbType sqldropdb;
451
- cliLib = DLOPEN( LIBDB2, RTLD_LAZY );
452
- sqldropdb = (sqldropdbType) DLSYM( cliLib, "SQLDropDb" );
453
- #endif
454
- #else
455
- #ifdef _WIN32
456
- HINSTANCE cliLib = NULL;
457
- FARPROC sqldropdb;
458
- cliLib = DLOPEN( LIBDB2 );
459
- sqldropdb = DLSYM( cliLib, "SQLDropDbW" );
460
- #elif _AIX
461
- void *cliLib = NULL;
462
- typedef int (*sqldropdbType)( SQLHDBC, SQLWCHAR *, SQLINTEGER);
463
- sqldropdbType sqldropdb;
464
- /* On AIX CLI library is in archive. Hence we will need to specify flags in DLOPEN to load a member of the archive*/
465
- cliLib = DLOPEN( LIBDB2, RTLD_MEMBER | RTLD_LAZY );
466
- sqldropdb = (sqldropdbType) DLSYM( cliLib, "SQLDropDbW" );
467
- #else
468
- void *cliLib = NULL;
469
- typedef int (*sqldropdbType)( SQLHDBC, SQLWCHAR *, SQLINTEGER);
470
- sqldropdbType sqldropdb;
471
- cliLib = DLOPEN( LIBDB2, RTLD_LAZY );
472
- sqldropdb = (sqldropdbType) DLSYM( cliLib, "SQLDropDbW" );
473
- #endif
474
- #endif
475
-
476
- rc = (*sqldropdb)( (SQLHSTMT) data->conn_res->hdbc, data->dbName, (SQLINTEGER)data->dbName_string_len );
477
-
478
- DLCLOSE( cliLib );
479
- return rc;
480
- }
481
-
482
- /*
483
- This function calls SQLPrepare cli call to prepare the given statement
484
- */
485
- int _ruby_ibm_db_SQLPrepare_helper(exec_cum_prepare_args *data) {
486
- int rc = 0;
487
-
488
- data->stmt_res->is_executing = 1;
489
-
490
- #ifndef UNICODE_SUPPORT_VERSION
491
- rc = SQLPrepare( (SQLHSTMT) data->stmt_res->hstmt, data->stmt_string, (SQLINTEGER)data->stmt_string_len );
492
- #else
493
- rc = SQLPrepareW( (SQLHSTMT) data->stmt_res->hstmt, data->stmt_string, (SQLINTEGER)data->stmt_string_len );
494
- #endif
495
-
496
- data->stmt_res->is_executing = 0;
497
-
498
- return rc;
499
- }
500
-
501
- /*
502
- This function calls SQLFreeStmt to end processing on the statement referenced by statement handle
503
- */
504
- int _ruby_ibm_db_SQLFreeStmt_helper(free_stmt_args *data) {
505
- int rc = 0;
506
-
507
- data->stmt_res->is_executing = 1;
508
-
509
- SQLFreeStmt((SQLHSTMT)data->stmt_res->hstmt, data->option );
510
-
511
- data->stmt_res->is_executing = 0;
512
-
513
- return rc;
514
- }
515
-
516
- /*
517
- This function calls SQLExecute cli call to execute the prepared
518
- */
519
- int _ruby_ibm_db_SQLExecute_helper(stmt_handle *stmt_res) {
520
- int rc = 0;
521
-
522
- stmt_res->is_executing = 1;
523
-
524
- rc = SQLExecute( (SQLHSTMT) stmt_res->hstmt );
525
-
526
- stmt_res->is_executing = 0;
527
-
528
- return rc;
529
- }
530
-
531
- /*
532
- This function calls SQLParamData cli call to read if there is still data to be sent
533
- */
534
- int _ruby_ibm_db_SQLParamData_helper(param_cum_put_data_args *data) {
535
- int rc = 0;
536
-
537
- data->stmt_res->is_executing = 1;
538
-
539
- rc = SQLParamData( (SQLHSTMT) data->stmt_res->hstmt, (SQLPOINTER *) &(data->valuePtr) );
540
-
541
- data->stmt_res->is_executing = 0;
542
-
543
- return rc;
544
- }
545
-
546
- /*
547
- This function calls SQLColAttributes cli call to get the specified attribute of the column in result set
548
- */
549
- int _ruby_ibm_db_SQLColAttributes_helper(col_attr_args *data) {
550
- int rc = 0;
551
-
552
- data->stmt_res->is_executing = 1;
553
-
554
- rc = SQLColAttributes( (SQLHSTMT) data->stmt_res->hstmt, data->col_num,
555
- data->FieldIdentifier, NULL, 0, NULL, &(data->num_attr) );
556
-
557
- data->stmt_res->is_executing = 0;
558
-
559
- return rc;
560
- }
561
-
562
- /*
563
- This function calls SQLPutData cli call to supply parameter data value
564
- */
565
- int _ruby_ibm_db_SQLPutData_helper(param_cum_put_data_args *data) {
566
- int rc = 0;
567
-
568
- data->stmt_res->is_executing = 1;
569
-
570
- rc = SQLPutData( (SQLHSTMT) data->stmt_res->hstmt, (SQLPOINTER)(((param_node*)(data->valuePtr))->svalue),
571
- ((param_node*)(data->valuePtr))->ivalue );
572
-
573
- data->stmt_res->is_executing = 0;
574
-
575
- return rc;
576
- }
577
-
578
- /*
579
- This function calls SQLGetData cli call to retrieve data for a single column
580
- */
581
- int _ruby_ibm_db_SQLGetData_helper(get_data_args *data) {
582
- int rc = 0;
583
-
584
- data->stmt_res->is_executing = 1;
585
-
586
- rc = SQLGetData( (SQLHSTMT) data->stmt_res->hstmt, data->col_num, data->targetType, data->buff,
587
- data->buff_length, data->out_length);
588
-
589
- data->stmt_res->is_executing = 0;
590
-
591
- return rc;
592
- }
593
-
594
- /*
595
- This function calls SQLGetLength cli call to retrieve the length of the lob value
596
- */
597
- int _ruby_ibm_db_SQLGetLength_helper(get_length_args *data) {
598
- int col_num = data->col_num;
599
- int rc = 0;
600
-
601
- data->stmt_res->is_executing = 1;
602
-
603
- rc = SQLGetLength( (SQLHSTMT) *( data->new_hstmt ), data->stmt_res->column_info[col_num-1].loc_type,
604
- data->stmt_res->column_info[col_num-1].lob_loc, data->sLength,
605
- &(data->stmt_res->column_info[col_num-1].loc_ind) );
606
-
607
- data->stmt_res->is_executing = 0;
608
-
609
- return rc;
610
- }
611
-
612
- /*
613
- This function calls SQLGetSubString cli call to retrieve portion of the lob value
614
- */
615
- int _ruby_ibm_db_SQLGetSubString_helper(get_subString_args *data) {
616
- int col_num = data->col_num;
617
- int rc = 0;
618
-
619
- data->stmt_res->is_executing = 1;
620
-
621
- rc = SQLGetSubString( (SQLHSTMT) *( data->new_hstmt ), data->stmt_res->column_info[col_num-1].loc_type,
622
- data->stmt_res->column_info[col_num-1].lob_loc, 1, data->forLength, data->targetCType,
623
- data->buffer, data->buff_length, data->out_length,
624
- &(data->stmt_res->column_info[col_num-1].loc_ind) );
625
-
626
- data->stmt_res->is_executing = 0;
627
-
628
- return rc;
629
- }
630
-
631
- /*
632
- This function calls SQLNextResult cli call to fetch the multiple result sets that might be returned by a stored Proc
633
- */
634
- int _ruby_ibm_db_SQLNextResult_helper(next_result_args *data) {
635
- int rc = 0;
636
-
637
- data->stmt_res->is_executing = 1;
638
-
639
- rc = SQLNextResult( (SQLHSTMT) data->stmt_res->hstmt, (SQLHSTMT) *(data->new_hstmt) );
640
-
641
- data->stmt_res->is_executing = 0;
642
-
643
- return rc;
644
- }
645
-
646
- /*
647
- This function calls SQLFetchScroll cli call to fetch the specified rowset of data from result
648
- */
649
- int _ruby_ibm_db_SQLFetchScroll_helper(fetch_data_args *data) {
650
- int rc = 0;
651
-
652
- data->stmt_res->is_executing = 1;
653
-
654
- rc = SQLFetchScroll( (SQLHSTMT) data->stmt_res->hstmt, data->fetchOrientation, data->fetchOffset);
655
-
656
- data->stmt_res->is_executing = 0;
657
-
658
- return rc;
659
- }
660
-
661
- /*
662
- This function calls SQLFetch cli call to advance the cursor to
663
- the next row of the result set, and retrieves any bound columns
664
- */
665
- int _ruby_ibm_db_SQLFetch_helper(fetch_data_args *data) {
666
- int rc = 0;
667
-
668
- data->stmt_res->is_executing = 1;
669
-
670
- rc = SQLFetch( (SQLHSTMT) data->stmt_res->hstmt );
671
-
672
- data->stmt_res->is_executing = 0;
673
-
674
- return rc;
675
- }
676
-
677
- /*
678
- This function calls SQLNumResultCols cli call to fetch the number of fields contained in a result set
679
- */
680
- int _ruby_ibm_db_SQLNumResultCols_helper(row_col_count_args *data) {
681
- int rc = 0;
682
-
683
- data->stmt_res->is_executing = 1;
684
-
685
- rc = SQLNumResultCols( (SQLHSTMT) data->stmt_res->hstmt, (SQLSMALLINT*) &(data->count) );
686
-
687
- data->stmt_res->is_executing = 0;
688
-
689
- return rc;
690
- }
691
-
692
- /*
693
- This function calls SQLNumParams cli call to fetch the number of parameter markers in an SQL statement
694
- */
695
- int _ruby_ibm_db_SQLNumParams_helper(row_col_count_args *data) {
696
- int rc = 0;
697
-
698
- data->stmt_res->is_executing = 1;
699
-
700
- rc = SQLNumParams( (SQLHSTMT) data->stmt_res->hstmt, (SQLSMALLINT*) &(data->count) );
701
-
702
- data->stmt_res->is_executing = 0;
703
-
704
- return rc;
705
- }
706
-
707
- /*
708
- This function calls SQLRowCount cli call to fetch the number of rows affected by the SQL statement
709
- */
710
- int _ruby_ibm_db_SQLRowCount_helper(sql_row_count_args *data) {
711
- int rc = 0;
712
-
713
- data->stmt_res->is_executing = 1;
714
-
715
- rc = SQLRowCount( (SQLHSTMT) data->stmt_res->hstmt, (SQLLEN*) &(data->count) );
716
-
717
- data->stmt_res->is_executing = 0;
718
-
719
- return rc;
720
- }
721
-
722
- /*
723
- This function calls SQLGetInfo cli call to get general information about DBMS, which the app is connected to
724
- */
725
- int _ruby_ibm_db_SQLGetInfo_helper(get_info_args *data) {
726
- #ifndef UNICODE_SUPPORT_VERSION
727
- return SQLGetInfo( data->conn_res->hdbc, data->infoType, data->infoValue, data->buff_length, data->out_length);
728
- #else
729
- return SQLGetInfoW( data->conn_res->hdbc, data->infoType, data->infoValue, data->buff_length, data->out_length);
730
- #endif
731
- }
732
-
733
- /*
734
- This function calls SQLGetDiagRec cli call to get the current values of a diagnostic record that contains error
735
- */
736
- int _ruby_ibm_db_SQLGetDiagRec_helper(get_diagRec_args *data) {
737
- #ifdef UNICODE_SUPPORT_VERSION
738
- return SQLGetDiagRecW( data->hType, data->handle, data->recNum, data->SQLState, data->NativeErrorPtr,
739
- data->msgText, data->buff_length, data->text_length_ptr );
740
- #else
741
- return SQLGetDiagRec(data->hType, data->handle, data->recNum, data->SQLState, data->NativeErrorPtr,
742
- data->msgText, data->buff_length, data->text_length_ptr );
743
- #endif
744
- }
745
-
746
- /*
747
- This function calls SQLSetStmtAttr cli call to set attributes related to a statement
748
- */
749
- int _ruby_ibm_db_SQLSetStmtAttr_helper(set_handle_attr_args *data) {
750
- #ifndef UNICODE_SUPPORT_VERSION
751
- return SQLSetStmtAttr( (SQLHSTMT) *(data->handle), data->attribute, data->valuePtr, data->strLength );
752
- #else
753
- return SQLSetStmtAttrW( (SQLHSTMT) *(data->handle), data->attribute, data->valuePtr, data->strLength );
754
- #endif
755
- }
756
-
757
- /*
758
- This function calls SQLSetConnectAttr cli call to set attributes that govern aspects of connections
759
- */
760
- int _ruby_ibm_db_SQLSetConnectAttr_helper(set_handle_attr_args *data) {
761
- #ifndef UNICODE_SUPPORT_VERSION
762
- return SQLSetConnectAttr( (SQLHDBC) *(data->handle), data->attribute, data->valuePtr, data->strLength );
763
- #else
764
- return SQLSetConnectAttrW( (SQLHDBC) *(data->handle), data->attribute, data->valuePtr, data->strLength );
765
- #endif
766
- }
767
-
768
- /*
769
- This function calls SQLSetEnvAttr cli call to set an environment attribute
770
- */
771
- int _ruby_ibm_db_SQLSetEnvAttr_helper(set_handle_attr_args *data) {
772
- return SQLSetEnvAttr( (SQLHENV) *(data->handle), data->attribute, data->valuePtr, data->strLength);
773
- }
774
-
775
- /*
776
- This function calls SQLGetStmtAttr cli call to set an environment attribute
777
-
778
- The unicode equivalent of SQLGetStmtAttr is not used because the attributes being retrieved currently are not of type char or binary (SQL_IS_INTEGER). If support for retrieving a string type is provided then use the SQLGetStmtAttrW function accordingly
779
- In get_last_serial_id although we are retrieving a char type, it is converted back to an integer (atoi). The char to integer conversion function in unicode equivalent will be more complicated and is unnecessary for this case.
780
-
781
- */
782
- int _ruby_ibm_db_SQLGetStmtAttr_helper(get_handle_attr_args *data) {
783
- return SQLGetStmtAttr( (SQLHSTMT) *(data->handle), data->attribute, data->valuePtr,
784
- data->buff_length, data->out_length);
785
- }
786
-
787
- /*
788
- This function calls SQLGetConnectAttr cli call to set an environment attribute
789
- */
790
- int _ruby_ibm_db_SQLGetConnectAttr_helper(get_handle_attr_args *data) {
791
- #ifndef UNICODE_SUPPORT_VERSION
792
- return SQLGetConnectAttr( (SQLHDBC) *(data->handle), data->attribute, data->valuePtr,
793
- data->buff_length, data->out_length);
794
- #else
795
- return SQLGetConnectAttrW( (SQLHDBC) *(data->handle), data->attribute, data->valuePtr,
796
- data->buff_length, data->out_length);
797
- #endif
798
- }
799
-
800
- /*
801
- This function calls SQLBindFileToParam cli call
802
- */
803
- int _ruby_ibm_db_SQLBindFileToParam_helper(stmt_handle *stmt_res, param_node *curr) {
804
- int rc = 0;
805
-
806
- stmt_res->is_executing = 1;
807
-
808
- rc = SQLBindFileToParam( (SQLHSTMT)stmt_res->hstmt, curr->param_num,
809
- curr->data_type, (SQLCHAR*)curr->svalue,
810
- (SQLSMALLINT*)&(curr->ivalue), &(curr->file_options),
811
- curr->ivalue, &(curr->bind_indicator) );
812
-
813
- stmt_res->is_executing = 0;
814
-
815
- return rc;
816
- }
817
-
818
- /*
819
- This function calls SQLBindParameter cli call
820
- */
821
- int _ruby_ibm_db_SQLBindParameter_helper(bind_parameter_args *data) {
822
- int rc = 0;
823
-
824
- data->stmt_res->is_executing = 1;
825
-
826
- rc = SQLBindParameter( (SQLHSTMT) data->stmt_res->hstmt, data->param_num, data->IOType, data->valueType,
827
- data->paramType, data->colSize, data->decimalDigits, data->paramValPtr, data->buff_length,
828
- data->out_length );
829
-
830
- data->stmt_res->is_executing = 0;
831
-
832
- return rc;
833
- }
834
-
835
- /*
836
- Statement level thread unblock function. This fuction cancels a statement level SQL call issued when requested for,
837
- allowing for a safe interrupt of the thread.
838
- */
839
- void _ruby_ibm_db_Statement_level_UBF(stmt_handle *stmt_res) {
840
- int rc = 0;
841
- if( stmt_res->is_executing == 1 ) {
842
- rc = SQLCancel( (SQLHSTMT) stmt_res->hstmt );
843
- }
844
- return;
845
- }
1
+ /*
2
+ +----------------------------------------------------------------------+
3
+ | Licensed Materials - Property of IBM |
4
+ | |
5
+ | (C) Copyright IBM Corporation 2009, 2010, 2012 |
6
+ +----------------------------------------------------------------------+
7
+ | Authors: Praveen Devarao |
8
+ +----------------------------------------------------------------------+
9
+ */
10
+
11
+
12
+ /*
13
+ This C file contains functions that perform DB operations, which can take long time to complete.
14
+ For Eg: - Like SQLConnect, SQLFetch etc.
15
+
16
+ This file in general will contain functions that make CLI calls and
17
+ depending on whether the call will be transferred to server or not the functions are termed long time comsuming or not.
18
+
19
+ The functions which will contact the server and hence can be time consuming will be called by ruby's (1.9 onwards)
20
+ rb_thread_blocking_region method, which inturn will release the GVL while these operations are being performed.
21
+ With this the executing thread will become unblocking allowing concurrent threads perform operations simultaneously.
22
+ */
23
+
24
+ #include "ruby_ibm_db_cli.h"
25
+
26
+ /*
27
+ This function connects to the database using either SQLConnect or SQLDriverConnect CLI API
28
+ depending on whether it is a cataloged or an uncataloged connection.
29
+ */
30
+ int _ruby_ibm_db_SQLConnect_helper(connect_args *data) {
31
+ if(data->ctlg_conn == 1) {
32
+ #ifndef UNICODE_SUPPORT_VERSION
33
+ return SQLConnect( (SQLHDBC)*(data->hdbc), (SQLCHAR *)data->database,
34
+ (SQLSMALLINT)data->database_len, (SQLCHAR *)data->uid, (SQLSMALLINT)data->uid_len,
35
+ (SQLCHAR *)data->password, (SQLSMALLINT)data->password_len );
36
+ #else
37
+ return SQLConnectW( (SQLHDBC)*(data->hdbc), data->database,
38
+ data->database_len, data->uid, data->uid_len,
39
+ data->password, data->password_len );
40
+ #endif
41
+ } else {
42
+ #ifndef UNICODE_SUPPORT_VERSION
43
+ return SQLDriverConnect( (SQLHDBC) *(data->hdbc), (SQLHWND)NULL,
44
+ (SQLCHAR*)data->database, SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPROMPT );
45
+ #else
46
+ return SQLDriverConnectW( (SQLHDBC) *(data->hdbc), (SQLHWND)NULL,
47
+ data->database, SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPROMPT );
48
+ #endif
49
+ }
50
+ }
51
+
52
+ /*
53
+ This function issues SQLDisconnect to disconnect from the Dataserver
54
+ */
55
+ int _ruby_ibm_db_SQLDisconnect_helper(SQLHANDLE *hdbc) {
56
+ return SQLDisconnect( (SQLHDBC) *hdbc );
57
+ }
58
+
59
+ /*
60
+ Connection level Unblock function. This function is called when a thread interruput is issued while executing a
61
+ connection level SQL call
62
+ */
63
+ void _ruby_ibm_db_Connection_level_UBF(void *data) {
64
+ return;
65
+ }
66
+
67
+ /*
68
+ This function will commit and end the inprogress transaction by issuing a SQLCommit
69
+ */
70
+ int _ruby_ibm_db_SQLEndTran(end_tran_args *endtran_args) {
71
+ return SQLEndTran( endtran_args->handleType, *(endtran_args->hdbc), endtran_args->completionType );
72
+ }
73
+
74
+ /*
75
+ This function call the SQLDescribeParam cli call to get the description of the parameter in the sql specified
76
+ */
77
+ int _ruby_ibm_db_SQLDescribeParam_helper(describeparam_args *data) {
78
+ int rc = 0;
79
+ data->stmt_res->is_executing = 1;
80
+
81
+ rc = SQLDescribeParam( (SQLHSTMT) data->stmt_res->hstmt, (SQLUSMALLINT)data->param_no, &(data->sql_data_type),
82
+ &(data->sql_precision), &(data->sql_scale), &(data->sql_nullable) );
83
+
84
+ data->stmt_res->is_executing = 0;
85
+
86
+ return rc;
87
+ }
88
+
89
+ /*
90
+ This function call the SQLDescribeCol cli call to get the description of the parameter in the sql specified
91
+ */
92
+ int _ruby_ibm_db_SQLDescribeCol_helper(describecol_args *data) {
93
+ int i = data->col_no - 1;
94
+ int rc = 0;
95
+
96
+ data->stmt_res->is_executing = 1;
97
+
98
+ #ifdef UNICODE_SUPPORT_VERSION
99
+ rc = SQLDescribeColW( (SQLHSTMT)data->stmt_res->hstmt, (SQLSMALLINT)(data->col_no),
100
+ data->stmt_res->column_info[i].name, data->buff_length, &(data->name_length),
101
+ &(data->stmt_res->column_info[i].type), &(data->stmt_res->column_info[i].size),
102
+ &(data->stmt_res->column_info[i].scale), &(data->stmt_res->column_info[i].nullable) );
103
+ #else
104
+ rc = SQLDescribeCol( (SQLHSTMT)data->stmt_res->hstmt, (SQLSMALLINT)(data->col_no),
105
+ data->stmt_res->column_info[i].name, data->buff_length, &(data->name_length),
106
+ &(data->stmt_res->column_info[i].type), &(data->stmt_res->column_info[i].size),
107
+ &(data->stmt_res->column_info[i].scale), &(data->stmt_res->column_info[i].nullable) );
108
+ #endif
109
+
110
+ data->stmt_res->is_executing = 0;
111
+
112
+ return rc;
113
+ }
114
+
115
+ /*
116
+ This function call the SQLBindCol cli call to get the description of the parameter in the sql specified
117
+ */
118
+ int _ruby_ibm_db_SQLBindCol_helper(bind_col_args *data) {
119
+ int rc = 0;
120
+
121
+ data->stmt_res->is_executing = 1;
122
+
123
+ rc = SQLBindCol( (SQLHSTMT) data->stmt_res->hstmt, (SQLUSMALLINT)(data->col_num),
124
+ data->TargetType, data->TargetValuePtr, data->buff_length,
125
+ data->out_length );
126
+
127
+ data->stmt_res->is_executing = 0;
128
+
129
+ return rc;
130
+ }
131
+
132
+ /*
133
+ This function calls SQLColumnPrivileges cli call to get the list of columns and the associated privileges
134
+ */
135
+ int _ruby_ibm_db_SQLColumnPrivileges_helper(metadata_args *data) {
136
+ int rc = 0;
137
+
138
+ data->stmt_res->is_executing = 1;
139
+
140
+ #ifndef UNICODE_SUPPORT_VERSION
141
+ rc = SQLColumnPrivileges( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
142
+ data->owner, data->owner_len, data->table_name, data->table_name_len,
143
+ data->column_name, data->column_name_len );
144
+ #else
145
+ rc = SQLColumnPrivilegesW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
146
+ data->owner, data->owner_len, data->table_name, data->table_name_len,
147
+ data->column_name, data->column_name_len );
148
+ #endif
149
+
150
+ data->stmt_res->is_executing = 0;
151
+
152
+ return rc;
153
+
154
+ }
155
+
156
+ /*
157
+ This function calls SQLColumns cli call to get the list of columns and the associated metadata of the table
158
+ */
159
+ int _ruby_ibm_db_SQLColumns_helper(metadata_args *data) {
160
+ int rc = 0;
161
+
162
+ data->stmt_res->is_executing = 1;
163
+
164
+ #ifndef UNICODE_SUPPORT_VERSION
165
+ rc = SQLColumns( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
166
+ data->owner, data->owner_len, data->table_name, data->table_name_len,
167
+ data->column_name, data->column_name_len );
168
+ #else
169
+ rc = SQLColumnsW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
170
+ data->owner, data->owner_len, data->table_name, data->table_name_len,
171
+ data->column_name, data->column_name_len );
172
+ #endif
173
+
174
+ data->stmt_res->is_executing = 0;
175
+
176
+ return rc;
177
+ }
178
+
179
+ /*
180
+ This function calls SQLPrimaryKeys cli call to get the list of primay key columns and the associated metadata
181
+ */
182
+ int _ruby_ibm_db_SQLPrimaryKeys_helper(metadata_args *data) {
183
+ int rc = 0;
184
+
185
+ data->stmt_res->is_executing = 1;
186
+
187
+ #ifndef UNICODE_SUPPORT_VERSION
188
+ rc = SQLPrimaryKeys( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
189
+ data->owner, data->owner_len, data->table_name, data->table_name_len );
190
+ #else
191
+ rc = SQLPrimaryKeysW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
192
+ data->owner, data->owner_len, data->table_name, data->table_name_len );
193
+ #endif
194
+
195
+ data->stmt_res->is_executing = 0;
196
+
197
+ return rc;
198
+ }
199
+
200
+ /*
201
+ This function calls SQLForeignKeys cli call to get the list of foreign key columns and the associated metadata
202
+ */
203
+ int _ruby_ibm_db_SQLForeignKeys_helper(metadata_args *data) {
204
+ int rc = 0;
205
+
206
+ data->stmt_res->is_executing = 1;
207
+
208
+ #ifndef UNICODE_SUPPORT_VERSION
209
+ rc = SQLForeignKeys( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
210
+ data->owner, data->owner_len, data->table_name , data->table_name_len, NULL, SQL_NTS,
211
+ NULL, SQL_NTS, NULL, SQL_NTS );
212
+ #else
213
+ rc = SQLForeignKeysW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
214
+ data->owner, data->owner_len, data->table_name , data->table_name_len, NULL, SQL_NTS,
215
+ NULL, SQL_NTS, NULL, SQL_NTS );
216
+ #endif
217
+
218
+ data->stmt_res->is_executing = 0;
219
+
220
+ return rc;
221
+ }
222
+
223
+ /*
224
+ This function calls SQLProcedureColumns cli call to get the list of parameters
225
+ and associated metadata of the stored procedure
226
+ */
227
+ int _ruby_ibm_db_SQLProcedureColumns_helper(metadata_args *data) {
228
+ int rc = 0;
229
+
230
+ data->stmt_res->is_executing = 1;
231
+
232
+ #ifndef UNICODE_SUPPORT_VERSION
233
+ rc = SQLProcedureColumns( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
234
+ data->owner_len, data->proc_name, data->proc_name_len, data->column_name, data->column_name_len );
235
+ #else
236
+ rc = SQLProcedureColumnsW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
237
+ data->owner_len, data->proc_name, data->proc_name_len, data->column_name, data->column_name_len );
238
+ #endif
239
+
240
+ data->stmt_res->is_executing = 0;
241
+
242
+ return rc;
243
+ }
244
+
245
+ /*
246
+ This function calls SQLProcedures cli call to get the list of stored procedures
247
+ and associated metadata of the stored procedure
248
+ */
249
+ int _ruby_ibm_db_SQLProcedures_helper(metadata_args *data) {
250
+ int rc = 0;
251
+
252
+ data->stmt_res->is_executing = 1;
253
+
254
+ #ifndef UNICODE_SUPPORT_VERSION
255
+ rc = SQLProcedures( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
256
+ data->owner_len, data->proc_name, data->proc_name_len );
257
+ #else
258
+ rc = SQLProceduresW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
259
+ data->owner_len, data->proc_name, data->proc_name_len );
260
+ #endif
261
+
262
+ data->stmt_res->is_executing = 0;
263
+
264
+ return rc;
265
+ }
266
+
267
+ /*
268
+ This function calls SQLSpecialColumns cli call to get the metadata related to the special columns
269
+ (Unique index or primary key column) and associated metadata
270
+ */
271
+ int _ruby_ibm_db_SQLSpecialColumns_helper(metadata_args *data) {
272
+ int rc = 0;
273
+
274
+ data->stmt_res->is_executing = 1;
275
+
276
+ #ifndef UNICODE_SUPPORT_VERSION
277
+ rc = SQLSpecialColumns( (SQLHSTMT) data->stmt_res->hstmt, SQL_BEST_ROWID, data->qualifier, data->qualifier_len,
278
+ data->owner, data->owner_len, data->table_name, data->table_name_len,
279
+ (SQLUSMALLINT)data->scope, SQL_NULLABLE );
280
+ #else
281
+ rc = SQLSpecialColumnsW( (SQLHSTMT) data->stmt_res->hstmt, SQL_BEST_ROWID, data->qualifier, data->qualifier_len,
282
+ data->owner, data->owner_len, data->table_name, data->table_name_len,
283
+ (SQLUSMALLINT)data->scope, SQL_NULLABLE );
284
+ #endif
285
+
286
+ data->stmt_res->is_executing = 0;
287
+
288
+ return rc;
289
+ }
290
+
291
+ /*
292
+ This function calls SQLStatistics cli call to get the index information for a given table.
293
+ */
294
+ int _ruby_ibm_db_SQLStatistics_helper(metadata_args *data) {
295
+ int rc = 0;
296
+
297
+ data->stmt_res->is_executing = 1;
298
+
299
+ #ifndef UNICODE_SUPPORT_VERSION
300
+ rc = SQLStatistics( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
301
+ data->owner_len, data->table_name, data->table_name_len, (SQLUSMALLINT)data->unique, SQL_QUICK );
302
+ #else
303
+ rc = SQLStatisticsW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
304
+ data->owner_len, data->table_name, data->table_name_len, (SQLUSMALLINT)data->unique, SQL_QUICK );
305
+ #endif
306
+
307
+ data->stmt_res->is_executing = 0;
308
+
309
+ return rc;
310
+ }
311
+
312
+ /*
313
+ This function calls SQLTablePrivileges cli call to retrieve list of tables and
314
+ the asscociated privileges for each table.
315
+ */
316
+ int _ruby_ibm_db_SQLTablePrivileges_helper(metadata_args *data) {
317
+ int rc = 0;
318
+
319
+ data->stmt_res->is_executing = 1;
320
+
321
+ #ifndef UNICODE_SUPPORT_VERSION
322
+ rc = SQLTablePrivileges( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
323
+ data->owner, data->owner_len, data->table_name, data->table_name_len );
324
+ #else
325
+ rc = SQLTablePrivilegesW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len,
326
+ data->owner, data->owner_len, data->table_name, data->table_name_len );
327
+ #endif
328
+
329
+ data->stmt_res->is_executing = 0;
330
+
331
+ return rc;
332
+ }
333
+
334
+ /*
335
+ This function calls SQLTables cli call to retrieve list of tables in the specified schema and
336
+ the asscociated metadata for each table.
337
+ */
338
+ int _ruby_ibm_db_SQLTables_helper(metadata_args *data) {
339
+ int rc = 0;
340
+
341
+ data->stmt_res->is_executing = 1;
342
+
343
+ #ifndef UNICODE_SUPPORT_VERSION
344
+ rc = SQLTables( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
345
+ data->owner_len, data->table_name, data->table_name_len, data->table_type, data->table_type_len );
346
+ #else
347
+ rc = SQLTablesW( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, data->qualifier_len, data->owner,
348
+ data->owner_len, data->table_name, data->table_name_len, data->table_type, data->table_type_len );
349
+ #endif
350
+
351
+ data->stmt_res->is_executing = 0;
352
+
353
+ return rc;
354
+ }
355
+
356
+ /*
357
+ This function calls SQLExecDirect cli call to execute a statement directly
358
+ */
359
+ int _ruby_ibm_db_SQLExecDirect_helper(exec_cum_prepare_args *data) {
360
+ int rc = 0;
361
+
362
+ data->stmt_res->is_executing = 1;
363
+
364
+ #ifndef UNICODE_SUPPORT_VERSION
365
+ rc = SQLExecDirect( (SQLHSTMT) data->stmt_res->hstmt, data->stmt_string, (SQLINTEGER)data->stmt_string_len );
366
+ #else
367
+ rc = SQLExecDirectW( (SQLHSTMT) data->stmt_res->hstmt, data->stmt_string, (SQLINTEGER)data->stmt_string_len );
368
+ #endif
369
+
370
+ data->stmt_res->is_executing = 0;
371
+
372
+ return rc;
373
+ }
374
+
375
+ /*
376
+ This function calls SQLCreateDb cli call
377
+ */
378
+ int _ruby_ibm_db_SQLCreateDB_helper(create_drop_db_args *data) {
379
+ int rc = 0;
380
+ #ifndef UNICODE_SUPPORT_VERSION
381
+ #ifdef _WIN32
382
+ HINSTANCE cliLib = NULL;
383
+ FARPROC sqlcreatedb;
384
+ cliLib = DLOPEN( LIBDB2 );
385
+ sqlcreatedb = DLSYM( cliLib, "SQLCreateDb" );
386
+ #elif _AIX
387
+ void *cliLib = NULL;
388
+ typedef int (*sqlcreatedbType)( SQLHDBC, SQLCHAR *, SQLINTEGER, SQLCHAR *, SQLINTEGER, SQLCHAR *, SQLINTEGER );
389
+ sqlcreatedbType sqlcreatedb;
390
+ /* On AIX CLI library is in archive. Hence we will need to specify flags in DLOPEN to load a member of the archive*/
391
+ cliLib = DLOPEN( LIBDB2, RTLD_MEMBER | RTLD_LAZY );
392
+ sqlcreatedb = (sqlcreatedbType) DLSYM( cliLib, "SQLCreateDb" );
393
+ #else
394
+ void *cliLib = NULL;
395
+ typedef int (*sqlcreatedbType)( SQLHDBC, SQLCHAR *, SQLINTEGER, SQLCHAR *, SQLINTEGER, SQLCHAR *, SQLINTEGER );
396
+ sqlcreatedbType sqlcreatedb;
397
+ cliLib = DLOPEN( LIBDB2, RTLD_LAZY );
398
+ sqlcreatedb = (sqlcreatedbType) DLSYM( cliLib, "SQLCreateDb" );
399
+ #endif
400
+ #else
401
+ #ifdef _WIN32
402
+ HINSTANCE cliLib = NULL;
403
+ FARPROC sqlcreatedb;
404
+ cliLib = DLOPEN( LIBDB2 );
405
+ sqlcreatedb = DLSYM( cliLib, "SQLCreateDbW" );
406
+ #elif _AIX
407
+ void *cliLib = NULL;
408
+ typedef int (*sqlcreatedbType)( SQLHDBC, SQLWCHAR *, SQLINTEGER, SQLWCHAR *, SQLINTEGER, SQLWCHAR *, SQLINTEGER );
409
+ sqlcreatedbType sqlcreatedb;
410
+ /* On AIX CLI library is in archive. Hence we will need to specify flags in DLOPEN to load a member of the archive*/
411
+ cliLib = DLOPEN( LIBDB2, RTLD_MEMBER | RTLD_LAZY );
412
+ sqlcreatedb = (sqlcreatedbType) DLSYM( cliLib, "SQLCreateDbW" );
413
+ #else
414
+ void *cliLib = NULL;
415
+ typedef int (*sqlcreatedbType)( SQLHDBC, SQLWCHAR *, SQLINTEGER, SQLWCHAR *, SQLINTEGER, SQLWCHAR *, SQLINTEGER );
416
+ sqlcreatedbType sqlcreatedb;
417
+ cliLib = DLOPEN( LIBDB2, RTLD_LAZY );
418
+ sqlcreatedb = (sqlcreatedbType) DLSYM( cliLib, "SQLCreateDbW" );
419
+ #endif
420
+ #endif
421
+
422
+ rc = (*sqlcreatedb)( (SQLHSTMT) data->conn_res->hdbc, data->dbName, (SQLINTEGER)data->dbName_string_len,
423
+ data->codeSet, (SQLINTEGER)data->codeSet_string_len,
424
+ data->mode, (SQLINTEGER)data->mode_string_len );
425
+ DLCLOSE( cliLib );
426
+ return rc;
427
+ }
428
+
429
+ /*
430
+ This function calls SQLDropDb cli call
431
+ */
432
+ int _ruby_ibm_db_SQLDropDB_helper(create_drop_db_args *data) {
433
+ int rc = 0;
434
+ #ifndef UNICODE_SUPPORT_VERSION
435
+ #ifdef _WIN32
436
+ HINSTANCE cliLib = NULL;
437
+ FARPROC sqldropdb;
438
+ cliLib = DLOPEN( LIBDB2 );
439
+ sqldropdb = DLSYM( cliLib, "SQLDropDb" );
440
+ #elif _AIX
441
+ void *cliLib = NULL;
442
+ typedef int (*sqldropdbType)( SQLHDBC, SQLCHAR *, SQLINTEGER);
443
+ sqldropdbType sqldropdb;
444
+ /* On AIX CLI library is in archive. Hence we will need to specify flags in DLOPEN to load a member of the archive*/
445
+ cliLib = DLOPEN( LIBDB2, RTLD_MEMBER | RTLD_LAZY );
446
+ sqldropdb = (sqldropdbType) DLSYM( cliLib, "SQLDropDb" );
447
+ #else
448
+ void *cliLib = NULL;
449
+ typedef int (*sqldropdbType)( SQLHDBC, SQLCHAR *, SQLINTEGER);
450
+ sqldropdbType sqldropdb;
451
+ cliLib = DLOPEN( LIBDB2, RTLD_LAZY );
452
+ sqldropdb = (sqldropdbType) DLSYM( cliLib, "SQLDropDb" );
453
+ #endif
454
+ #else
455
+ #ifdef _WIN32
456
+ HINSTANCE cliLib = NULL;
457
+ FARPROC sqldropdb;
458
+ cliLib = DLOPEN( LIBDB2 );
459
+ sqldropdb = DLSYM( cliLib, "SQLDropDbW" );
460
+ #elif _AIX
461
+ void *cliLib = NULL;
462
+ typedef int (*sqldropdbType)( SQLHDBC, SQLWCHAR *, SQLINTEGER);
463
+ sqldropdbType sqldropdb;
464
+ /* On AIX CLI library is in archive. Hence we will need to specify flags in DLOPEN to load a member of the archive*/
465
+ cliLib = DLOPEN( LIBDB2, RTLD_MEMBER | RTLD_LAZY );
466
+ sqldropdb = (sqldropdbType) DLSYM( cliLib, "SQLDropDbW" );
467
+ #else
468
+ void *cliLib = NULL;
469
+ typedef int (*sqldropdbType)( SQLHDBC, SQLWCHAR *, SQLINTEGER);
470
+ sqldropdbType sqldropdb;
471
+ cliLib = DLOPEN( LIBDB2, RTLD_LAZY );
472
+ sqldropdb = (sqldropdbType) DLSYM( cliLib, "SQLDropDbW" );
473
+ #endif
474
+ #endif
475
+
476
+ rc = (*sqldropdb)( (SQLHSTMT) data->conn_res->hdbc, data->dbName, (SQLINTEGER)data->dbName_string_len );
477
+
478
+ DLCLOSE( cliLib );
479
+ return rc;
480
+ }
481
+
482
+ /*
483
+ This function calls SQLPrepare cli call to prepare the given statement
484
+ */
485
+ int _ruby_ibm_db_SQLPrepare_helper(exec_cum_prepare_args *data) {
486
+ int rc = 0;
487
+
488
+ data->stmt_res->is_executing = 1;
489
+
490
+ #ifndef UNICODE_SUPPORT_VERSION
491
+ rc = SQLPrepare( (SQLHSTMT) data->stmt_res->hstmt, data->stmt_string, (SQLINTEGER)data->stmt_string_len );
492
+ #else
493
+ rc = SQLPrepareW( (SQLHSTMT) data->stmt_res->hstmt, data->stmt_string, (SQLINTEGER)data->stmt_string_len );
494
+ #endif
495
+
496
+ data->stmt_res->is_executing = 0;
497
+
498
+ return rc;
499
+ }
500
+
501
+ /*
502
+ This function calls SQLFreeStmt to end processing on the statement referenced by statement handle
503
+ */
504
+ int _ruby_ibm_db_SQLFreeStmt_helper(free_stmt_args *data) {
505
+ int rc = 0;
506
+
507
+ data->stmt_res->is_executing = 1;
508
+
509
+ SQLFreeStmt((SQLHSTMT)data->stmt_res->hstmt, data->option );
510
+
511
+ data->stmt_res->is_executing = 0;
512
+
513
+ return rc;
514
+ }
515
+
516
+ /*
517
+ This function calls SQLExecute cli call to execute the prepared
518
+ */
519
+ int _ruby_ibm_db_SQLExecute_helper(stmt_handle *stmt_res) {
520
+ int rc = 0;
521
+
522
+ stmt_res->is_executing = 1;
523
+
524
+ rc = SQLExecute( (SQLHSTMT) stmt_res->hstmt );
525
+
526
+ stmt_res->is_executing = 0;
527
+
528
+ return rc;
529
+ }
530
+
531
+ /*
532
+ This function calls SQLParamData cli call to read if there is still data to be sent
533
+ */
534
+ int _ruby_ibm_db_SQLParamData_helper(param_cum_put_data_args *data) {
535
+ int rc = 0;
536
+
537
+ data->stmt_res->is_executing = 1;
538
+
539
+ rc = SQLParamData( (SQLHSTMT) data->stmt_res->hstmt, (SQLPOINTER *) &(data->valuePtr) );
540
+
541
+ data->stmt_res->is_executing = 0;
542
+
543
+ return rc;
544
+ }
545
+
546
+ /*
547
+ This function calls SQLColAttributes cli call to get the specified attribute of the column in result set
548
+ */
549
+ int _ruby_ibm_db_SQLColAttributes_helper(col_attr_args *data) {
550
+ int rc = 0;
551
+
552
+ data->stmt_res->is_executing = 1;
553
+
554
+ rc = SQLColAttributes( (SQLHSTMT) data->stmt_res->hstmt, data->col_num,
555
+ data->FieldIdentifier, NULL, 0, NULL, &(data->num_attr) );
556
+
557
+ data->stmt_res->is_executing = 0;
558
+
559
+ return rc;
560
+ }
561
+
562
+ /*
563
+ This function calls SQLPutData cli call to supply parameter data value
564
+ */
565
+ int _ruby_ibm_db_SQLPutData_helper(param_cum_put_data_args *data) {
566
+ int rc = 0;
567
+
568
+ data->stmt_res->is_executing = 1;
569
+
570
+ rc = SQLPutData( (SQLHSTMT) data->stmt_res->hstmt, (SQLPOINTER)(((param_node*)(data->valuePtr))->svalue),
571
+ ((param_node*)(data->valuePtr))->ivalue );
572
+
573
+ data->stmt_res->is_executing = 0;
574
+
575
+ return rc;
576
+ }
577
+
578
+ /*
579
+ This function calls SQLGetData cli call to retrieve data for a single column
580
+ */
581
+ int _ruby_ibm_db_SQLGetData_helper(get_data_args *data) {
582
+ int rc = 0;
583
+
584
+ data->stmt_res->is_executing = 1;
585
+
586
+ rc = SQLGetData( (SQLHSTMT) data->stmt_res->hstmt, data->col_num, data->targetType, data->buff,
587
+ data->buff_length, data->out_length);
588
+
589
+ data->stmt_res->is_executing = 0;
590
+
591
+ return rc;
592
+ }
593
+
594
+ /*
595
+ This function calls SQLGetLength cli call to retrieve the length of the lob value
596
+ */
597
+ int _ruby_ibm_db_SQLGetLength_helper(get_length_args *data) {
598
+ int col_num = data->col_num;
599
+ int rc = 0;
600
+
601
+ data->stmt_res->is_executing = 1;
602
+
603
+ rc = SQLGetLength( (SQLHSTMT) *( data->new_hstmt ), data->stmt_res->column_info[col_num-1].loc_type,
604
+ data->stmt_res->column_info[col_num-1].lob_loc, data->sLength,
605
+ &(data->stmt_res->column_info[col_num-1].loc_ind) );
606
+
607
+ data->stmt_res->is_executing = 0;
608
+
609
+ return rc;
610
+ }
611
+
612
+ /*
613
+ This function calls SQLGetSubString cli call to retrieve portion of the lob value
614
+ */
615
+ int _ruby_ibm_db_SQLGetSubString_helper(get_subString_args *data) {
616
+ int col_num = data->col_num;
617
+ int rc = 0;
618
+
619
+ data->stmt_res->is_executing = 1;
620
+
621
+ rc = SQLGetSubString( (SQLHSTMT) *( data->new_hstmt ), data->stmt_res->column_info[col_num-1].loc_type,
622
+ data->stmt_res->column_info[col_num-1].lob_loc, 1, data->forLength, data->targetCType,
623
+ data->buffer, data->buff_length, data->out_length,
624
+ &(data->stmt_res->column_info[col_num-1].loc_ind) );
625
+
626
+ data->stmt_res->is_executing = 0;
627
+
628
+ return rc;
629
+ }
630
+
631
+ /*
632
+ This function calls SQLNextResult cli call to fetch the multiple result sets that might be returned by a stored Proc
633
+ */
634
+ int _ruby_ibm_db_SQLNextResult_helper(next_result_args *data) {
635
+ int rc = 0;
636
+
637
+ data->stmt_res->is_executing = 1;
638
+
639
+ rc = SQLNextResult( (SQLHSTMT) data->stmt_res->hstmt, (SQLHSTMT) *(data->new_hstmt) );
640
+
641
+ data->stmt_res->is_executing = 0;
642
+
643
+ return rc;
644
+ }
645
+
646
+ /*
647
+ This function calls SQLFetchScroll cli call to fetch the specified rowset of data from result
648
+ */
649
+ int _ruby_ibm_db_SQLFetchScroll_helper(fetch_data_args *data) {
650
+ int rc = 0;
651
+
652
+ data->stmt_res->is_executing = 1;
653
+
654
+ rc = SQLFetchScroll( (SQLHSTMT) data->stmt_res->hstmt, data->fetchOrientation, data->fetchOffset);
655
+
656
+ data->stmt_res->is_executing = 0;
657
+
658
+ return rc;
659
+ }
660
+
661
+ /*
662
+ This function calls SQLFetch cli call to advance the cursor to
663
+ the next row of the result set, and retrieves any bound columns
664
+ */
665
+ int _ruby_ibm_db_SQLFetch_helper(fetch_data_args *data) {
666
+ int rc = 0;
667
+
668
+ data->stmt_res->is_executing = 1;
669
+
670
+ rc = SQLFetch( (SQLHSTMT) data->stmt_res->hstmt );
671
+
672
+ data->stmt_res->is_executing = 0;
673
+
674
+ return rc;
675
+ }
676
+
677
+ /*
678
+ This function calls SQLNumResultCols cli call to fetch the number of fields contained in a result set
679
+ */
680
+ int _ruby_ibm_db_SQLNumResultCols_helper(row_col_count_args *data) {
681
+ int rc = 0;
682
+
683
+ data->stmt_res->is_executing = 1;
684
+
685
+ rc = SQLNumResultCols( (SQLHSTMT) data->stmt_res->hstmt, (SQLSMALLINT*) &(data->count) );
686
+
687
+ data->stmt_res->is_executing = 0;
688
+
689
+ return rc;
690
+ }
691
+
692
+ /*
693
+ This function calls SQLNumParams cli call to fetch the number of parameter markers in an SQL statement
694
+ */
695
+ int _ruby_ibm_db_SQLNumParams_helper(row_col_count_args *data) {
696
+ int rc = 0;
697
+
698
+ data->stmt_res->is_executing = 1;
699
+
700
+ rc = SQLNumParams( (SQLHSTMT) data->stmt_res->hstmt, (SQLSMALLINT*) &(data->count) );
701
+
702
+ data->stmt_res->is_executing = 0;
703
+
704
+ return rc;
705
+ }
706
+
707
+ /*
708
+ This function calls SQLRowCount cli call to fetch the number of rows affected by the SQL statement
709
+ */
710
+ int _ruby_ibm_db_SQLRowCount_helper(sql_row_count_args *data) {
711
+ int rc = 0;
712
+
713
+ data->stmt_res->is_executing = 1;
714
+
715
+ rc = SQLRowCount( (SQLHSTMT) data->stmt_res->hstmt, (SQLLEN*) &(data->count) );
716
+
717
+ data->stmt_res->is_executing = 0;
718
+
719
+ return rc;
720
+ }
721
+
722
+ /*
723
+ This function calls SQLGetInfo cli call to get general information about DBMS, which the app is connected to
724
+ */
725
+ int _ruby_ibm_db_SQLGetInfo_helper(get_info_args *data) {
726
+ #ifndef UNICODE_SUPPORT_VERSION
727
+ return SQLGetInfo( data->conn_res->hdbc, data->infoType, data->infoValue, data->buff_length, data->out_length);
728
+ #else
729
+ return SQLGetInfoW( data->conn_res->hdbc, data->infoType, data->infoValue, data->buff_length, data->out_length);
730
+ #endif
731
+ }
732
+
733
+ /*
734
+ This function calls SQLGetDiagRec cli call to get the current values of a diagnostic record that contains error
735
+ */
736
+ int _ruby_ibm_db_SQLGetDiagRec_helper(get_diagRec_args *data) {
737
+ #ifdef UNICODE_SUPPORT_VERSION
738
+ return SQLGetDiagRecW( data->hType, data->handle, data->recNum, data->SQLState, data->NativeErrorPtr,
739
+ data->msgText, data->buff_length, data->text_length_ptr );
740
+ #else
741
+ return SQLGetDiagRec(data->hType, data->handle, data->recNum, data->SQLState, data->NativeErrorPtr,
742
+ data->msgText, data->buff_length, data->text_length_ptr );
743
+ #endif
744
+ }
745
+
746
+ /*
747
+ This function calls SQLSetStmtAttr cli call to set attributes related to a statement
748
+ */
749
+ int _ruby_ibm_db_SQLSetStmtAttr_helper(set_handle_attr_args *data) {
750
+ #ifndef UNICODE_SUPPORT_VERSION
751
+ return SQLSetStmtAttr( (SQLHSTMT) *(data->handle), data->attribute, data->valuePtr, data->strLength );
752
+ #else
753
+ return SQLSetStmtAttrW( (SQLHSTMT) *(data->handle), data->attribute, data->valuePtr, data->strLength );
754
+ #endif
755
+ }
756
+
757
+ /*
758
+ This function calls SQLSetConnectAttr cli call to set attributes that govern aspects of connections
759
+ */
760
+ int _ruby_ibm_db_SQLSetConnectAttr_helper(set_handle_attr_args *data) {
761
+ #ifndef UNICODE_SUPPORT_VERSION
762
+ return SQLSetConnectAttr( (SQLHDBC) *(data->handle), data->attribute, data->valuePtr, data->strLength );
763
+ #else
764
+ return SQLSetConnectAttrW( (SQLHDBC) *(data->handle), data->attribute, data->valuePtr, data->strLength );
765
+ #endif
766
+ }
767
+
768
+ /*
769
+ This function calls SQLSetEnvAttr cli call to set an environment attribute
770
+ */
771
+ int _ruby_ibm_db_SQLSetEnvAttr_helper(set_handle_attr_args *data) {
772
+ return SQLSetEnvAttr( (SQLHENV) *(data->handle), data->attribute, data->valuePtr, data->strLength);
773
+ }
774
+
775
+ /*
776
+ This function calls SQLGetStmtAttr cli call to set an environment attribute
777
+
778
+ The unicode equivalent of SQLGetStmtAttr is not used because the attributes being retrieved currently are not of type char or binary (SQL_IS_INTEGER). If support for retrieving a string type is provided then use the SQLGetStmtAttrW function accordingly
779
+ In get_last_serial_id although we are retrieving a char type, it is converted back to an integer (atoi). The char to integer conversion function in unicode equivalent will be more complicated and is unnecessary for this case.
780
+
781
+ */
782
+ int _ruby_ibm_db_SQLGetStmtAttr_helper(get_handle_attr_args *data) {
783
+ return SQLGetStmtAttr( (SQLHSTMT) *(data->handle), data->attribute, data->valuePtr,
784
+ data->buff_length, data->out_length);
785
+ }
786
+
787
+ /*
788
+ This function calls SQLGetConnectAttr cli call to set an environment attribute
789
+ */
790
+ int _ruby_ibm_db_SQLGetConnectAttr_helper(get_handle_attr_args *data) {
791
+ #ifndef UNICODE_SUPPORT_VERSION
792
+ return SQLGetConnectAttr( (SQLHDBC) *(data->handle), data->attribute, data->valuePtr,
793
+ data->buff_length, data->out_length);
794
+ #else
795
+ return SQLGetConnectAttrW( (SQLHDBC) *(data->handle), data->attribute, data->valuePtr,
796
+ data->buff_length, data->out_length);
797
+ #endif
798
+ }
799
+
800
+ /*
801
+ This function calls SQLBindFileToParam cli call
802
+ */
803
+ int _ruby_ibm_db_SQLBindFileToParam_helper(stmt_handle *stmt_res, param_node *curr) {
804
+ int rc = 0;
805
+
806
+ stmt_res->is_executing = 1;
807
+
808
+ rc = SQLBindFileToParam( (SQLHSTMT)stmt_res->hstmt, curr->param_num,
809
+ curr->data_type, (SQLCHAR*)curr->svalue,
810
+ (SQLSMALLINT*)&(curr->ivalue), &(curr->file_options),
811
+ curr->ivalue, &(curr->bind_indicator) );
812
+
813
+ stmt_res->is_executing = 0;
814
+
815
+ return rc;
816
+ }
817
+
818
+ /*
819
+ This function calls SQLBindParameter cli call
820
+ */
821
+ int _ruby_ibm_db_SQLBindParameter_helper(bind_parameter_args *data) {
822
+ int rc = 0;
823
+
824
+ data->stmt_res->is_executing = 1;
825
+
826
+ rc = SQLBindParameter( (SQLHSTMT) data->stmt_res->hstmt, data->param_num, data->IOType, data->valueType,
827
+ data->paramType, data->colSize, data->decimalDigits, data->paramValPtr, data->buff_length,
828
+ data->out_length );
829
+
830
+ data->stmt_res->is_executing = 0;
831
+
832
+ return rc;
833
+ }
834
+
835
+ /*
836
+ Statement level thread unblock function. This fuction cancels a statement level SQL call issued when requested for,
837
+ allowing for a safe interrupt of the thread.
838
+ */
839
+ void _ruby_ibm_db_Statement_level_UBF(stmt_handle *stmt_res) {
840
+ int rc = 0;
841
+ if( stmt_res->is_executing == 1 ) {
842
+ rc = SQLCancel( (SQLHSTMT) stmt_res->hstmt );
843
+ }
844
+ return;
845
+ }