ibm_db 1.1.1-mswin32 → 1.5.0-mswin32

Sign up to get free protection for your applications and to get access to all the features.
data/ext/mkmf.log ADDED
@@ -0,0 +1,45 @@
1
+ have_library: checking for SQLConnect() in db2cli.lib... -------------------- yes
2
+
3
+ "cl -nologo -Feconftest -I. -Ic:/ruby/lib/ruby/1.8/i386-mswin32 -I. -Ic:/ruby/lib/ruby/1.8/i386-mswin32 -IC:/Progra~1/IBM/SQLLIB/include -MD -Zi -O2b2xg- -G6 conftest.c msvcrt-ruby18-static.lib db2cli.lib oldnames.lib user32.lib advapi32.lib ws2_32.lib -link -libpath:"." -libpath:"c:/ruby/lib" -libpath:"C:/Progra~1/IBM/SQLLIB/lib" -stack:0x2000000"
4
+ cl : Command line warning D9035 : option 'Og-' has been deprecated and will be removed in a future release
5
+ cl : Command line warning D9002 : ignoring unknown option '-G6'
6
+ conftest.c
7
+ conftest.c(7) : error C2065: 'SQLConnect' : undeclared identifier
8
+ checked program was:
9
+ /* begin */
10
+ 1: #define WIN32_LEAN_AND_MEAN
11
+ 2: #include <winsock2.h>
12
+ 3: #include <windows.h>
13
+ 4:
14
+ 5: /*top*/
15
+ 6: int main() { return 0; }
16
+ 7: int t() { void ((*volatile p)()); p = (void ((*)()))SQLConnect; return 0; }
17
+ /* end */
18
+
19
+ "cl -nologo -Feconftest -I. -Ic:/ruby/lib/ruby/1.8/i386-mswin32 -I. -Ic:/ruby/lib/ruby/1.8/i386-mswin32 -IC:/Progra~1/IBM/SQLLIB/include -MD -Zi -O2b2xg- -G6 conftest.c msvcrt-ruby18-static.lib db2cli.lib oldnames.lib user32.lib advapi32.lib ws2_32.lib -link -libpath:"." -libpath:"c:/ruby/lib" -libpath:"C:/Progra~1/IBM/SQLLIB/lib" -stack:0x2000000"
20
+ cl : Command line warning D9035 : option 'Og-' has been deprecated and will be removed in a future release
21
+ cl : Command line warning D9002 : ignoring unknown option '-G6'
22
+ conftest.c
23
+ checked program was:
24
+ /* begin */
25
+ 1: /*top*/
26
+ 2: int main() { return 0; }
27
+ 3: int t() { SQLConnect(); return 0; }
28
+ /* end */
29
+
30
+ --------------------
31
+
32
+ have_header: checking for gil_release_version... -------------------- no
33
+
34
+ "cl -nologo -E -I. -Ic:/ruby/lib/ruby/1.8/i386-mswin32 -I. -IC:/Progra~1/IBM/SQLLIB/include -MD -Zi -O2b2xg- -G6 conftest.c -P"
35
+ cl : Command line warning D9035 : option 'Og-' has been deprecated and will be removed in a future release
36
+ cl : Command line warning D9002 : ignoring unknown option '-G6'
37
+ conftest.c
38
+ conftest.c(1) : fatal error C1083: Cannot open include file: 'gil_release_version': No such file or directory
39
+ checked program was:
40
+ /* begin */
41
+ 1: #include <gil_release_version>
42
+ /* end */
43
+
44
+ --------------------
45
+
data/ext/ruby_ibm_db.h CHANGED
@@ -71,9 +71,15 @@
71
71
  /* strlen(" SQLCODE=") added in */
72
72
  #define DB2_MAX_ERR_MSG_LEN (SQL_MAX_MESSAGE_LENGTH + SQL_SQLSTATE_SIZE + 10)
73
73
 
74
- /* Used in _ruby_parse_options */
75
- #define DB2_ERRMSG 1
76
- #define DB2_ERR 2
74
+ /*Used to find the type of resource and the error type required*/
75
+ #define DB_ERRMSG 1
76
+ #define DB_ERR_STATE 2
77
+
78
+ #define DB_CONN 1
79
+ #define DB_STMT 2
80
+
81
+ #define CONN_ERROR 1
82
+ #define STMT_ERROR 2
77
83
 
78
84
  /* DB2 instance environment variable */
79
85
  #define DB2_VAR_INSTANCE "DB2INSTANCE="
@@ -92,9 +98,9 @@
92
98
  #endif
93
99
 
94
100
  /*fetch*/
95
- #define FETCH_INDEX 0x01
96
- #define FETCH_ASSOC 0x02
97
- #define FETCH_BOTH 0x03
101
+ #define FETCH_INDEX 0x01
102
+ #define FETCH_ASSOC 0x02
103
+ #define FETCH_BOTH 0x03
98
104
 
99
105
  /* Change column case */
100
106
  #define ATTR_CASE 3271982
@@ -122,6 +128,8 @@ enum
122
128
 
123
129
  void Init_ibm_db();
124
130
 
131
+ /* Function Declarations */
132
+
125
133
  VALUE ibm_db_connect(int argc, VALUE *argv, VALUE self);
126
134
  VALUE ibm_db_commit(int argc, VALUE *argv, VALUE self);
127
135
  VALUE ibm_db_pconnect(int argc, VALUE *argv, VALUE self);
@@ -149,6 +157,8 @@ VALUE ibm_db_prepare(int argc, VALUE *argv, VALUE self);
149
157
  VALUE ibm_db_execute(int argc, VALUE *argv, VALUE self);
150
158
  VALUE ibm_db_conn_errormsg(int argc, VALUE *argv, VALUE self);
151
159
  VALUE ibm_db_stmt_errormsg(int argc, VALUE *argv, VALUE self);
160
+ VALUE ibm_db_getErrormsg(int argc, VALUE *argv, VALUE self);
161
+ VALUE ibm_db_getErrorstate(int argc, VALUE *argv, VALUE self);
152
162
  VALUE ibm_db_conn_error(int argc, VALUE *argv, VALUE self);
153
163
  VALUE ibm_db_stmt_error(int argc, VALUE *argv, VALUE self);
154
164
  VALUE ibm_db_next_result(int argc, VALUE *argv, VALUE self);
@@ -202,7 +212,7 @@ struct _ibm_db_globals {
202
212
 
203
213
  #define IBM_DB_G(v) (ibm_db_globals->v)
204
214
 
205
- #endif /* RUBY_IBM_DB_H */
215
+ #endif /* RUBY_IBM_DB_H */
206
216
 
207
217
 
208
218
  /*
@@ -0,0 +1,629 @@
1
+ /*
2
+ +----------------------------------------------------------------------+
3
+ | Licensed Materials - Property of IBM |
4
+ | |
5
+ | (C) Copyright IBM Corporation 2009 |
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
+ return SQLConnect( (SQLHDBC)*(data->hdbc), (SQLCHAR *)data->database,
33
+ (SQLSMALLINT)data->database_len, (SQLCHAR *)data->uid, (SQLSMALLINT)data->uid_len,
34
+ (SQLCHAR *)data->password, (SQLSMALLINT)data->password_len );
35
+ } else {
36
+ return SQLDriverConnect( (SQLHDBC) *(data->hdbc), (SQLHWND)NULL,
37
+ (SQLCHAR*)data->database, SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPROMPT );
38
+ }
39
+ }
40
+
41
+ /*
42
+ This function issues SQLDisconnect to disconnect from the Dataserver
43
+ */
44
+ int _ruby_ibm_db_SQLDisconnect_helper(SQLHANDLE *hdbc) {
45
+ return SQLDisconnect( (SQLHDBC) *hdbc );
46
+ }
47
+
48
+ /*
49
+ Connection level Unblock function. This function is called when a thread interruput is issued while executing a
50
+ connection level SQL call
51
+ */
52
+ void _ruby_ibm_db_Connection_level_UBF(void *data) {
53
+ return;
54
+ }
55
+
56
+ /*
57
+ This function will commit and end the inprogress transaction by issuing a SQLCommit
58
+ */
59
+ int _ruby_ibm_db_SQLEndTran(end_tran_args *endtran_args) {
60
+ return SQLEndTran( endtran_args->handleType, *(endtran_args->hdbc), endtran_args->completionType );
61
+ }
62
+
63
+ /*
64
+ This function call the SQLDescribeParam cli call to get the description of the parameter in the sql specified
65
+ */
66
+ int _ruby_ibm_db_SQLDescribeParam_helper(describeparam_args *data) {
67
+ int rc = 0;
68
+ data->stmt_res->is_executing = 1;
69
+
70
+ rc = SQLDescribeParam( (SQLHSTMT) data->stmt_res->hstmt, (SQLUSMALLINT)data->param_no, &(data->sql_data_type),
71
+ &(data->sql_precision), &(data->sql_scale), &(data->sql_nullable) );
72
+
73
+ data->stmt_res->is_executing = 0;
74
+
75
+ return rc;
76
+ }
77
+
78
+ /*
79
+ This function call the SQLDescribeCol cli call to get the description of the parameter in the sql specified
80
+ */
81
+ int _ruby_ibm_db_SQLDescribeCol_helper(describecol_args *data) {
82
+ int i = data->col_no - 1;
83
+ int rc = 0;
84
+
85
+ data->stmt_res->is_executing = 1;
86
+
87
+ rc = SQLDescribeCol( (SQLHSTMT)data->stmt_res->hstmt, (SQLSMALLINT)(data->col_no),
88
+ data->stmt_res->column_info[i].name, data->buff_length, &(data->name_length),
89
+ &(data->stmt_res->column_info[i].type), &(data->stmt_res->column_info[i].size),
90
+ &(data->stmt_res->column_info[i].scale), &(data->stmt_res->column_info[i].nullable) );
91
+
92
+ data->stmt_res->is_executing = 0;
93
+
94
+ return rc;
95
+ }
96
+
97
+ /*
98
+ This function call the SQLBindCol cli call to get the description of the parameter in the sql specified
99
+ */
100
+ int _ruby_ibm_db_SQLBindCol_helper(bind_col_args *data) {
101
+ int rc = 0;
102
+
103
+ data->stmt_res->is_executing = 1;
104
+
105
+ rc = SQLBindCol( (SQLHSTMT) data->stmt_res->hstmt, (SQLUSMALLINT)(data->col_num),
106
+ data->TargetType, data->TargetValuePtr, data->buff_length,
107
+ data->out_length );
108
+
109
+ data->stmt_res->is_executing = 0;
110
+
111
+ return rc;
112
+ }
113
+
114
+ /*
115
+ This function calls SQLColumnPrivileges cli call to get the list of columns and the associated privileges
116
+ */
117
+ int _ruby_ibm_db_SQLColumnPrivileges_helper(metadata_args *data) {
118
+ int rc = 0;
119
+
120
+ data->stmt_res->is_executing = 1;
121
+
122
+ rc = SQLColumnPrivileges( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, SQL_NTS,
123
+ data->owner,SQL_NTS, data->table_name,SQL_NTS, data->column_name,SQL_NTS );
124
+
125
+ data->stmt_res->is_executing = 0;
126
+
127
+ return rc;
128
+
129
+ }
130
+
131
+ /*
132
+ This function calls SQLColumns cli call to get the list of columns and the associated metadata of the table
133
+ */
134
+ int _ruby_ibm_db_SQLColumns_helper(metadata_args *data) {
135
+ int rc = 0;
136
+
137
+ data->stmt_res->is_executing = 1;
138
+
139
+ rc = SQLColumns( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, SQL_NTS,
140
+ data->owner,SQL_NTS, data->table_name,SQL_NTS, data->column_name,SQL_NTS );
141
+
142
+ data->stmt_res->is_executing = 0;
143
+
144
+ return rc;
145
+ }
146
+
147
+ /*
148
+ This function calls SQLPrimaryKeys cli call to get the list of primay key columns and the associated metadata
149
+ */
150
+ int _ruby_ibm_db_SQLPrimaryKeys_helper(metadata_args *data) {
151
+ int rc = 0;
152
+
153
+ data->stmt_res->is_executing = 1;
154
+
155
+ rc = SQLPrimaryKeys( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, SQL_NTS,
156
+ data->owner, SQL_NTS, data->table_name,SQL_NTS );
157
+
158
+ data->stmt_res->is_executing = 0;
159
+
160
+ return rc;
161
+ }
162
+
163
+ /*
164
+ This function calls SQLForeignKeys cli call to get the list of primay key columns and the associated metadata
165
+ */
166
+ int _ruby_ibm_db_SQLForeignKeys_helper(metadata_args *data) {
167
+ int rc = 0;
168
+
169
+ data->stmt_res->is_executing = 1;
170
+
171
+ rc = SQLForeignKeys( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, SQL_NTS,
172
+ data->owner, SQL_NTS, data->table_name ,SQL_NTS, NULL, SQL_NTS,
173
+ NULL, SQL_NTS, NULL, SQL_NTS );
174
+
175
+ data->stmt_res->is_executing = 0;
176
+
177
+ return rc;
178
+ }
179
+
180
+ /*
181
+ This function calls SQLProcedureColumns cli call to get the list of parameters
182
+ and associated metadata of the stored procedure
183
+ */
184
+ int _ruby_ibm_db_SQLProcedureColumns_helper(metadata_args *data) {
185
+ int rc = 0;
186
+
187
+ data->stmt_res->is_executing = 1;
188
+
189
+ rc = SQLProcedureColumns( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, SQL_NTS, data->owner,
190
+ SQL_NTS, data->proc_name, SQL_NTS, data->column_name, SQL_NTS );
191
+
192
+ data->stmt_res->is_executing = 0;
193
+
194
+ return rc;
195
+ }
196
+
197
+ /*
198
+ This function calls SQLProcedures cli call to get the list of stored procedures
199
+ and associated metadata of the stored procedure
200
+ */
201
+ int _ruby_ibm_db_SQLProcedures_helper(metadata_args *data) {
202
+ int rc = 0;
203
+
204
+ data->stmt_res->is_executing = 1;
205
+
206
+ rc = SQLProcedures( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, SQL_NTS, data->owner,
207
+ SQL_NTS, data->proc_name, SQL_NTS );
208
+
209
+ data->stmt_res->is_executing = 0;
210
+
211
+ return rc;
212
+ }
213
+
214
+ /*
215
+ This function calls SQLSpecialColumns cli call to get the metadata related to the special columns
216
+ (Unique index or primary key column) and associated metadata
217
+ */
218
+ int _ruby_ibm_db_SQLSpecialColumns_helper(metadata_args *data) {
219
+ int rc = 0;
220
+
221
+ data->stmt_res->is_executing = 1;
222
+
223
+ rc = SQLSpecialColumns( (SQLHSTMT) data->stmt_res->hstmt,SQL_BEST_ROWID, data->qualifier, SQL_NTS,
224
+ data->owner,SQL_NTS, data->table_name,SQL_NTS,(SQLUSMALLINT)data->scope,SQL_NULLABLE );
225
+
226
+ data->stmt_res->is_executing = 0;
227
+
228
+ return rc;
229
+ }
230
+
231
+ /*
232
+ This function calls SQLStatistics cli call to get the index information for a given table.
233
+ */
234
+ int _ruby_ibm_db_SQLStatistics_helper(metadata_args *data) {
235
+ int rc = 0;
236
+
237
+ data->stmt_res->is_executing = 1;
238
+
239
+ rc = SQLStatistics( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, SQL_NTS, data->owner,
240
+ SQL_NTS, data->table_name, SQL_NTS, (SQLUSMALLINT)data->unique, SQL_QUICK );
241
+
242
+ data->stmt_res->is_executing = 0;
243
+
244
+ return rc;
245
+ }
246
+
247
+ /*
248
+ This function calls SQLTablePrivileges cli call to retrieve list of tables and
249
+ the asscociated privileges for each table.
250
+ */
251
+ int _ruby_ibm_db_SQLTablePrivileges_helper(metadata_args *data) {
252
+ int rc = 0;
253
+
254
+ data->stmt_res->is_executing = 1;
255
+
256
+ rc = SQLTablePrivileges( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, SQL_NTS, data->owner,
257
+ SQL_NTS, data->table_name, SQL_NTS );
258
+
259
+ data->stmt_res->is_executing = 0;
260
+
261
+ return rc;
262
+ }
263
+
264
+ /*
265
+ This function calls SQLTables cli call to retrieve list of tables in the specified schema and
266
+ the asscociated metadata for each table.
267
+ */
268
+ int _ruby_ibm_db_SQLTables_helper(metadata_args *data) {
269
+ int rc = 0;
270
+
271
+ data->stmt_res->is_executing = 1;
272
+
273
+ rc = SQLTables( (SQLHSTMT) data->stmt_res->hstmt, data->qualifier, SQL_NTS, data->owner,
274
+ SQL_NTS, data->table_name, SQL_NTS, data->table_type, SQL_NTS );
275
+
276
+ data->stmt_res->is_executing = 0;
277
+
278
+ return rc;
279
+ }
280
+
281
+ /*
282
+ This function calls SQLExecDirect cli call to execute a statement directly
283
+ */
284
+ int _ruby_ibm_db_SQLExecDirect_helper(exec_cum_prepare_args *data) {
285
+ int rc = 0;
286
+
287
+ data->stmt_res->is_executing = 1;
288
+
289
+ rc = SQLExecDirect( (SQLHSTMT) data->stmt_res->hstmt, data->stmt_string, (SQLINTEGER)data->stmt_string_len );
290
+
291
+ data->stmt_res->is_executing = 0;
292
+
293
+ return rc;
294
+ }
295
+
296
+ /*
297
+ This function calls SQLPrepare cli call to prepare the given statement
298
+ */
299
+ int _ruby_ibm_db_SQLPrepare_helper(exec_cum_prepare_args *data) {
300
+ int rc = 0;
301
+
302
+ data->stmt_res->is_executing = 1;
303
+
304
+ rc = SQLPrepare( (SQLHSTMT) data->stmt_res->hstmt, data->stmt_string, (SQLINTEGER)data->stmt_string_len );
305
+
306
+ data->stmt_res->is_executing = 0;
307
+
308
+ return rc;
309
+ }
310
+
311
+ /*
312
+ This function calls SQLFreeStmt to end processing on the statement referenced by statement handle
313
+ */
314
+ int _ruby_ibm_db_SQLFreeStmt_helper(free_stmt_args *data) {
315
+ int rc = 0;
316
+
317
+ data->stmt_res->is_executing = 1;
318
+
319
+ SQLFreeStmt((SQLHSTMT)data->stmt_res->hstmt, data->option );
320
+
321
+ data->stmt_res->is_executing = 0;
322
+
323
+ return rc;
324
+ }
325
+
326
+ /*
327
+ This function calls SQLExecute cli call to execute the prepared
328
+ */
329
+ int _ruby_ibm_db_SQLExecute_helper(stmt_handle *stmt_res) {
330
+ int rc = 0;
331
+
332
+ stmt_res->is_executing = 1;
333
+
334
+ rc = SQLExecute( (SQLHSTMT) stmt_res->hstmt );
335
+
336
+ stmt_res->is_executing = 0;
337
+
338
+ return rc;
339
+ }
340
+
341
+ /*
342
+ This function calls SQLParamData cli call to read if there is still data to be sent
343
+ */
344
+ int _ruby_ibm_db_SQLParamData_helper(param_cum_put_data_args *data) {
345
+ int rc = 0;
346
+
347
+ data->stmt_res->is_executing = 1;
348
+
349
+ rc = SQLParamData( (SQLHSTMT) data->stmt_res->hstmt, (SQLPOINTER *) &(data->valuePtr) );
350
+
351
+ data->stmt_res->is_executing = 0;
352
+
353
+ return rc;
354
+ }
355
+
356
+ /*
357
+ This function calls SQLColAttributes cli call to get the specified attribute of the column in result set
358
+ */
359
+ int _ruby_ibm_db_SQLColAttributes_helper(col_attr_args *data) {
360
+ int rc = 0;
361
+
362
+ data->stmt_res->is_executing = 1;
363
+
364
+ rc = SQLColAttributes( (SQLHSTMT) data->stmt_res->hstmt, data->col_num,
365
+ data->FieldIdentifier, NULL, 0, NULL, &(data->num_attr) );
366
+
367
+ data->stmt_res->is_executing = 0;
368
+
369
+ return rc;
370
+ }
371
+
372
+ /*
373
+ This function calls SQLPutData cli call to supply parameter data value
374
+ */
375
+ int _ruby_ibm_db_SQLPutData_helper(param_cum_put_data_args *data) {
376
+ int rc = 0;
377
+
378
+ data->stmt_res->is_executing = 1;
379
+
380
+ rc = SQLPutData( (SQLHSTMT) data->stmt_res->hstmt, (SQLPOINTER)(((param_node*)(data->valuePtr))->svalue),
381
+ ((param_node*)(data->valuePtr))->ivalue );
382
+
383
+ data->stmt_res->is_executing = 0;
384
+
385
+ return rc;
386
+ }
387
+
388
+ /*
389
+ This function calls SQLGetData cli call to retrieve data for a single column
390
+ */
391
+ int _ruby_ibm_db_SQLGetData_helper(get_data_args *data) {
392
+ int rc = 0;
393
+
394
+ data->stmt_res->is_executing = 1;
395
+
396
+ rc = SQLGetData( (SQLHSTMT) data->stmt_res->hstmt, data->col_num, data->targetType, data->buff,
397
+ data->buff_length, data->out_length);
398
+
399
+ data->stmt_res->is_executing = 0;
400
+
401
+ return rc;
402
+ }
403
+
404
+ /*
405
+ This function calls SQLGetLength cli call to retrieve the length of the lob value
406
+ */
407
+ int _ruby_ibm_db_SQLGetLength_helper(get_length_args *data) {
408
+ int col_num = data->col_num;
409
+ int rc = 0;
410
+
411
+ data->stmt_res->is_executing = 1;
412
+
413
+ rc = SQLGetLength( (SQLHSTMT) *( data->new_hstmt ), data->stmt_res->column_info[col_num-1].loc_type,
414
+ data->stmt_res->column_info[col_num-1].lob_loc, data->sLength,
415
+ &(data->stmt_res->column_info[col_num-1].loc_ind) );
416
+
417
+ data->stmt_res->is_executing = 0;
418
+
419
+ return rc;
420
+ }
421
+
422
+ /*
423
+ This function calls SQLGetSubString cli call to retrieve portion of the lob value
424
+ */
425
+ int _ruby_ibm_db_SQLGetSubString_helper(get_subString_args *data) {
426
+ int col_num = data->col_num;
427
+ int rc = 0;
428
+
429
+ data->stmt_res->is_executing = 1;
430
+
431
+ rc = SQLGetSubString( (SQLHSTMT) *( data->new_hstmt ), data->stmt_res->column_info[col_num-1].loc_type,
432
+ data->stmt_res->column_info[col_num-1].lob_loc, 1, data->forLength, data->targetCType,
433
+ data->buffer, data->buff_length, data->out_length,
434
+ &(data->stmt_res->column_info[col_num-1].loc_ind) );
435
+
436
+ data->stmt_res->is_executing = 0;
437
+
438
+ return rc;
439
+ }
440
+
441
+ /*
442
+ This function calls SQLNextResult cli call to fetch the multiple result sets that might be returned by a stored Proc
443
+ */
444
+ int _ruby_ibm_db_SQLNextResult_helper(next_result_args *data) {
445
+ int rc = 0;
446
+
447
+ data->stmt_res->is_executing = 1;
448
+
449
+ rc = SQLNextResult( (SQLHSTMT) data->stmt_res->hstmt, (SQLHSTMT) *(data->new_hstmt) );
450
+
451
+ data->stmt_res->is_executing = 0;
452
+
453
+ return rc;
454
+ }
455
+
456
+ /*
457
+ This function calls SQLFetchScroll cli call to fetch the specified rowset of data from result
458
+ */
459
+ int _ruby_ibm_db_SQLFetchScroll_helper(fetch_data_args *data) {
460
+ int rc = 0;
461
+
462
+ data->stmt_res->is_executing = 1;
463
+
464
+ rc = SQLFetchScroll( (SQLHSTMT) data->stmt_res->hstmt, data->fetchOrientation, data->fetchOffset);
465
+
466
+ data->stmt_res->is_executing = 0;
467
+
468
+ return rc;
469
+ }
470
+
471
+ /*
472
+ This function calls SQLFetch cli call to advance the cursor to
473
+ the next row of the result set, and retrieves any bound columns
474
+ */
475
+ int _ruby_ibm_db_SQLFetch_helper(fetch_data_args *data) {
476
+ int rc = 0;
477
+
478
+ data->stmt_res->is_executing = 1;
479
+
480
+ rc = SQLFetch( (SQLHSTMT) data->stmt_res->hstmt );
481
+
482
+ data->stmt_res->is_executing = 0;
483
+
484
+ return rc;
485
+ }
486
+
487
+ /*
488
+ This function calls SQLNumResultCols cli call to fetch the number of fields contained in a result set
489
+ */
490
+ int _ruby_ibm_db_SQLNumResultCols_helper(row_col_count_args *data) {
491
+ int rc = 0;
492
+
493
+ data->stmt_res->is_executing = 1;
494
+
495
+ rc = SQLNumResultCols( (SQLHSTMT) data->stmt_res->hstmt, (SQLSMALLINT*) &(data->count) );
496
+
497
+ data->stmt_res->is_executing = 0;
498
+
499
+ return rc;
500
+ }
501
+
502
+ /*
503
+ This function calls SQLNumParams cli call to fetch the number of parameter markers in an SQL statement
504
+ */
505
+ int _ruby_ibm_db_SQLNumParams_helper(row_col_count_args *data) {
506
+ int rc = 0;
507
+
508
+ data->stmt_res->is_executing = 1;
509
+
510
+ rc = SQLNumParams( (SQLHSTMT) data->stmt_res->hstmt, (SQLSMALLINT*) &(data->count) );
511
+
512
+ data->stmt_res->is_executing = 0;
513
+
514
+ return rc;
515
+ }
516
+
517
+ /*
518
+ This function calls SQLRowCount cli call to fetch the number of rows affected by the SQL statement
519
+ */
520
+ int _ruby_ibm_db_SQLRowCount_helper(row_col_count_args *data) {
521
+ int rc = 0;
522
+
523
+ data->stmt_res->is_executing = 1;
524
+
525
+ rc = SQLRowCount( (SQLHSTMT) data->stmt_res->hstmt, (SQLLEN*) &(data->count) );
526
+
527
+ data->stmt_res->is_executing = 0;
528
+
529
+ return rc;
530
+ }
531
+
532
+ /*
533
+ This function calls SQLGetInfo cli call to get general information about DBMS, which the app is connected to
534
+ */
535
+ int _ruby_ibm_db_SQLGetInfo_helper(get_info_args *data) {
536
+ return SQLGetInfo( data->conn_res->hdbc, data->infoType, data->infoValue, data->buff_length, data->out_length);
537
+ }
538
+
539
+ /*
540
+ This function calls SQLGetDiagRec cli call to get the current values of a diagnostic record that contains error
541
+ */
542
+ int _ruby_ibm_db_SQLGetDiagRec_helper(get_diagRec_args *data) {
543
+ return SQLGetDiagRec(data->hType, data->handle, data->recNum, data->SQLState, data->NativeErrorPtr,
544
+ data->msgText, data->buff_length, data->text_length_ptr );
545
+ }
546
+
547
+ /*
548
+ This function calls SQLSetStmtAttr cli call to set attributes related to a statement
549
+ */
550
+ int _ruby_ibm_db_SQLSetStmtAttr_helper(set_handle_attr_args *data) {
551
+ return SQLSetStmtAttr( (SQLHSTMT) *(data->handle), data->attribute, data->valuePtr, data->strLength );
552
+ }
553
+
554
+ /*
555
+ This function calls SQLSetConnectAttr cli call to set attributes that govern aspects of connections
556
+ */
557
+ int _ruby_ibm_db_SQLSetConnectAttr_helper(set_handle_attr_args *data) {
558
+ return SQLSetConnectAttr( (SQLHDBC) *(data->handle), data->attribute, data->valuePtr, data->strLength );
559
+ }
560
+
561
+ /*
562
+ This function calls SQLSetEnvAttr cli call to set an environment attribute
563
+ */
564
+ int _ruby_ibm_db_SQLSetEnvAttr_helper(set_handle_attr_args *data) {
565
+ return SQLSetEnvAttr( (SQLHENV) *(data->handle), data->attribute, data->valuePtr, data->strLength);
566
+ }
567
+
568
+ /*
569
+ This function calls SQLGetStmtAttr cli call to set an environment attribute
570
+ */
571
+ int _ruby_ibm_db_SQLGetStmtAttr_helper(get_handle_attr_args *data) {
572
+ return SQLGetStmtAttr( (SQLHSTMT) *(data->handle), data->attribute, data->valuePtr,
573
+ data->buff_length, data->out_length);
574
+ }
575
+
576
+ /*
577
+ This function calls SQLGetConnectAttr cli call to set an environment attribute
578
+ */
579
+ int _ruby_ibm_db_SQLGetConnectAttr_helper(get_handle_attr_args *data) {
580
+ return SQLGetConnectAttr( (SQLHDBC) *(data->handle), data->attribute, data->valuePtr,
581
+ data->buff_length, data->out_length);
582
+ }
583
+
584
+ /*
585
+ This function calls SQLBindFileToParam cli call
586
+ */
587
+ int _ruby_ibm_db_SQLBindFileToParam_helper(stmt_handle *stmt_res, param_node *curr) {
588
+ int rc = 0;
589
+
590
+ stmt_res->is_executing = 1;
591
+
592
+ rc = SQLBindFileToParam( (SQLHSTMT)stmt_res->hstmt, curr->param_num,
593
+ curr->data_type, (SQLCHAR*)curr->svalue,
594
+ (SQLSMALLINT*)&(curr->ivalue), &(curr->file_options),
595
+ curr->ivalue, &(curr->bind_indicator) );
596
+
597
+ stmt_res->is_executing = 0;
598
+
599
+ return rc;
600
+ }
601
+
602
+ /*
603
+ This function calls SQLBindParameter cli call
604
+ */
605
+ int _ruby_ibm_db_SQLBindParameter_helper(bind_parameter_args *data) {
606
+ int rc = 0;
607
+
608
+ data->stmt_res->is_executing = 1;
609
+
610
+ rc = SQLBindParameter( (SQLHSTMT) data->stmt_res->hstmt, data->param_num, data->IOType, data->valueType,
611
+ data->paramType, data->colSize, data->decimalDigits, data->paramValPtr, data->buff_length,
612
+ data->out_length );
613
+
614
+ data->stmt_res->is_executing = 0;
615
+
616
+ return rc;
617
+ }
618
+
619
+ /*
620
+ Statement level thread unblock function. This fuction cancels a statement level SQL call issued when requested for,
621
+ allowing for a safe interrupt of the thread.
622
+ */
623
+ void _ruby_ibm_db_Statement_level_UBF(stmt_handle *stmt_res) {
624
+ int rc = 0;
625
+ if( stmt_res->is_executing == 1 ) {
626
+ rc = SQLCancel( (SQLHSTMT) stmt_res->hstmt );
627
+ }
628
+ return;
629
+ }