advantage 0.1.0-x86-mingw32 → 0.1.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/Makefile +17 -13
- data/ext/ace.h +6 -1
- data/ext/adscapidll.o +0 -0
- data/ext/advantage.c +926 -882
- data/ext/advantage.o +0 -0
- data/ext/advantage.so +0 -0
- data/ext/dbcapi.cpp +1780 -0
- data/ext/dbcapi.o +0 -0
- data/lib/advantage.so +0 -0
- metadata +5 -3
data/ext/Makefile
CHANGED
@@ -61,18 +61,19 @@ LIBRUBY = lib$(RUBY_SO_NAME).dll.a
|
|
61
61
|
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
62
62
|
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
|
63
63
|
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
|
64
|
-
|
65
|
-
|
64
|
+
empty =
|
65
|
+
OUTFLAG = -o $(empty)
|
66
|
+
COUTFLAG = -o $(empty)
|
66
67
|
|
67
68
|
RUBY_EXTCONF_H =
|
68
69
|
cflags = $(optflags) $(debugflags) $(warnflags)
|
69
70
|
optflags = -O3 -fno-omit-frame-pointer
|
70
71
|
debugflags = -g
|
71
|
-
warnflags = -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration
|
72
|
+
warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration
|
72
73
|
CFLAGS = $(cflags) $(ARCH_FLAG)
|
73
74
|
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
|
74
75
|
DEFS =
|
75
|
-
CPPFLAGS =
|
76
|
+
CPPFLAGS = -DFD_SETSIZE=2048 $(DEFS) $(cppflags)
|
76
77
|
CXXFLAGS = $(CFLAGS) $(cxxflags)
|
77
78
|
ldflags = -L.
|
78
79
|
dldflags = -Wl,--enable-auto-image-base,--enable-auto-import $(DEFFILE)
|
@@ -99,6 +100,7 @@ INSTALL = /usr/bin/install -c
|
|
99
100
|
INSTALL_PROG = $(INSTALL) -m 0755
|
100
101
|
INSTALL_DATA = $(INSTALL) -m 644
|
101
102
|
COPY = cp
|
103
|
+
TOUCH = exit >
|
102
104
|
|
103
105
|
#### End of system configuration section. ####
|
104
106
|
|
@@ -116,9 +118,9 @@ extout =
|
|
116
118
|
extout_prefix =
|
117
119
|
target_prefix =
|
118
120
|
LOCAL_LIBS =
|
119
|
-
LIBS = $(LIBRUBYARG_SHARED) -lshell32 -lws2_32 -limagehlp
|
120
|
-
SRCS = adscapidll.c advantage.c
|
121
|
-
OBJS = adscapidll.o advantage.o
|
121
|
+
LIBS = $(LIBRUBYARG_SHARED) -lshell32 -lws2_32 -limagehlp -lshlwapi
|
122
|
+
SRCS = adscapidll.c advantage.c dbcapi.cpp
|
123
|
+
OBJS = adscapidll.o advantage.o dbcapi.o
|
122
124
|
TARGET = advantage
|
123
125
|
DLLIB = $(TARGET).so
|
124
126
|
EXTSTATIC =
|
@@ -157,19 +159,21 @@ distclean: clean distclean-so distclean-rb-default distclean-rb
|
|
157
159
|
realclean: distclean
|
158
160
|
install: install-so install-rb
|
159
161
|
|
160
|
-
install-so: $(RUBYARCHDIR)
|
161
162
|
install-so: $(RUBYARCHDIR)/$(DLLIB)
|
162
163
|
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
|
163
|
-
|
164
|
+
-$(Q)$(MAKEDIRS) $(@D)
|
164
165
|
$(INSTALL_PROG) $(DLLIB) $(@D)
|
166
|
+
clean-static::
|
167
|
+
-$(Q)$(RM) $(STATIC_LIB)
|
165
168
|
install-rb: pre-install-rb install-rb-default
|
166
169
|
install-rb-default: pre-install-rb-default
|
167
170
|
pre-install-rb: Makefile
|
168
171
|
pre-install-rb-default: Makefile
|
169
172
|
pre-install-rb-default:
|
170
173
|
$(ECHO) installing default advantage libraries
|
171
|
-
|
172
|
-
$(Q) $(MAKEDIRS)
|
174
|
+
./.RUBYARCHDIR.time:
|
175
|
+
$(Q) $(MAKEDIRS) $(RUBYARCHDIR)
|
176
|
+
$(Q) $(TOUCH) $@
|
173
177
|
|
174
178
|
site-install: site-install-so site-install-rb
|
175
179
|
site-install-so: install-so
|
@@ -203,8 +207,8 @@ site-install-rb: install-rb
|
|
203
207
|
|
204
208
|
$(DLLIB): $(DEFFILE) $(OBJS) Makefile
|
205
209
|
$(ECHO) linking shared-object $(DLLIB)
|
206
|
-
|
207
|
-
$(Q) $(
|
210
|
+
-$(Q)$(RM) $(@)
|
211
|
+
$(Q) $(LDSHAREDXX) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
208
212
|
|
209
213
|
|
210
214
|
|
data/ext/ace.h
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
// cost of servicing or repair. No oral or written information or advice given
|
20
20
|
// by an Extended Systems Inc. representative shall create a warranty or in any
|
21
21
|
// way increase the scope of this warranty.
|
22
|
-
// LIBACE_VERSION 10
|
22
|
+
// LIBACE_VERSION 11.10
|
23
23
|
/*******************************************************************************
|
24
24
|
* Source File : ace.h
|
25
25
|
* Description : This is the main header file for the Advantage Client
|
@@ -1503,6 +1503,11 @@ typedef struct _ADD_FIELD_DESC_
|
|
1503
1503
|
#define ADS_CIPHER_SUITE_STRING_AES128 "AES128-SHA"
|
1504
1504
|
#define ADS_CIPHER_SUITE_STRING_AES256 "AES256-SHA"
|
1505
1505
|
|
1506
|
+
/*
|
1507
|
+
* System alias which always resolves to the root dictionary
|
1508
|
+
* defined by ADS_ROOT_DICTIONARY server configuration setting
|
1509
|
+
*/
|
1510
|
+
#define ADS_ROOT_DD_ALIAS "__rootdd"
|
1506
1511
|
|
1507
1512
|
/* Options for the AdsGetKeyFilter */
|
1508
1513
|
#define ADS_FILTER_FORMAT_ODATA 0x00000001
|
data/ext/adscapidll.o
CHANGED
Binary file
|
data/ext/advantage.c
CHANGED
@@ -21,12 +21,13 @@
|
|
21
21
|
#include "ruby.h"
|
22
22
|
#include "adscapidll.h"
|
23
23
|
|
24
|
-
const char* VERSION = "0.1.
|
24
|
+
const char* VERSION = "0.1.1";
|
25
25
|
|
26
|
-
typedef struct imp_drh_st
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
typedef struct imp_drh_st
|
27
|
+
{
|
28
|
+
AdvantageInterface api;
|
29
|
+
void *adscapi_context;
|
30
|
+
} imp_drh_st;
|
30
31
|
|
31
32
|
// Defining the Ruby Modules
|
32
33
|
static VALUE mAdvantage;
|
@@ -36,163 +37,166 @@ static VALUE cAdvantageInterface;
|
|
36
37
|
// Defining binder for DBCAPI types
|
37
38
|
static VALUE cA_ads_connection;
|
38
39
|
static VALUE cA_ads_data_value;
|
39
|
-
static VALUE cA_ads_stmt;
|
40
40
|
static VALUE cA_ads_bind_param;
|
41
41
|
static VALUE cA_ads_bind_param_info;
|
42
42
|
|
43
43
|
// This function is called when the module is first loaded by ruby.
|
44
44
|
// The name of this function MUST match be Init_<modulename>.
|
45
|
-
void Init_advantage();
|
45
|
+
void Init_advantage( );
|
46
46
|
|
47
47
|
// Wrapper functions for the DBICAPI functions
|
48
48
|
|
49
49
|
static VALUE
|
50
|
-
static_API_ads_initialize_interface(VALUE module, VALUE imp_drh);
|
50
|
+
static_API_ads_initialize_interface( VALUE module, VALUE imp_drh );
|
51
51
|
|
52
52
|
static VALUE
|
53
|
-
static_API_ads_finalize_interface(VALUE module, VALUE imp_drh);
|
53
|
+
static_API_ads_finalize_interface( VALUE module, VALUE imp_drh );
|
54
54
|
|
55
55
|
static VALUE
|
56
|
-
static_AdvantageInterface_alloc(VALUE class);
|
56
|
+
static_AdvantageInterface_alloc( VALUE class );
|
57
57
|
|
58
58
|
static VALUE
|
59
|
-
static_AdvantageInterface_ads_init(VALUE class);
|
59
|
+
static_AdvantageInterface_ads_init( VALUE class );
|
60
60
|
|
61
61
|
static VALUE
|
62
|
-
static_AdvantageInterface_ads_new_connection(VALUE class);
|
62
|
+
static_AdvantageInterface_ads_new_connection( VALUE class );
|
63
63
|
|
64
64
|
static VALUE
|
65
|
-
static_AdvantageInterface_ads_client_version(VALUE imp_drh);
|
65
|
+
static_AdvantageInterface_ads_client_version( VALUE imp_drh );
|
66
66
|
|
67
67
|
static VALUE
|
68
|
-
static_AdvantageInterface_ads_connect(VALUE imp_drh, VALUE ads_conn, VALUE str);
|
68
|
+
static_AdvantageInterface_ads_connect( VALUE imp_drh, VALUE ads_conn, VALUE str );
|
69
69
|
|
70
70
|
static VALUE
|
71
|
-
static_AdvantageInterface_ads_disconnect(VALUE imp_drh, VALUE ads_conn);
|
71
|
+
static_AdvantageInterface_ads_disconnect( VALUE imp_drh, VALUE ads_conn );
|
72
72
|
|
73
73
|
static VALUE
|
74
|
-
static_AdvantageInterface_ads_free_connection(VALUE imp_drh, VALUE ads_conn);
|
74
|
+
static_AdvantageInterface_ads_free_connection( VALUE imp_drh, VALUE ads_conn );
|
75
75
|
|
76
76
|
static VALUE
|
77
|
-
static_AdvantageInterface_ads_fini(VALUE imp_drh);
|
77
|
+
static_AdvantageInterface_ads_fini( VALUE imp_drh );
|
78
78
|
|
79
79
|
static VALUE
|
80
|
-
static_AdvantageInterface_ads_error(VALUE imp_drh, VALUE ads_conn);
|
80
|
+
static_AdvantageInterface_ads_error( VALUE imp_drh, VALUE ads_conn );
|
81
81
|
|
82
82
|
static VALUE
|
83
|
-
static_AdvantageInterface_ads_execute_immediate(VALUE imp_drh, VALUE ads_conn, VALUE sql);
|
83
|
+
static_AdvantageInterface_ads_execute_immediate( VALUE imp_drh, VALUE ads_conn, VALUE sql );
|
84
84
|
|
85
85
|
static VALUE
|
86
|
-
static_AdvantageInterface_ads_execute_direct(VALUE imp_drh, VALUE ads_conn, VALUE sql);
|
86
|
+
static_AdvantageInterface_ads_execute_direct( VALUE imp_drh, VALUE ads_conn, VALUE sql );
|
87
87
|
|
88
88
|
static VALUE
|
89
|
-
static_AdvantageInterface_ads_num_cols(VALUE imp_drh, VALUE ads_stmt);
|
89
|
+
static_AdvantageInterface_ads_num_cols( VALUE imp_drh, VALUE ads_stmt );
|
90
90
|
|
91
91
|
static VALUE
|
92
|
-
static_AdvantageInterface_ads_num_rows(VALUE imp_drh, VALUE ads_stmt);
|
92
|
+
static_AdvantageInterface_ads_num_rows( VALUE imp_drh, VALUE ads_stmt );
|
93
93
|
|
94
94
|
static VALUE
|
95
|
-
static_AdvantageInterface_ads_get_column(VALUE imp_drh, VALUE ads_stmt, VALUE col_num);
|
95
|
+
static_AdvantageInterface_ads_get_column( VALUE imp_drh, VALUE ads_stmt, VALUE col_num );
|
96
96
|
|
97
97
|
static VALUE
|
98
|
-
static_AdvantageInterface_ads_fetch_next(VALUE imp_drh, VALUE ads_stmt);
|
98
|
+
static_AdvantageInterface_ads_fetch_next( VALUE imp_drh, VALUE ads_stmt );
|
99
99
|
|
100
100
|
static VALUE
|
101
|
-
static_AdvantageInterface_ads_get_column_info(VALUE imp_drh, VALUE ads_stmt, VALUE col_num);
|
101
|
+
static_AdvantageInterface_ads_get_column_info( VALUE imp_drh, VALUE ads_stmt, VALUE col_num );
|
102
102
|
|
103
103
|
static VALUE
|
104
|
-
static_AdvantageInterface_AdsBeginTransaction(VALUE imp_drh, VALUE ads_conn);
|
104
|
+
static_AdvantageInterface_AdsBeginTransaction( VALUE imp_drh, VALUE ads_conn );
|
105
105
|
|
106
106
|
static VALUE
|
107
|
-
static_AdvantageInterface_ads_commit(VALUE imp_drh, VALUE ads_conn);
|
107
|
+
static_AdvantageInterface_ads_commit( VALUE imp_drh, VALUE ads_conn );
|
108
108
|
|
109
109
|
static VALUE
|
110
|
-
static_AdvantageInterface_ads_rollback(VALUE imp_drh, VALUE ads_conn);
|
110
|
+
static_AdvantageInterface_ads_rollback( VALUE imp_drh, VALUE ads_conn );
|
111
111
|
|
112
112
|
static VALUE
|
113
|
-
static_AdvantageInterface_ads_prepare(VALUE imp_drh, VALUE ads_conn, VALUE sql);
|
113
|
+
static_AdvantageInterface_ads_prepare( VALUE imp_drh, VALUE ads_conn, VALUE sql );
|
114
114
|
|
115
115
|
static VALUE
|
116
|
-
static_AdvantageInterface_ads_free_stmt(VALUE imp_drh, VALUE ads_stmt);
|
116
|
+
static_AdvantageInterface_ads_free_stmt( VALUE imp_drh, VALUE ads_stmt );
|
117
117
|
|
118
118
|
static VALUE
|
119
|
-
static_AdvantageInterface_ads_reset(VALUE imp_drh, VALUE ads_stmt);
|
119
|
+
static_AdvantageInterface_ads_reset( VALUE imp_drh, VALUE ads_stmt );
|
120
120
|
|
121
121
|
static VALUE
|
122
|
-
static_AdvantageInterface_ads_execute(VALUE imp_drh, VALUE ads_stmt);
|
122
|
+
static_AdvantageInterface_ads_execute( VALUE imp_drh, VALUE ads_stmt );
|
123
123
|
|
124
124
|
static VALUE
|
125
|
-
static_AdvantageInterface_ads_affected_rows(VALUE imp_drh, VALUE ads_stmt);
|
125
|
+
static_AdvantageInterface_ads_affected_rows( VALUE imp_drh, VALUE ads_stmt );
|
126
126
|
|
127
127
|
static VALUE
|
128
|
-
static_AdvantageInterface_ads_describe_bind_param(VALUE imp_drh, VALUE ads_stmt, VALUE index);
|
128
|
+
static_AdvantageInterface_ads_describe_bind_param( VALUE imp_drh, VALUE ads_stmt, VALUE index );
|
129
129
|
|
130
130
|
/*
|
131
131
|
* C to Ruby Data conversion function to convert DBCAPI column type into the correct Ruby type
|
132
132
|
*/
|
133
|
-
static VALUE C2RB(a_ads_data_value* value)
|
134
|
-
{
|
133
|
+
static VALUE C2RB( a_ads_data_value* value )
|
134
|
+
{
|
135
135
|
VALUE tdata;
|
136
136
|
|
137
|
-
if( value == NULL || value->buffer == NULL || value->is_null == NULL )
|
138
|
-
|
139
|
-
|
140
|
-
|
137
|
+
if( value == NULL || value->buffer == NULL || value->is_null == NULL )
|
138
|
+
{
|
139
|
+
rb_raise( rb_eTypeError, "Operation not allowed. Has no value." );
|
140
|
+
}
|
141
|
+
else if( *value->is_null )
|
142
|
+
{
|
141
143
|
tdata = Qnil;
|
142
|
-
}
|
143
|
-
else {
|
144
|
-
switch( value->type ) {
|
145
|
-
case A_BINARY:
|
146
|
-
tdata = rb_str_new(value->buffer, *value->length);
|
147
|
-
break;
|
148
|
-
case A_STRING:
|
149
|
-
case A_DATE:
|
150
|
-
case A_TIME:
|
151
|
-
case A_TIMESTAMP:
|
152
|
-
case A_NCHAR:
|
153
|
-
case A_DECIMAL:
|
154
|
-
tdata = rb_str_new(value->buffer, *value->length);
|
155
|
-
break;
|
156
|
-
case A_DOUBLE:
|
157
|
-
tdata = rb_float_new(*(double*) value->buffer);
|
158
|
-
break;
|
159
|
-
case A_VAL64:
|
160
|
-
tdata = LL2NUM(*(LONG_LONG*)value->buffer);
|
161
|
-
break;
|
162
|
-
case A_UVAL64:
|
163
|
-
tdata = ULL2NUM(*(unsigned LONG_LONG*)value->buffer);
|
164
|
-
break;
|
165
|
-
case A_VAL32:
|
166
|
-
tdata = INT2NUM(*(int *)value->buffer);
|
167
|
-
break;
|
168
|
-
case A_UVAL32:
|
169
|
-
tdata = UINT2NUM(*(unsigned int *)value->buffer);
|
170
|
-
break;
|
171
|
-
case A_VAL16:
|
172
|
-
tdata = INT2NUM(*(short *)value->buffer);
|
173
|
-
break;
|
174
|
-
case A_UVAL16:
|
175
|
-
tdata = UINT2NUM(*( unsigned short *)value->buffer);
|
176
|
-
break;
|
177
|
-
case A_VAL8:
|
178
|
-
tdata = CHR2FIX(*(unsigned char *)value->buffer);
|
179
|
-
break;
|
180
|
-
case A_UVAL8:
|
181
|
-
tdata = CHR2FIX(*(unsigned char *)value->buffer);
|
182
|
-
break;
|
183
|
-
default:
|
184
|
-
rb_raise(rb_eTypeError, "Invalid Data Type");
|
185
|
-
tdata = Qnil;
|
186
|
-
break;
|
187
144
|
}
|
188
|
-
|
145
|
+
else
|
146
|
+
{
|
147
|
+
switch( value->type )
|
148
|
+
{
|
149
|
+
case A_BINARY:
|
150
|
+
tdata = rb_str_new( ( char* )value->buffer, *value->length );
|
151
|
+
break;
|
152
|
+
case A_STRING:
|
153
|
+
case A_DATE:
|
154
|
+
case A_TIME:
|
155
|
+
case A_TIMESTAMP:
|
156
|
+
case A_NCHAR:
|
157
|
+
case A_DECIMAL:
|
158
|
+
tdata = rb_str_new( ( char* )value->buffer, *value->length );
|
159
|
+
break;
|
160
|
+
case A_DOUBLE:
|
161
|
+
tdata = rb_float_new( *( double* ) value->buffer );
|
162
|
+
break;
|
163
|
+
case A_VAL64:
|
164
|
+
tdata = LL2NUM( *( LONG_LONG* )value->buffer );
|
165
|
+
break;
|
166
|
+
case A_UVAL64:
|
167
|
+
tdata = ULL2NUM( *( unsigned LONG_LONG* )value->buffer );
|
168
|
+
break;
|
169
|
+
case A_VAL32:
|
170
|
+
tdata = INT2NUM( *( int * )value->buffer );
|
171
|
+
break;
|
172
|
+
case A_UVAL32:
|
173
|
+
tdata = UINT2NUM( *( unsigned int * )value->buffer );
|
174
|
+
break;
|
175
|
+
case A_VAL16:
|
176
|
+
tdata = INT2NUM( *( short * )value->buffer );
|
177
|
+
break;
|
178
|
+
case A_UVAL16:
|
179
|
+
tdata = UINT2NUM( *( unsigned short * )value->buffer );
|
180
|
+
break;
|
181
|
+
case A_VAL8:
|
182
|
+
tdata = CHR2FIX( *( unsigned char * )value->buffer );
|
183
|
+
break;
|
184
|
+
case A_UVAL8:
|
185
|
+
tdata = CHR2FIX( *( unsigned char * )value->buffer );
|
186
|
+
break;
|
187
|
+
default:
|
188
|
+
rb_raise( rb_eTypeError, "Invalid Data Type" );
|
189
|
+
tdata = Qnil;
|
190
|
+
break;
|
191
|
+
}
|
192
|
+
}
|
189
193
|
|
190
|
-
|
191
|
-
}
|
194
|
+
return tdata;
|
195
|
+
}
|
192
196
|
|
193
197
|
/*
|
194
198
|
* call-seq:
|
195
|
-
* ads_initialize_interface(VALUE imp_drh) -> int result
|
199
|
+
* ads_initialize_interface( VALUE imp_drh ) -> int result
|
196
200
|
*
|
197
201
|
* Initializes the AdvantageInterface object and loads the DLL dynamically.
|
198
202
|
*
|
@@ -207,21 +211,21 @@ static VALUE C2RB(a_ads_data_value* value)
|
|
207
211
|
*
|
208
212
|
*/
|
209
213
|
static VALUE
|
210
|
-
static_API_ads_initialize_interface(VALUE module, VALUE imp_drh)
|
211
|
-
{
|
212
|
-
|
213
|
-
|
214
|
+
static_API_ads_initialize_interface( VALUE module, VALUE imp_drh )
|
215
|
+
{
|
216
|
+
imp_drh_st* s_imp_drh;
|
217
|
+
int result;
|
214
218
|
|
215
|
-
|
219
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
216
220
|
|
217
|
-
|
221
|
+
result = ads_initialize_interface( &( s_imp_drh->api ), NULL );
|
218
222
|
|
219
|
-
|
220
|
-
}
|
223
|
+
return( INT2NUM( result ) );
|
224
|
+
}
|
221
225
|
|
222
226
|
/*
|
223
227
|
* call-seq:
|
224
|
-
* ads_finalize_interface(VALUE imp_drh) -> nil
|
228
|
+
* ads_finalize_interface( VALUE imp_drh ) -> nil
|
225
229
|
*
|
226
230
|
* Finalize and free resources associated with the Advantage C API DLL.
|
227
231
|
*
|
@@ -236,35 +240,35 @@ static_API_ads_initialize_interface(VALUE module, VALUE imp_drh)
|
|
236
240
|
*
|
237
241
|
*/
|
238
242
|
static VALUE
|
239
|
-
static_API_ads_finalize_interface(VALUE module, VALUE imp_drh)
|
240
|
-
{
|
241
|
-
|
243
|
+
static_API_ads_finalize_interface( VALUE module, VALUE imp_drh )
|
244
|
+
{
|
245
|
+
imp_drh_st* s_imp_drh;
|
242
246
|
|
243
|
-
|
247
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
244
248
|
|
245
|
-
|
249
|
+
ads_finalize_interface( &( s_imp_drh->api ) );
|
246
250
|
|
247
|
-
|
251
|
+
free( &( s_imp_drh->api ) );
|
248
252
|
|
249
|
-
|
250
|
-
}
|
253
|
+
return( Qnil );
|
254
|
+
}
|
251
255
|
|
252
256
|
static VALUE
|
253
|
-
static_AdvantageInterface_alloc(VALUE class)
|
254
|
-
{
|
255
|
-
|
256
|
-
|
257
|
+
static_AdvantageInterface_alloc( VALUE class )
|
258
|
+
{
|
259
|
+
imp_drh_st *imp_drh = NULL;
|
260
|
+
VALUE tdata;
|
257
261
|
|
258
|
-
|
259
|
-
|
262
|
+
imp_drh = malloc( sizeof( imp_drh_st ) );
|
263
|
+
memset( imp_drh, 0, sizeof( imp_drh_st ) );
|
260
264
|
|
261
|
-
|
262
|
-
|
263
|
-
}
|
265
|
+
tdata = Data_Wrap_Struct( class, 0, 0, imp_drh );
|
266
|
+
return tdata;
|
267
|
+
}
|
264
268
|
|
265
269
|
/*
|
266
270
|
* call-seq:
|
267
|
-
* ads_init(VALUE imp_drh) -> [VALUE result, VALUE version]
|
271
|
+
* ads_init( VALUE imp_drh ) -> [VALUE result, VALUE version]
|
268
272
|
*
|
269
273
|
* Initializes the interface.
|
270
274
|
*
|
@@ -277,32 +281,35 @@ static_AdvantageInterface_alloc(VALUE class)
|
|
277
281
|
*
|
278
282
|
*/
|
279
283
|
static VALUE
|
280
|
-
static_AdvantageInterface_ads_init(VALUE imp_drh)
|
281
|
-
{
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
284
|
+
static_AdvantageInterface_ads_init( VALUE imp_drh )
|
285
|
+
{
|
286
|
+
imp_drh_st* s_imp_drh;
|
287
|
+
UNSIGNED32 result;
|
288
|
+
UNSIGNED32 s_version_available;
|
289
|
+
VALUE multi_result;
|
286
290
|
|
287
|
-
|
291
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
288
292
|
|
289
|
-
|
293
|
+
multi_result = rb_ary_new( );
|
290
294
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
295
|
+
if( &( s_imp_drh->api ) == NULL )
|
296
|
+
{
|
297
|
+
rb_ary_push( multi_result, INT2NUM( 0 ) );
|
298
|
+
rb_ary_push( multi_result, Qnil );
|
299
|
+
}
|
300
|
+
else
|
301
|
+
{
|
302
|
+
result = s_imp_drh->api.ads_init( ( UNSIGNED8* )"RUBY", 1 , &s_version_available );
|
303
|
+
rb_ary_push( multi_result, INT2NUM( result ) );
|
304
|
+
rb_ary_push( multi_result, INT2NUM( s_version_available ) );
|
298
305
|
}
|
299
306
|
|
300
|
-
|
301
|
-
}
|
307
|
+
return( multi_result );
|
308
|
+
}
|
302
309
|
|
303
310
|
/*
|
304
311
|
* call-seq:
|
305
|
-
* ads_new_connection(VALUE imp_drh) -> VALUE connection
|
312
|
+
* ads_new_connection( VALUE imp_drh ) -> VALUE connection
|
306
313
|
*
|
307
314
|
* Creates a connection object.
|
308
315
|
*
|
@@ -318,23 +325,23 @@ static_AdvantageInterface_ads_init(VALUE imp_drh)
|
|
318
325
|
*
|
319
326
|
*/
|
320
327
|
static VALUE
|
321
|
-
static_AdvantageInterface_ads_new_connection(VALUE imp_drh)
|
322
|
-
{
|
323
|
-
|
324
|
-
|
325
|
-
|
328
|
+
static_AdvantageInterface_ads_new_connection( VALUE imp_drh )
|
329
|
+
{
|
330
|
+
imp_drh_st* s_imp_drh;
|
331
|
+
a_ads_connection* ptr;
|
332
|
+
VALUE tdata;
|
326
333
|
|
327
|
-
|
328
|
-
|
334
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
335
|
+
ptr = s_imp_drh->api.ads_new_connection( );
|
329
336
|
|
330
|
-
|
337
|
+
tdata = Data_Wrap_Struct( cA_ads_connection, 0, 0, ptr );
|
331
338
|
|
332
|
-
|
333
|
-
}
|
339
|
+
return( tdata );
|
340
|
+
}
|
334
341
|
|
335
342
|
/*
|
336
343
|
* call-seq:
|
337
|
-
* ads_client_version(VALUE imp_drh) -> [VALUE verstr]
|
344
|
+
* ads_client_version( VALUE imp_drh ) -> [VALUE verstr]
|
338
345
|
*
|
339
346
|
* Retrieves the client version as a string.
|
340
347
|
*
|
@@ -349,22 +356,21 @@ static_AdvantageInterface_ads_new_connection(VALUE imp_drh)
|
|
349
356
|
*/
|
350
357
|
|
351
358
|
static VALUE
|
352
|
-
static_AdvantageInterface_ads_client_version(VALUE imp_drh)
|
353
|
-
{
|
354
|
-
|
355
|
-
|
356
|
-
char s_buffer[255];
|
359
|
+
static_AdvantageInterface_ads_client_version( VALUE imp_drh )
|
360
|
+
{
|
361
|
+
imp_drh_st* s_imp_drh;
|
362
|
+
char s_buffer[255];
|
357
363
|
|
358
|
-
|
364
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
359
365
|
|
360
|
-
|
366
|
+
s_imp_drh->api.ads_client_version( ( UNSIGNED8* )s_buffer, 255 );
|
361
367
|
|
362
|
-
|
363
|
-
}
|
368
|
+
return( rb_str_new2( s_buffer ) );
|
369
|
+
}
|
364
370
|
|
365
371
|
/*
|
366
372
|
* call-seq:
|
367
|
-
* ads_connect(VALUE imp_drh, VALUE ads_conn, VALUE str) -> VALUE result
|
373
|
+
* ads_connect( VALUE imp_drh, VALUE ads_conn, VALUE str ) -> VALUE result
|
368
374
|
*
|
369
375
|
* Creates a connection object.
|
370
376
|
*
|
@@ -374,7 +380,7 @@ static_AdvantageInterface_ads_client_version(VALUE imp_drh)
|
|
374
380
|
*
|
375
381
|
* <b>Parameters</b>:
|
376
382
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
377
|
-
* - <tt>VALUE ads_conn</tt> -- A connection object that was created by ads_new_connection().
|
383
|
+
* - <tt>VALUE ads_conn</tt> -- A connection object that was created by ads_new_connection( ).
|
378
384
|
* - <tt>VALUE str</tt> -- A connection string.
|
379
385
|
*
|
380
386
|
* <b>Returns</b>:
|
@@ -382,26 +388,26 @@ static_AdvantageInterface_ads_client_version(VALUE imp_drh)
|
|
382
388
|
*
|
383
389
|
*/
|
384
390
|
static VALUE
|
385
|
-
static_AdvantageInterface_ads_connect(VALUE imp_drh, VALUE ads_conn, VALUE str)
|
386
|
-
{
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
+
static_AdvantageInterface_ads_connect( VALUE imp_drh, VALUE ads_conn, VALUE str )
|
392
|
+
{
|
393
|
+
imp_drh_st* s_imp_drh;
|
394
|
+
a_ads_connection* s_ads_conn;
|
395
|
+
char* s_str;
|
396
|
+
UNSIGNED32 result;
|
391
397
|
|
392
|
-
|
393
|
-
|
398
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
399
|
+
Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
|
394
400
|
|
395
|
-
|
401
|
+
s_str = StringValueCStr( str );
|
396
402
|
|
397
|
-
|
403
|
+
result = s_imp_drh->api.ads_connect( s_ads_conn, ( UNSIGNED8* )s_str );
|
398
404
|
|
399
|
-
|
400
|
-
}
|
405
|
+
return( INT2NUM( result ) );
|
406
|
+
}
|
401
407
|
|
402
408
|
/*
|
403
409
|
* call-seq:
|
404
|
-
* ads_disconnect(VALUE imp_drh, VALUE ads_conn) -> nil
|
410
|
+
* ads_disconnect( VALUE imp_drh, VALUE ads_conn ) -> nil
|
405
411
|
*
|
406
412
|
* Disconnect an already established connection.
|
407
413
|
*
|
@@ -410,59 +416,59 @@ static_AdvantageInterface_ads_connect(VALUE imp_drh, VALUE ads_conn, VALUE str)
|
|
410
416
|
*
|
411
417
|
* <b>Parameters</b>:
|
412
418
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
413
|
-
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
|
419
|
+
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
|
414
420
|
*
|
415
421
|
* <b>Returns</b>:
|
416
422
|
* - <tt>nil</tt>.
|
417
423
|
*
|
418
424
|
*/
|
419
425
|
static VALUE
|
420
|
-
static_AdvantageInterface_ads_disconnect(VALUE imp_drh, VALUE ads_conn)
|
421
|
-
{
|
422
|
-
|
423
|
-
|
426
|
+
static_AdvantageInterface_ads_disconnect( VALUE imp_drh, VALUE ads_conn )
|
427
|
+
{
|
428
|
+
imp_drh_st* s_imp_drh;
|
429
|
+
a_ads_connection* s_ads_conn;
|
424
430
|
|
425
|
-
|
426
|
-
|
431
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
432
|
+
Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
|
427
433
|
|
428
434
|
|
429
|
-
|
435
|
+
s_imp_drh->api.ads_disconnect( s_ads_conn );
|
430
436
|
|
431
|
-
|
432
|
-
}
|
437
|
+
return( Qnil );
|
438
|
+
}
|
433
439
|
|
434
440
|
/*
|
435
441
|
* call-seq:
|
436
|
-
* ads_free_connection(VALUE imp_drh, VALUE ads_conn) -> nil
|
442
|
+
* ads_free_connection( VALUE imp_drh, VALUE ads_conn ) -> nil
|
437
443
|
*
|
438
444
|
* Frees the resources associated with a connection object.
|
439
445
|
*
|
440
446
|
* <b>Parameters</b>:
|
441
447
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
442
|
-
* - <tt>VALUE ads_conn</tt> -- A connection object that was disconnected by ads_disconnect().
|
448
|
+
* - <tt>VALUE ads_conn</tt> -- A connection object that was disconnected by ads_disconnect( ).
|
443
449
|
*
|
444
450
|
* <b>Returns</b>:
|
445
451
|
* - <tt>nil</tt>.
|
446
452
|
*
|
447
453
|
*/
|
448
454
|
static VALUE
|
449
|
-
static_AdvantageInterface_ads_free_connection(VALUE imp_drh, VALUE ads_conn)
|
450
|
-
{
|
451
|
-
|
452
|
-
|
455
|
+
static_AdvantageInterface_ads_free_connection( VALUE imp_drh, VALUE ads_conn )
|
456
|
+
{
|
457
|
+
imp_drh_st* s_imp_drh;
|
458
|
+
a_ads_connection* s_ads_conn;
|
453
459
|
|
454
|
-
|
455
|
-
|
460
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
461
|
+
Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
|
456
462
|
|
457
463
|
|
458
|
-
|
464
|
+
s_imp_drh->api.ads_free_connection( s_ads_conn );
|
459
465
|
|
460
|
-
|
461
|
-
}
|
466
|
+
return( Qnil );
|
467
|
+
}
|
462
468
|
|
463
469
|
/*
|
464
470
|
* call-seq:
|
465
|
-
* ads_fini(VALUE imp_drh) -> nil
|
471
|
+
* ads_fini( VALUE imp_drh ) -> nil
|
466
472
|
*
|
467
473
|
* Finalizes the interface.
|
468
474
|
*
|
@@ -476,20 +482,20 @@ static_AdvantageInterface_ads_free_connection(VALUE imp_drh, VALUE ads_conn)
|
|
476
482
|
*
|
477
483
|
*/
|
478
484
|
static VALUE
|
479
|
-
static_AdvantageInterface_ads_fini(VALUE imp_drh)
|
480
|
-
{
|
481
|
-
|
485
|
+
static_AdvantageInterface_ads_fini( VALUE imp_drh )
|
486
|
+
{
|
487
|
+
imp_drh_st* s_imp_drh;
|
482
488
|
|
483
|
-
|
489
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
484
490
|
|
485
|
-
|
491
|
+
s_imp_drh->api.ads_fini( );
|
486
492
|
|
487
|
-
|
488
|
-
}
|
493
|
+
return( Qnil );
|
494
|
+
}
|
489
495
|
|
490
496
|
/*
|
491
497
|
* call-seq:
|
492
|
-
* ads_error(VALUE imp_drh, VALUE ads_conn) -> [VALUE result, VALUE errstr]
|
498
|
+
* ads_error( VALUE imp_drh, VALUE ads_conn ) -> [VALUE result, VALUE errstr]
|
493
499
|
*
|
494
500
|
* Retrieves the last error code and message.
|
495
501
|
*
|
@@ -498,7 +504,7 @@ static_AdvantageInterface_ads_fini(VALUE imp_drh)
|
|
498
504
|
*
|
499
505
|
* <b>Parameters</b>:
|
500
506
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
501
|
-
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
|
507
|
+
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
|
502
508
|
*
|
503
509
|
* <b>Returns</b>:
|
504
510
|
* - <tt>VALUE result</tt>: The last error code. Positive values are warnings, negative values are errors, and <tt>0</tt> is success.
|
@@ -507,31 +513,30 @@ static_AdvantageInterface_ads_fini(VALUE imp_drh)
|
|
507
513
|
*/
|
508
514
|
|
509
515
|
static VALUE
|
510
|
-
static_AdvantageInterface_ads_error(VALUE imp_drh, VALUE ads_conn)
|
511
|
-
{
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
VALUE multi_result;
|
516
|
+
static_AdvantageInterface_ads_error( VALUE imp_drh, VALUE ads_conn )
|
517
|
+
{
|
518
|
+
imp_drh_st* s_imp_drh;
|
519
|
+
a_ads_connection* s_ads_conn;
|
520
|
+
char s_buffer[255];
|
521
|
+
UNSIGNED32 result;
|
522
|
+
VALUE multi_result;
|
518
523
|
|
519
|
-
|
520
|
-
|
524
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
525
|
+
Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
|
521
526
|
|
522
|
-
|
527
|
+
result = s_imp_drh->api.ads_error( s_ads_conn, ( UNSIGNED8* )s_buffer, 255 );
|
523
528
|
|
524
|
-
|
529
|
+
multi_result = rb_ary_new( );
|
525
530
|
|
526
|
-
|
527
|
-
|
531
|
+
rb_ary_push( multi_result, INT2NUM( result ) );
|
532
|
+
rb_ary_push( multi_result, rb_str_new2( s_buffer ) );
|
528
533
|
|
529
|
-
|
530
|
-
}
|
534
|
+
return( multi_result );
|
535
|
+
}
|
531
536
|
|
532
537
|
/*
|
533
538
|
* call-seq:
|
534
|
-
* ads_execute_immediate(VALUE imp_drh, VALUE ads_conn, VALUE sql) -> VALUE result
|
539
|
+
* ads_execute_immediate( VALUE imp_drh, VALUE ads_conn, VALUE sql ) -> VALUE result
|
535
540
|
*
|
536
541
|
* Executes a SQL statement immediately without returning a result set.
|
537
542
|
*
|
@@ -541,7 +546,7 @@ static_AdvantageInterface_ads_error(VALUE imp_drh, VALUE ads_conn)
|
|
541
546
|
*
|
542
547
|
* <b>Parameters</b>:
|
543
548
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
544
|
-
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
|
549
|
+
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
|
545
550
|
* - <tt>VALUE sql</tt> -- A SQL query string.
|
546
551
|
*
|
547
552
|
* <b>Returns</b>:
|
@@ -549,40 +554,40 @@ static_AdvantageInterface_ads_error(VALUE imp_drh, VALUE ads_conn)
|
|
549
554
|
*
|
550
555
|
*/
|
551
556
|
static VALUE
|
552
|
-
static_AdvantageInterface_ads_execute_immediate(VALUE imp_drh, VALUE ads_conn, VALUE sql)
|
553
|
-
{
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
557
|
+
static_AdvantageInterface_ads_execute_immediate( VALUE imp_drh, VALUE ads_conn, VALUE sql )
|
558
|
+
{
|
559
|
+
imp_drh_st* s_imp_drh;
|
560
|
+
a_ads_connection* s_ads_conn;
|
561
|
+
char* s_sql;
|
562
|
+
UNSIGNED32 result;
|
558
563
|
|
559
|
-
|
564
|
+
s_sql = StringValueCStr( sql );
|
560
565
|
|
561
|
-
|
562
|
-
|
566
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
567
|
+
Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
|
563
568
|
|
564
|
-
|
569
|
+
result = s_imp_drh->api.ads_execute_immediate( s_ads_conn, ( UNSIGNED8* )s_sql );
|
565
570
|
|
566
|
-
|
567
|
-
}
|
571
|
+
return( INT2NUM( result ) );
|
572
|
+
}
|
568
573
|
|
569
574
|
/*
|
570
575
|
* call-seq:
|
571
|
-
* ads_execute_direct(VALUE imp_drh, VALUE ads_conn, VALUE sql) -> VALUE resultset
|
576
|
+
* ads_execute_direct( VALUE imp_drh, VALUE ads_conn, VALUE sql ) -> VALUE resultset
|
572
577
|
*
|
573
578
|
* Executes a SQL statement and possibly returns a result set.
|
574
579
|
*
|
575
580
|
* This function executes the SQL statement specified by the string argument.
|
576
581
|
* This function is suitable if you want to prepare and then execute a
|
577
|
-
* statement, and can be used instead of calling ads_prepare() followed
|
578
|
-
* by ads_execute().
|
582
|
+
* statement, and can be used instead of calling ads_prepare( ) followed
|
583
|
+
* by ads_execute( ).
|
579
584
|
*
|
580
585
|
* This function cannot be used for executing a SQL statement with
|
581
586
|
* parameters.
|
582
587
|
*
|
583
588
|
* <b>Parameters</b>:
|
584
589
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
585
|
-
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
|
590
|
+
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
|
586
591
|
* - <tt>VALUE sql</tt> -- A SQL query string.
|
587
592
|
*
|
588
593
|
* <b>Returns</b>:
|
@@ -590,198 +595,199 @@ static_AdvantageInterface_ads_execute_immediate(VALUE imp_drh, VALUE ads_conn, V
|
|
590
595
|
*
|
591
596
|
*/
|
592
597
|
static VALUE
|
593
|
-
static_AdvantageInterface_ads_execute_direct(VALUE imp_drh, VALUE ads_conn, VALUE sql)
|
594
|
-
{
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
598
|
+
static_AdvantageInterface_ads_execute_direct( VALUE imp_drh, VALUE ads_conn, VALUE sql )
|
599
|
+
{
|
600
|
+
imp_drh_st* s_imp_drh;
|
601
|
+
a_ads_connection* s_ads_conn;
|
602
|
+
ADSHANDLE resultset = 0;
|
603
|
+
char* s_sql;
|
604
|
+
VALUE tdata;
|
600
605
|
|
601
|
-
|
606
|
+
s_sql = StringValueCStr( sql );
|
602
607
|
|
603
|
-
|
604
|
-
|
608
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
609
|
+
Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
|
605
610
|
|
606
|
-
|
611
|
+
resultset = s_imp_drh->api.ads_execute_direct( s_ads_conn, ( UNSIGNED8* )s_sql );
|
607
612
|
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
613
|
+
if( resultset )
|
614
|
+
{
|
615
|
+
tdata = INT2NUM( resultset );
|
616
|
+
}
|
617
|
+
else
|
618
|
+
{
|
619
|
+
tdata = Qnil;
|
620
|
+
}
|
616
621
|
|
617
|
-
|
618
|
-
}
|
622
|
+
return( tdata );
|
623
|
+
}
|
619
624
|
|
620
625
|
/*
|
621
626
|
* call-seq:
|
622
|
-
* ads_num_cols(VALUE imp_drh, VALUE ads_stmt) -> VALUE num_cols
|
627
|
+
* ads_num_cols( VALUE imp_drh, VALUE ads_stmt ) -> VALUE num_cols
|
623
628
|
*
|
624
629
|
* Returns number of columns in the result set.
|
625
630
|
*
|
626
631
|
* <b>Parameters</b>:
|
627
632
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
628
|
-
* - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
|
633
|
+
* - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare( ) or ads_execute_direct( ).
|
629
634
|
*
|
630
635
|
* <b>Returns</b>:
|
631
636
|
* - <tt>VALUE num_cols</tt>: The number of columns in the result set or <tt>-1</tt> on a failure.
|
632
637
|
*
|
633
638
|
*/
|
634
639
|
static VALUE
|
635
|
-
static_AdvantageInterface_ads_num_cols(VALUE imp_drh, VALUE ads_stmt)
|
636
|
-
{
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
+
static_AdvantageInterface_ads_num_cols( VALUE imp_drh, VALUE ads_stmt )
|
641
|
+
{
|
642
|
+
imp_drh_st* s_imp_drh;
|
643
|
+
ADSHANDLE s_stmt;
|
644
|
+
UNSIGNED32 result;
|
640
645
|
|
641
|
-
|
642
|
-
|
643
|
-
|
646
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
647
|
+
//Data_Get_Struct( ads_stmt, ADSHANDLE, s_stmt );
|
648
|
+
s_stmt = NUM2ULONG( ads_stmt );
|
644
649
|
|
645
|
-
|
650
|
+
result = s_imp_drh->api.ads_num_cols( s_stmt );
|
646
651
|
|
647
|
-
|
648
|
-
}
|
652
|
+
return( INT2NUM( result ) );
|
653
|
+
}
|
649
654
|
|
650
655
|
/*
|
651
656
|
* call-seq:
|
652
|
-
* ads_num_rows(VALUE imp_drh, VALUE ads_stmt) -> VALUE num_rows
|
657
|
+
* ads_num_rows( VALUE imp_drh, VALUE ads_stmt ) -> VALUE num_rows
|
653
658
|
*
|
654
659
|
* Returns number of rows in the result set.
|
655
660
|
*
|
656
661
|
* <b>Parameters</b>:
|
657
662
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
658
|
-
* - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
|
663
|
+
* - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare( ) or ads_execute_direct( ).
|
659
664
|
*
|
660
665
|
* <b>Returns</b>:
|
661
666
|
* - <tt>VALUE num_rows</tt>: The number of rows in the result set or <tt>-1</tt> on a failure.
|
662
667
|
*
|
663
668
|
*/
|
664
669
|
static VALUE
|
665
|
-
static_AdvantageInterface_ads_num_rows(VALUE imp_drh, VALUE ads_stmt)
|
666
|
-
{
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
+
static_AdvantageInterface_ads_num_rows( VALUE imp_drh, VALUE ads_stmt )
|
671
|
+
{
|
672
|
+
imp_drh_st* s_imp_drh;
|
673
|
+
ADSHANDLE s_stmt;
|
674
|
+
UNSIGNED32 result;
|
670
675
|
|
671
|
-
|
672
|
-
|
673
|
-
|
676
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
677
|
+
//Data_Get_Struct( ads_stmt, ADSHANDLE, s_stmt );
|
678
|
+
s_stmt = NUM2ULONG( ads_stmt );
|
674
679
|
|
675
|
-
|
680
|
+
result = s_imp_drh->api.ads_num_rows( s_stmt );
|
676
681
|
|
677
|
-
|
678
|
-
}
|
682
|
+
return( INT2NUM( result ) );
|
683
|
+
}
|
679
684
|
|
680
685
|
/*
|
681
686
|
* call-seq:
|
682
|
-
* ads_get_column(VALUE imp_drh, VALUE ads_stmt, VALUE col_num) -> [VALUE result, VALUE column_value]
|
687
|
+
* ads_get_column( VALUE imp_drh, VALUE ads_stmt, VALUE col_num ) -> [VALUE result, VALUE column_value]
|
683
688
|
*
|
684
689
|
* Retrieves the data fetched for the specified column.
|
685
690
|
*
|
686
691
|
* <b>Parameters</b>:
|
687
692
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
688
|
-
* - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
|
689
|
-
* - <tt>VALUE col_num</tt> -- The number of the column to be retrieved. A column number is between 0 and ads_num_cols() - 1.
|
693
|
+
* - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare( ) or ads_execute_direct( ).
|
694
|
+
* - <tt>VALUE col_num</tt> -- The number of the column to be retrieved. A column number is between 0 and ads_num_cols( ) - 1.
|
690
695
|
*
|
691
696
|
* <b>Returns</b>:
|
692
697
|
* - <tt>VALUE column_value</tt>: The value of the column. nil is returned if the value was NULL.
|
693
698
|
*
|
694
699
|
*/
|
695
700
|
static VALUE
|
696
|
-
static_AdvantageInterface_ads_get_column(VALUE imp_drh, VALUE ads_stmt, VALUE col_num)
|
697
|
-
{
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
701
|
+
static_AdvantageInterface_ads_get_column( VALUE imp_drh, VALUE ads_stmt, VALUE col_num )
|
702
|
+
{
|
703
|
+
imp_drh_st* s_imp_drh;
|
704
|
+
ADSHANDLE s_stmt;
|
705
|
+
UNSIGNED32 s_col_num;
|
706
|
+
a_ads_data_value value;
|
707
|
+
UNSIGNED32 result;
|
708
|
+
VALUE multi_result;
|
709
|
+
|
710
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
711
|
+
//Data_Get_Struct( ads_stmt, ADSHANDLE, s_stmt );
|
712
|
+
s_stmt = NUM2ULONG( ads_stmt );
|
713
|
+
s_col_num = NUM2INT( col_num );
|
714
|
+
|
715
|
+
result = s_imp_drh->api.ads_get_column( s_stmt, s_col_num, &value );
|
716
|
+
|
717
|
+
multi_result = rb_ary_new( );
|
718
|
+
rb_ary_push( multi_result, INT2NUM( result ) );
|
719
|
+
|
720
|
+
if( !result )
|
721
|
+
{
|
722
|
+
rb_ary_push( multi_result, Qnil );
|
723
|
+
}
|
724
|
+
else
|
725
|
+
{
|
726
|
+
if( *value.is_null )
|
727
|
+
{
|
728
|
+
rb_ary_push( multi_result, Qnil );
|
729
|
+
}
|
730
|
+
else
|
731
|
+
{
|
732
|
+
rb_ary_push( multi_result, C2RB( &value ) );
|
733
|
+
}
|
734
|
+
}
|
735
|
+
|
736
|
+
return( multi_result );
|
737
|
+
}
|
732
738
|
|
733
739
|
/*
|
734
740
|
* call-seq:
|
735
|
-
* ads_fetch_next(VALUE imp_drh, VALUE ads_stmt) -> VALUE result
|
741
|
+
* ads_fetch_next( VALUE imp_drh, VALUE ads_stmt ) -> VALUE result
|
736
742
|
*
|
737
743
|
* Fetches the next row from the result set.
|
738
744
|
*
|
739
745
|
* This function fetches the next row from the result set. When the result
|
740
746
|
* object is first created, the current row pointer is set to point before
|
741
|
-
* the first row (that is, row 0).
|
747
|
+
* the first row ( that is, row 0 ).
|
742
748
|
* This function advances the row pointer first and then fetches the data
|
743
749
|
* at the new row.
|
744
750
|
*
|
745
751
|
* <b>Parameters</b>:
|
746
752
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
747
|
-
* - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
|
753
|
+
* - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare( ) or ads_execute_direct( ).
|
748
754
|
*
|
749
755
|
* <b>Returns</b>:
|
750
756
|
* - <tt>VALUE result</tt>: <tt>1</tt> on successful fetch, <tt>0</tt> otherwise.
|
751
757
|
*
|
752
758
|
*/
|
753
759
|
static VALUE
|
754
|
-
static_AdvantageInterface_ads_fetch_next(VALUE imp_drh, VALUE ads_stmt)
|
755
|
-
{
|
756
|
-
|
757
|
-
|
758
|
-
|
760
|
+
static_AdvantageInterface_ads_fetch_next( VALUE imp_drh, VALUE ads_stmt )
|
761
|
+
{
|
762
|
+
imp_drh_st* s_imp_drh;
|
763
|
+
ADSHANDLE s_stmt;
|
764
|
+
UNSIGNED32 result;
|
759
765
|
|
760
|
-
|
761
|
-
|
762
|
-
|
766
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
767
|
+
//Data_Get_Struct( ads_stmt, ADSHANDLE, s_stmt );
|
768
|
+
s_stmt = NUM2ULONG( ads_stmt );
|
763
769
|
|
764
|
-
|
770
|
+
result = s_imp_drh->api.ads_fetch_next( s_stmt );
|
765
771
|
|
766
|
-
|
767
|
-
}
|
772
|
+
return( INT2NUM( result ) );
|
773
|
+
}
|
768
774
|
|
769
775
|
/*
|
770
776
|
* call-seq:
|
771
|
-
* ads_get_column_info(VALUE imp_drh, VALUE ads_stmt, VALUE col_num) -> [VALUE result, VALUE col_num, VALUE name, VALUE type, VALUE max_size]
|
777
|
+
* ads_get_column_info( VALUE imp_drh, VALUE ads_stmt, VALUE col_num ) -> [VALUE result, VALUE col_num, VALUE name, VALUE type, VALUE max_size]
|
772
778
|
*
|
773
779
|
* Fetches the next row from the result set.
|
774
780
|
*
|
775
781
|
* This function fetches the next row from the result set. When the result
|
776
782
|
* object is first created, the current row pointer is set to point before
|
777
|
-
* the first row (that is, row 0).
|
783
|
+
* the first row ( that is, row 0 ).
|
778
784
|
* This function advances the row pointer first and then fetches the data
|
779
785
|
* at the new row.
|
780
786
|
*
|
781
787
|
* <b>Parameters</b>:
|
782
788
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
783
|
-
* - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
|
784
|
-
* - <tt>VALUE col_num</tt> -- The number of the column to be retrieved. A column number is between 0 and ads_num_cols() - 1.
|
789
|
+
* - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare( ) or ads_execute_direct( ).
|
790
|
+
* - <tt>VALUE col_num</tt> -- The number of the column to be retrieved. A column number is between 0 and ads_num_cols( ) - 1.
|
785
791
|
*
|
786
792
|
* <b>Returns</b>:
|
787
793
|
* - <tt>VALUE result</tt>: <tt>1</tt> on success. Returns <tt>0</tt> if the column index is out of range, or if the statement does not return a result set.
|
@@ -796,179 +802,178 @@ static_AdvantageInterface_ads_fetch_next(VALUE imp_drh, VALUE ads_stmt)
|
|
796
802
|
*
|
797
803
|
*/
|
798
804
|
static VALUE
|
799
|
-
static_AdvantageInterface_ads_get_column_info(VALUE imp_drh, VALUE ads_stmt, VALUE col_num)
|
800
|
-
{
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
}
|
805
|
+
static_AdvantageInterface_ads_get_column_info( VALUE imp_drh, VALUE ads_stmt, VALUE col_num )
|
806
|
+
{
|
807
|
+
imp_drh_st* s_imp_drh;
|
808
|
+
ADSHANDLE s_stmt;
|
809
|
+
UNSIGNED32 s_col_num;
|
810
|
+
a_ads_column_info info;
|
811
|
+
UNSIGNED32 result;
|
812
|
+
VALUE multi_result;
|
813
|
+
|
814
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
815
|
+
//Data_Get_Struct( ads_stmt, ADSHANDLE, s_stmt );
|
816
|
+
s_stmt = NUM2ULONG( ads_stmt );
|
817
|
+
s_col_num = NUM2INT( col_num );
|
818
|
+
|
819
|
+
result = s_imp_drh->api.ads_get_column_info( s_stmt, s_col_num, &info );
|
820
|
+
|
821
|
+
multi_result = rb_ary_new( );
|
822
|
+
rb_ary_push( multi_result, INT2NUM( result ) );
|
823
|
+
rb_ary_push( multi_result, col_num );
|
824
|
+
rb_ary_push( multi_result, rb_str_new2( ( char* )info.name ) );
|
825
|
+
rb_ary_push( multi_result, INT2NUM( info.type ) );
|
826
|
+
rb_ary_push( multi_result, INT2NUM( info.native_type ) );
|
827
|
+
rb_ary_push( multi_result, INT2NUM( info.precision ) );
|
828
|
+
rb_ary_push( multi_result, INT2NUM( info.scale ) );
|
829
|
+
rb_ary_push( multi_result, INT2NUM( info.max_size ) );
|
830
|
+
rb_ary_push( multi_result, INT2NUM( info.nullable ) );
|
831
|
+
|
832
|
+
return( multi_result );
|
833
|
+
}
|
828
834
|
|
829
835
|
/*
|
830
836
|
* call-seq:
|
831
|
-
* AdsBeginTransaction(VALUE imp_drh, VALUE ads_conn) -> VALUE result
|
837
|
+
* AdsBeginTransaction( VALUE imp_drh, VALUE ads_conn ) -> VALUE result
|
832
838
|
*
|
833
839
|
* Starts a transaction on the current connection.
|
834
840
|
*
|
835
841
|
* <b>Parameters</b>:
|
836
842
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
837
|
-
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
|
843
|
+
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
|
838
844
|
*
|
839
845
|
* <b>Returns</b>:
|
840
846
|
* - <tt>VALUE result</tt>: <tt>1</tt> on successful begining a transaction, <tt>0</tt> otherwise.
|
841
847
|
*
|
842
848
|
*/
|
843
849
|
static VALUE
|
844
|
-
static_AdvantageInterface_AdsBeginTransaction(VALUE imp_drh, VALUE ads_conn)
|
845
|
-
{
|
846
|
-
|
847
|
-
|
848
|
-
|
850
|
+
static_AdvantageInterface_AdsBeginTransaction( VALUE imp_drh, VALUE ads_conn )
|
851
|
+
{
|
852
|
+
imp_drh_st* s_imp_drh;
|
853
|
+
a_ads_connection* s_ads_conn;
|
854
|
+
UNSIGNED32 result;
|
849
855
|
|
850
|
-
|
851
|
-
|
856
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
857
|
+
Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
|
852
858
|
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
}
|
859
|
+
result = s_imp_drh->api.AdsBeginTransaction( s_ads_conn->hConnect );
|
860
|
+
if( result == 0 )
|
861
|
+
return( INT2NUM( 1 ) );
|
862
|
+
else
|
863
|
+
return( INT2NUM( 0 ) );
|
864
|
+
}
|
859
865
|
|
860
866
|
/*
|
861
867
|
* call-seq:
|
862
|
-
* ads_commit(VALUE imp_drh, VALUE ads_conn) -> VALUE result
|
868
|
+
* ads_commit( VALUE imp_drh, VALUE ads_conn ) -> VALUE result
|
863
869
|
*
|
864
870
|
* Commits the current transaction.
|
865
871
|
*
|
866
872
|
* <b>Parameters</b>:
|
867
873
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
868
|
-
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
|
874
|
+
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
|
869
875
|
*
|
870
876
|
* <b>Returns</b>:
|
871
877
|
* - <tt>VALUE result</tt>: <tt>1</tt> on successful commit, <tt>0</tt> otherwise.
|
872
878
|
*
|
873
879
|
*/
|
874
880
|
static VALUE
|
875
|
-
static_AdvantageInterface_ads_commit(VALUE imp_drh, VALUE ads_conn)
|
876
|
-
{
|
877
|
-
|
878
|
-
|
879
|
-
|
881
|
+
static_AdvantageInterface_ads_commit( VALUE imp_drh, VALUE ads_conn )
|
882
|
+
{
|
883
|
+
imp_drh_st* s_imp_drh;
|
884
|
+
a_ads_connection* s_ads_conn;
|
885
|
+
UNSIGNED32 result;
|
880
886
|
|
881
|
-
|
882
|
-
|
887
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
888
|
+
Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
|
883
889
|
|
884
|
-
|
890
|
+
result = s_imp_drh->api.ads_commit( s_ads_conn );
|
885
891
|
|
886
|
-
|
887
|
-
}
|
892
|
+
return( INT2NUM( result ) );
|
893
|
+
}
|
888
894
|
|
889
895
|
|
890
896
|
/*
|
891
897
|
* call-seq:
|
892
|
-
* ads_rollback(VALUE imp_drh, VALUE ads_conn) -> VALUE result
|
898
|
+
* ads_rollback( VALUE imp_drh, VALUE ads_conn ) -> VALUE result
|
893
899
|
*
|
894
900
|
* Rolls back the current transaction.
|
895
901
|
*
|
896
902
|
* <b>Parameters</b>:
|
897
903
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
898
|
-
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
|
904
|
+
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
|
899
905
|
*
|
900
906
|
* <b>Returns</b>:
|
901
907
|
* - <tt>VALUE result</tt>: <tt>1</tt> on successful rollback, <tt>0</tt> otherwise.
|
902
908
|
*
|
903
909
|
*/
|
904
910
|
static VALUE
|
905
|
-
static_AdvantageInterface_ads_rollback(VALUE imp_drh, VALUE ads_conn)
|
906
|
-
{
|
907
|
-
|
908
|
-
|
909
|
-
|
911
|
+
static_AdvantageInterface_ads_rollback( VALUE imp_drh, VALUE ads_conn )
|
912
|
+
{
|
913
|
+
imp_drh_st* s_imp_drh;
|
914
|
+
a_ads_connection* s_ads_conn;
|
915
|
+
UNSIGNED32 result;
|
910
916
|
|
911
|
-
|
912
|
-
|
917
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
918
|
+
Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
|
913
919
|
|
914
|
-
|
920
|
+
result = s_imp_drh->api.ads_rollback( s_ads_conn );
|
915
921
|
|
916
|
-
|
917
|
-
}
|
922
|
+
return( INT2NUM( result ) );
|
923
|
+
}
|
918
924
|
|
919
925
|
/*
|
920
926
|
* call-seq:
|
921
|
-
* ads_prepare(VALUE imp_drh, VALUE ads_conn, VALUE sql) -> VALUE stmt
|
927
|
+
* ads_prepare( VALUE imp_drh, VALUE ads_conn, VALUE sql ) -> VALUE stmt
|
922
928
|
*
|
923
929
|
* Prepares a SQL statement.
|
924
930
|
*
|
925
931
|
* This function prepares the supplied SQL string. Execution does not
|
926
|
-
* happen until ads_execute() is called. The returned statement object
|
927
|
-
* should be freed using ads_free_stmt().
|
932
|
+
* happen until ads_execute( ) is called. The returned statement object
|
933
|
+
* should be freed using ads_free_stmt( ).
|
928
934
|
*
|
929
935
|
*
|
930
936
|
* <b>Parameters</b>:
|
931
937
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
932
|
-
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
|
938
|
+
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
|
933
939
|
* - <tt>VALUE sql</tt> -- SQL query to prepare.
|
934
940
|
*
|
935
941
|
* <b>Returns</b>:
|
936
|
-
* - <tt>VALUE stmt</tt>: A statement object, or nil on failure. The statement object can be used by ads_execute() to execute the statement.
|
942
|
+
* - <tt>VALUE stmt</tt>: A statement object, or nil on failure. The statement object can be used by ads_execute( ) to execute the statement.
|
937
943
|
*
|
938
944
|
*/
|
939
945
|
static VALUE
|
940
|
-
static_AdvantageInterface_ads_prepare(VALUE imp_drh, VALUE ads_conn, VALUE sql)
|
941
|
-
{
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
VALUE tdata;
|
946
|
+
static_AdvantageInterface_ads_prepare( VALUE imp_drh, VALUE ads_conn, VALUE sql )
|
947
|
+
{
|
948
|
+
imp_drh_st* s_imp_drh;
|
949
|
+
a_ads_connection* s_ads_conn;
|
950
|
+
ADSHANDLE s_stmt = 0;
|
951
|
+
char* s_sql;
|
952
|
+
VALUE tdata;
|
948
953
|
|
949
|
-
|
954
|
+
s_sql = StringValueCStr( sql );
|
950
955
|
|
951
|
-
|
952
|
-
|
956
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
957
|
+
Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
|
953
958
|
|
954
|
-
|
955
|
-
|
959
|
+
//EJS Passing FALSE for isUnicode
|
960
|
+
s_stmt = s_imp_drh->api.ads_prepare( s_ads_conn, ( UNSIGNED8* )s_sql, '\0' );
|
956
961
|
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
962
|
+
if( s_stmt )
|
963
|
+
{
|
964
|
+
tdata = INT2NUM( s_stmt );
|
965
|
+
}
|
966
|
+
else
|
967
|
+
{
|
968
|
+
tdata = Qnil;
|
969
|
+
}
|
965
970
|
|
966
|
-
|
967
|
-
}
|
971
|
+
return( tdata );
|
972
|
+
}
|
968
973
|
|
969
974
|
/*
|
970
975
|
* call-seq:
|
971
|
-
* ads_free_stmt(VALUE imp_drh, VALUE ads_stmt) -> nil
|
976
|
+
* ads_free_stmt( VALUE imp_drh, VALUE ads_stmt ) -> nil
|
972
977
|
*
|
973
978
|
* Frees resources associated with a prepared statement object.
|
974
979
|
*
|
@@ -977,116 +982,134 @@ static_AdvantageInterface_ads_prepare(VALUE imp_drh, VALUE ads_conn, VALUE sql)
|
|
977
982
|
*
|
978
983
|
* <b>Parameters</b>:
|
979
984
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
980
|
-
* - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
|
985
|
+
* - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare( ) or ads_execute_direct( ).
|
981
986
|
*
|
982
987
|
* <b>Returns</b>:
|
983
988
|
* - <tt>nil</tt>.
|
984
989
|
*
|
985
990
|
*/
|
986
991
|
static VALUE
|
987
|
-
static_AdvantageInterface_ads_free_stmt(VALUE imp_drh, VALUE ads_stmt)
|
988
|
-
{
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
992
|
+
static_AdvantageInterface_ads_free_stmt( VALUE imp_drh, VALUE ads_stmt )
|
993
|
+
{
|
994
|
+
imp_drh_st* s_imp_drh;
|
995
|
+
ADSHANDLE s_stmt;
|
996
|
+
int i;
|
997
|
+
int number_of_params = 0;
|
998
|
+
a_ads_bind_param_info bind_info;
|
994
999
|
|
995
|
-
|
996
|
-
|
997
|
-
|
1000
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
1001
|
+
//Data_Get_Struct( ads_stmt, ADSHANDLE, s_ads_stmt );
|
1002
|
+
s_stmt = NUM2ULONG( ads_stmt );
|
998
1003
|
|
999
|
-
|
1004
|
+
number_of_params = s_imp_drh->api.ads_num_params( s_stmt );
|
1000
1005
|
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1006
|
+
for( i = 0; i < number_of_params; i++ )
|
1007
|
+
{
|
1008
|
+
if( s_imp_drh->api.ads_get_bind_param_info( s_stmt, i, &bind_info ) )
|
1009
|
+
{
|
1010
|
+
// We don't free bind_info.name as it's not allocated
|
1011
|
+
// if ( bind_info.name ) {free ( bind_info.name );}
|
1012
|
+
|
1013
|
+
if( bind_info.input_value.is_null )
|
1014
|
+
{
|
1015
|
+
free( bind_info.input_value.is_null );
|
1016
|
+
}
|
1017
|
+
if( bind_info.input_value.length )
|
1018
|
+
{
|
1019
|
+
free( bind_info.input_value.length );
|
1020
|
+
}
|
1021
|
+
if( bind_info.input_value.buffer )
|
1022
|
+
{
|
1023
|
+
free( bind_info.input_value.buffer );
|
1024
|
+
}
|
1025
|
+
|
1026
|
+
if( bind_info.output_value.is_null )
|
1027
|
+
{
|
1028
|
+
free( bind_info.output_value.is_null );
|
1029
|
+
}
|
1030
|
+
if( bind_info.output_value.length )
|
1031
|
+
{
|
1032
|
+
free( bind_info.output_value.length );
|
1033
|
+
}
|
1034
|
+
if( bind_info.output_value.buffer )
|
1035
|
+
{
|
1036
|
+
free( bind_info.output_value.buffer );
|
1037
|
+
}
|
1038
|
+
}
|
1039
|
+
}
|
1017
1040
|
|
1018
|
-
|
1041
|
+
s_imp_drh->api.ads_free_stmt( s_stmt );
|
1019
1042
|
|
1020
|
-
|
1021
|
-
}
|
1043
|
+
return( Qnil );
|
1044
|
+
}
|
1022
1045
|
|
1023
1046
|
/*
|
1024
1047
|
* call-seq:
|
1025
|
-
* ads_reset(VALUE imp_drh, VALUE ads_stmt) -> VALUE result
|
1048
|
+
* ads_reset( VALUE imp_drh, VALUE ads_stmt ) -> VALUE result
|
1026
1049
|
*
|
1027
1050
|
*
|
1028
1051
|
* <b>Parameters</b>:
|
1029
1052
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
1030
|
-
* - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
|
1053
|
+
* - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare( ) or ads_execute_direct( ).
|
1031
1054
|
*
|
1032
1055
|
* <b>Returns</b>:
|
1033
1056
|
* - <tt>VALUE result</tt>: <tt>1</tt> on successful execution, <tt>0</tt> otherwise.
|
1034
1057
|
*
|
1035
1058
|
*/
|
1036
1059
|
static VALUE
|
1037
|
-
static_AdvantageInterface_ads_reset(VALUE imp_drh, VALUE ads_stmt)
|
1038
|
-
{
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1060
|
+
static_AdvantageInterface_ads_reset( VALUE imp_drh, VALUE ads_stmt )
|
1061
|
+
{
|
1062
|
+
imp_drh_st* s_imp_drh;
|
1063
|
+
ADSHANDLE s_stmt;
|
1064
|
+
UNSIGNED32 result;
|
1042
1065
|
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1066
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
1067
|
+
//Data_Get_Struct( ads_stmt, ADSHANDLE, s_ads_stmt );
|
1068
|
+
s_stmt = NUM2ULONG( ads_stmt );
|
1046
1069
|
|
1047
|
-
|
1070
|
+
result = s_imp_drh->api.ads_reset( s_stmt );
|
1048
1071
|
|
1049
|
-
|
1050
|
-
}
|
1072
|
+
return( INT2NUM( result ) );
|
1073
|
+
}
|
1051
1074
|
|
1052
1075
|
|
1053
1076
|
/*
|
1054
1077
|
* call-seq:
|
1055
|
-
* ads_execute(VALUE imp_drh, VALUE ads_stmt) -> VALUE result
|
1078
|
+
* ads_execute( VALUE imp_drh, VALUE ads_stmt ) -> VALUE result
|
1056
1079
|
*
|
1057
1080
|
* Executes a prepared statement.
|
1058
1081
|
*
|
1059
1082
|
* <b>Parameters</b>:
|
1060
1083
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
1061
|
-
* - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
|
1084
|
+
* - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare( ) or ads_execute_direct( ).
|
1062
1085
|
*
|
1063
1086
|
* <b>Returns</b>:
|
1064
1087
|
* - <tt>VALUE result</tt>: <tt>1</tt> on successful execution, <tt>0</tt> otherwise.
|
1065
1088
|
*
|
1066
1089
|
*/
|
1067
1090
|
static VALUE
|
1068
|
-
static_AdvantageInterface_ads_execute(VALUE imp_drh, VALUE ads_stmt)
|
1069
|
-
{
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
}
|
1091
|
+
static_AdvantageInterface_ads_execute( VALUE imp_drh, VALUE ads_stmt )
|
1092
|
+
{
|
1093
|
+
imp_drh_st* s_imp_drh;
|
1094
|
+
ADSHANDLE s_stmt;
|
1095
|
+
UNSIGNED32 result;
|
1096
|
+
|
1097
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
1098
|
+
//Data_Get_Struct( ads_stmt, ADSHANDLE, s_ads_stmt );
|
1099
|
+
s_stmt = NUM2ULONG( ads_stmt );
|
1100
|
+
|
1101
|
+
//printf( "CEXT s_ads_stmt: %d \n", s_stmt );
|
1102
|
+
result = s_imp_drh->api.ads_execute( s_stmt );
|
1103
|
+
/*if ( result != AE_SUCCESS )
|
1104
|
+
return ( 0 );
|
1105
|
+
else
|
1106
|
+
return ( 1 );*/
|
1107
|
+
return( INT2NUM( result ) );
|
1108
|
+
}
|
1086
1109
|
|
1087
1110
|
/*
|
1088
1111
|
* call-seq:
|
1089
|
-
* ads_affected_rows(VALUE imp_drh, VALUE ads_stmt) -> VALUE result
|
1112
|
+
* ads_affected_rows( VALUE imp_drh, VALUE ads_stmt ) -> VALUE result
|
1090
1113
|
*
|
1091
1114
|
* Returns the number of rows affected by execution of the prepared
|
1092
1115
|
* statement.
|
@@ -1100,37 +1123,37 @@ static_AdvantageInterface_ads_execute(VALUE imp_drh, VALUE ads_stmt)
|
|
1100
1123
|
*
|
1101
1124
|
*/
|
1102
1125
|
static VALUE
|
1103
|
-
static_AdvantageInterface_ads_affected_rows(VALUE imp_drh, VALUE ads_stmt)
|
1104
|
-
{
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1126
|
+
static_AdvantageInterface_ads_affected_rows( VALUE imp_drh, VALUE ads_stmt )
|
1127
|
+
{
|
1128
|
+
imp_drh_st* s_imp_drh;
|
1129
|
+
ADSHANDLE s_stmt;
|
1130
|
+
UNSIGNED32 result;
|
1108
1131
|
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1132
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
1133
|
+
//Data_Get_Struct( ads_stmt, ADSHANDLE, s_ads_stmt );
|
1134
|
+
s_stmt = NUM2ULONG( ads_stmt );
|
1112
1135
|
|
1113
|
-
|
1136
|
+
result = s_imp_drh->api.ads_affected_rows( s_stmt );
|
1114
1137
|
|
1115
|
-
|
1116
|
-
}
|
1138
|
+
return( INT2NUM( result ) );
|
1139
|
+
}
|
1117
1140
|
|
1118
1141
|
/*
|
1119
1142
|
* call-seq:
|
1120
|
-
* ads_describe_bind_param(VALUE imp_drh, VALUE ads_stmt, VALUE index) -> [VALUE result, VALUE bind_param]
|
1143
|
+
* ads_describe_bind_param( VALUE imp_drh, VALUE ads_stmt, VALUE index ) -> [VALUE result, VALUE bind_param]
|
1121
1144
|
*
|
1122
1145
|
* Describes the bind parameters of a prepared statement.
|
1123
1146
|
*
|
1124
1147
|
* This function allows the caller to determine information about parameters
|
1125
1148
|
* to a prepared statement. Depending on the type of the prepared statement
|
1126
|
-
* (call to stored procedure or a DML), only some information will be
|
1149
|
+
* ( call to stored procedure or a DML ), only some information will be
|
1127
1150
|
* provided. The information that will always be provided is the direction
|
1128
|
-
* of the parameters (input, output, or input-output).
|
1151
|
+
* of the parameters ( input, output, or input-output ).
|
1129
1152
|
*
|
1130
1153
|
* <b>Parameters</b>:
|
1131
1154
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
1132
|
-
* - <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare().
|
1133
|
-
* - <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and ads_num_params()- 1.
|
1155
|
+
* - <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare( ).
|
1156
|
+
* - <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and ads_num_params( )- 1.
|
1134
1157
|
*
|
1135
1158
|
* <b>Returns</b>:
|
1136
1159
|
* - <tt>VALUE result</tt>: <tt>1</tt> on success or <tt>0</tt> on failure.
|
@@ -1138,86 +1161,86 @@ static_AdvantageInterface_ads_affected_rows(VALUE imp_drh, VALUE ads_stmt)
|
|
1138
1161
|
*
|
1139
1162
|
*/
|
1140
1163
|
static VALUE
|
1141
|
-
static_AdvantageInterface_ads_describe_bind_param(VALUE imp_drh, VALUE ads_stmt, VALUE index)
|
1142
|
-
{
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1164
|
+
static_AdvantageInterface_ads_describe_bind_param( VALUE imp_drh, VALUE ads_stmt, VALUE index )
|
1165
|
+
{
|
1166
|
+
imp_drh_st* s_imp_drh;
|
1167
|
+
ADSHANDLE s_stmt;
|
1168
|
+
a_ads_bind_param* s_ads_bind_param;
|
1169
|
+
UNSIGNED32 result;
|
1170
|
+
UNSIGNED32 s_index;
|
1171
|
+
VALUE tdata;
|
1172
|
+
VALUE multi_result;
|
1150
1173
|
|
1151
|
-
|
1152
|
-
|
1174
|
+
s_ads_bind_param = malloc( sizeof( a_ads_bind_param ) );
|
1175
|
+
memset( s_ads_bind_param, 0, sizeof( a_ads_bind_param ) );
|
1153
1176
|
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1177
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
1178
|
+
s_stmt = NUM2ULONG( ads_stmt );
|
1179
|
+
s_index = NUM2INT( index );
|
1157
1180
|
|
1158
|
-
|
1181
|
+
result = s_imp_drh->api.ads_describe_bind_param( s_stmt, s_index, s_ads_bind_param );
|
1159
1182
|
|
1160
|
-
|
1183
|
+
//FIXME handle failed result
|
1161
1184
|
|
1162
|
-
|
1185
|
+
multi_result = rb_ary_new( );
|
1163
1186
|
|
1164
|
-
|
1187
|
+
rb_ary_push( multi_result, INT2NUM( result ) );
|
1165
1188
|
|
1166
|
-
|
1167
|
-
|
1189
|
+
tdata = Data_Wrap_Struct( cA_ads_bind_param, 0, 0, s_ads_bind_param );
|
1190
|
+
rb_ary_push( multi_result, tdata );
|
1168
1191
|
|
1169
|
-
|
1170
|
-
}
|
1192
|
+
return( multi_result );
|
1193
|
+
}
|
1171
1194
|
|
1172
1195
|
/*
|
1173
1196
|
* call-seq:
|
1174
|
-
* ads_bind_param(VALUE imp_drh, VALUE ads_stmt, VALUE index, VALUE ads_bind_param) -> VALUE result
|
1197
|
+
* ads_bind_param( VALUE imp_drh, VALUE ads_stmt, VALUE index, VALUE ads_bind_param ) -> VALUE result
|
1175
1198
|
*
|
1176
1199
|
* Binds a user supplied buffer as a parameter to the prepared statement.
|
1177
1200
|
*
|
1178
1201
|
* <b>Parameters</b>:
|
1179
1202
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
1180
|
-
* - <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare().
|
1181
|
-
* - <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and ads_num_params() - 1.
|
1182
|
-
* - <tt>VALUE ads_bind_param</tt> -- A filled bind object retrieved from ads_describe_bind_param().
|
1203
|
+
* - <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare( ).
|
1204
|
+
* - <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and ads_num_params( ) - 1.
|
1205
|
+
* - <tt>VALUE ads_bind_param</tt> -- A filled bind object retrieved from ads_describe_bind_param( ).
|
1183
1206
|
*
|
1184
1207
|
* <b>Returns</b>:
|
1185
1208
|
* - <tt>VALUE result</tt>: <tt>1</tt> on success or <tt>0</tt> on failure.
|
1186
1209
|
*
|
1187
1210
|
*/
|
1188
1211
|
static VALUE
|
1189
|
-
static_AdvantageInterface_ads_bind_param(VALUE imp_drh, VALUE ads_stmt, VALUE index, VALUE ads_bind_param
|
1190
|
-
{
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1212
|
+
static_AdvantageInterface_ads_bind_param( VALUE imp_drh, VALUE ads_stmt, VALUE index, VALUE ads_bind_param )
|
1213
|
+
{
|
1214
|
+
imp_drh_st* s_imp_drh;
|
1215
|
+
ADSHANDLE s_stmt;
|
1216
|
+
a_ads_bind_param* s_ads_bind_param;
|
1217
|
+
UNSIGNED32 result;
|
1218
|
+
UNSIGNED32 s_index;
|
1196
1219
|
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1220
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
1221
|
+
//Data_Get_Struct( ads_stmt, ADSHANDLE, s_ads_stmt );
|
1222
|
+
s_stmt = NUM2ULONG( ads_stmt );
|
1223
|
+
Data_Get_Struct( ads_bind_param, a_ads_bind_param, s_ads_bind_param );
|
1224
|
+
s_index = NUM2INT( index );
|
1202
1225
|
|
1203
|
-
|
1226
|
+
result = s_imp_drh->api.ads_bind_param( s_stmt, s_index, s_ads_bind_param );
|
1204
1227
|
|
1205
|
-
|
1206
|
-
}
|
1228
|
+
return( INT2NUM( result ) );
|
1229
|
+
}
|
1207
1230
|
|
1208
1231
|
/*
|
1209
1232
|
* call-seq:
|
1210
|
-
* ads_get_bind_param_info(VALUE imp_drh, VALUE ads_stmt, VALUE index) -> [VALUE result, VALUE bind_param]
|
1233
|
+
* ads_get_bind_param_info( VALUE imp_drh, VALUE ads_stmt, VALUE index ) -> [VALUE result, VALUE bind_param]
|
1211
1234
|
*
|
1212
1235
|
* Gets bound parameter info.
|
1213
1236
|
*
|
1214
1237
|
* This function retrieves information about the parameters that were
|
1215
|
-
* bound using ads_bind_param().
|
1238
|
+
* bound using ads_bind_param( ).
|
1216
1239
|
*
|
1217
1240
|
* <b>Parameters</b>:
|
1218
1241
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
1219
|
-
* - <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare().
|
1220
|
-
* - <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and ads_num_params() - 1.
|
1242
|
+
* - <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare( ).
|
1243
|
+
* - <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and ads_num_params( ) - 1.
|
1221
1244
|
*
|
1222
1245
|
* <b>Returns</b>:
|
1223
1246
|
* - <tt>VALUE result</tt>: <tt>1</tt> on success or <tt>0</tt> on failure.
|
@@ -1225,105 +1248,105 @@ static_AdvantageInterface_ads_bind_param(VALUE imp_drh, VALUE ads_stmt, VALUE in
|
|
1225
1248
|
*
|
1226
1249
|
*/
|
1227
1250
|
static VALUE
|
1228
|
-
static_AdvantageInterface_ads_get_bind_param_info(VALUE imp_drh, VALUE ads_stmt, VALUE index)
|
1229
|
-
{
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1251
|
+
static_AdvantageInterface_ads_get_bind_param_info( VALUE imp_drh, VALUE ads_stmt, VALUE index )
|
1252
|
+
{
|
1253
|
+
imp_drh_st* s_imp_drh;
|
1254
|
+
ADSHANDLE s_stmt;
|
1255
|
+
a_ads_bind_param_info s_ads_bind_param_info;
|
1256
|
+
UNSIGNED32 result;
|
1257
|
+
UNSIGNED32 s_index;
|
1258
|
+
VALUE tdata;
|
1259
|
+
VALUE multi_result;
|
1237
1260
|
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1261
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
1262
|
+
s_stmt = NUM2ULONG( ads_stmt );
|
1263
|
+
s_index = NUM2INT( index );
|
1241
1264
|
|
1242
|
-
|
1265
|
+
result = s_imp_drh->api.ads_get_bind_param_info( s_stmt, s_index, &s_ads_bind_param_info );
|
1243
1266
|
|
1244
|
-
|
1245
|
-
|
1267
|
+
//FIXME handle failed result
|
1268
|
+
multi_result = rb_ary_new( );
|
1246
1269
|
|
1247
|
-
|
1270
|
+
rb_ary_push( multi_result, INT2NUM( result ) );
|
1248
1271
|
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1272
|
+
// FIXME: Is this safe to be on the stack?
|
1273
|
+
tdata = Data_Wrap_Struct( cA_ads_bind_param_info, 0, 0, &s_ads_bind_param_info );
|
1274
|
+
rb_ary_push( multi_result, tdata );
|
1252
1275
|
|
1253
|
-
|
1254
|
-
}
|
1276
|
+
return( multi_result );
|
1277
|
+
}
|
1255
1278
|
|
1256
1279
|
/*
|
1257
1280
|
* call-seq:
|
1258
|
-
* ads_num_params(VALUE imp_drh, VALUE ads_stmt) -> VALUE result
|
1281
|
+
* ads_num_params( VALUE imp_drh, VALUE ads_stmt ) -> VALUE result
|
1259
1282
|
*
|
1260
1283
|
* Returns the number of parameters that are expected for a prepared
|
1261
1284
|
* statement.
|
1262
1285
|
*
|
1263
1286
|
* This function retrieves information about the parameters that were bound
|
1264
|
-
* using ads_bind_param().
|
1287
|
+
* using ads_bind_param( ).
|
1265
1288
|
*
|
1266
1289
|
* <b>Parameters</b>:
|
1267
1290
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
1268
|
-
* - <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare().
|
1291
|
+
* - <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare( ).
|
1269
1292
|
*
|
1270
1293
|
* <b>Returns</b>:
|
1271
1294
|
* - <tt>VALUE result</tt>: The number of parameters that are expected. <tt>-1</tt> if the ads_stmt object is not valid.
|
1272
1295
|
*
|
1273
1296
|
*/
|
1274
1297
|
static VALUE
|
1275
|
-
static_AdvantageInterface_ads_num_params(VALUE imp_drh, VALUE ads_stmt)
|
1276
|
-
{
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1298
|
+
static_AdvantageInterface_ads_num_params( VALUE imp_drh, VALUE ads_stmt )
|
1299
|
+
{
|
1300
|
+
imp_drh_st* s_imp_drh;
|
1301
|
+
ADSHANDLE s_stmt;
|
1302
|
+
UNSIGNED32 result;
|
1280
1303
|
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1304
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
1305
|
+
//Data_Get_Struct( ads_stmt, ADSHANDLE, s_ads_stmt );
|
1306
|
+
s_stmt = NUM2ULONG( ads_stmt );
|
1284
1307
|
|
1285
|
-
|
1308
|
+
result = s_imp_drh->api.ads_num_params( s_stmt );
|
1286
1309
|
|
1287
|
-
|
1288
|
-
}
|
1310
|
+
return( INT2NUM( result ) );
|
1311
|
+
}
|
1289
1312
|
|
1290
1313
|
/*
|
1291
1314
|
* call-seq:
|
1292
|
-
* ads_get_next_result(VALUE imp_drh, VALUE ads_stmt) -> VALUE result
|
1315
|
+
* ads_get_next_result( VALUE imp_drh, VALUE ads_stmt ) -> VALUE result
|
1293
1316
|
*
|
1294
1317
|
* Advances to the next result set in a multiple result set query.
|
1295
1318
|
*
|
1296
|
-
* If a query (such as a call to a stored procedure) returns multiple result
|
1319
|
+
* If a query ( such as a call to a stored procedure ) returns multiple result
|
1297
1320
|
* sets, then this function advances from the current result set to the next.
|
1298
1321
|
*
|
1299
1322
|
*
|
1300
1323
|
* <b>Parameters</b>:
|
1301
1324
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
1302
|
-
* - <tt>VALUE ads_stmt</tt> -- A statement object that was executed by ads_execute() or ads_execute_direct().
|
1325
|
+
* - <tt>VALUE ads_stmt</tt> -- A statement object that was executed by ads_execute( ) or ads_execute_direct( ).
|
1303
1326
|
*
|
1304
1327
|
* <b>Returns</b>:
|
1305
1328
|
* - <tt>VALUE result</tt>: <tt>1</tt> if was successfully able to advance to the next result set, <tt>0</tt> otherwise.
|
1306
1329
|
*
|
1307
1330
|
*/
|
1308
1331
|
static VALUE
|
1309
|
-
static_AdvantageInterface_ads_get_next_result(VALUE imp_drh, VALUE ads_stmt)
|
1310
|
-
{
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1332
|
+
static_AdvantageInterface_ads_get_next_result( VALUE imp_drh, VALUE ads_stmt )
|
1333
|
+
{
|
1334
|
+
imp_drh_st* s_imp_drh;
|
1335
|
+
ADSHANDLE s_stmt;
|
1336
|
+
UNSIGNED32 result;
|
1314
1337
|
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1338
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
1339
|
+
//Data_Get_Struct( ads_stmt, ADSHANDLE, s_ads_stmt );
|
1340
|
+
s_stmt = NUM2ULONG( ads_stmt );
|
1318
1341
|
|
1319
|
-
|
1342
|
+
result = s_imp_drh->api.ads_get_next_result( s_stmt );
|
1320
1343
|
|
1321
|
-
|
1322
|
-
}
|
1344
|
+
return( INT2NUM( result ) );
|
1345
|
+
}
|
1323
1346
|
|
1324
1347
|
/*
|
1325
1348
|
* call-seq:
|
1326
|
-
* ads_fetch_absolute(VALUE imp_drh, VALUE ads_stmt, VALUE offset) -> VALUE result
|
1349
|
+
* ads_fetch_absolute( VALUE imp_drh, VALUE ads_stmt, VALUE offset ) -> VALUE result
|
1327
1350
|
*
|
1328
1351
|
* Fetches data at a specific row number in the result set.
|
1329
1352
|
*
|
@@ -1332,7 +1355,7 @@ static_AdvantageInterface_ads_get_next_result(VALUE imp_drh, VALUE ads_stmt)
|
|
1332
1355
|
*
|
1333
1356
|
* <b>Parameters</b>:
|
1334
1357
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
1335
|
-
* - <tt>VALUE ads_stmt</tt> -- A statement object that was executed by ads_execute() or ads_execute_direct().
|
1358
|
+
* - <tt>VALUE ads_stmt</tt> -- A statement object that was executed by ads_execute( ) or ads_execute_direct( ).
|
1336
1359
|
* - <tt>VALUE offset</tt> -- The row number to be fetched. The first row is <tt>1</tt>, the last row is <tt>-1</tt>.
|
1337
1360
|
*
|
1338
1361
|
* <b>Returns</b>:
|
@@ -1340,108 +1363,107 @@ static_AdvantageInterface_ads_get_next_result(VALUE imp_drh, VALUE ads_stmt)
|
|
1340
1363
|
*
|
1341
1364
|
*/
|
1342
1365
|
static VALUE
|
1343
|
-
static_AdvantageInterface_ads_fetch_absolute(VALUE imp_drh, VALUE ads_stmt, VALUE offset)
|
1344
|
-
{
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1366
|
+
static_AdvantageInterface_ads_fetch_absolute( VALUE imp_drh, VALUE ads_stmt, VALUE offset )
|
1367
|
+
{
|
1368
|
+
imp_drh_st* s_imp_drh;
|
1369
|
+
ADSHANDLE s_stmt;
|
1370
|
+
UNSIGNED32 s_offset;
|
1371
|
+
UNSIGNED32 result;
|
1349
1372
|
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1373
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
1374
|
+
//Data_Get_Struct( ads_stmt, ADSHANDLE, s_ads_stmt );
|
1375
|
+
s_stmt = NUM2ULONG( ads_stmt );
|
1376
|
+
s_offset = NUM2INT( offset );
|
1377
|
+
result = s_imp_drh->api.ads_fetch_absolute( s_stmt, s_offset );
|
1355
1378
|
|
1356
|
-
|
1357
|
-
}
|
1379
|
+
return( INT2NUM( result ) );
|
1380
|
+
}
|
1358
1381
|
|
1359
1382
|
/*
|
1360
1383
|
* call-seq:
|
1361
|
-
* ads_sqlstate(VALUE imp_drh, VALUE ads_conn) -> VALUE sqlstate_str
|
1384
|
+
* ads_sqlstate( VALUE imp_drh, VALUE ads_conn ) -> VALUE sqlstate_str
|
1362
1385
|
*
|
1363
1386
|
* Retrieves the current SQL state.
|
1364
1387
|
*
|
1365
1388
|
* <b>Parameters</b>:
|
1366
1389
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
1367
|
-
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
|
1390
|
+
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
|
1368
1391
|
*
|
1369
1392
|
* <b>Returns</b>:
|
1370
1393
|
* - <tt>VALUE sqlstate_str</tt>: The SQL State.
|
1371
1394
|
*
|
1372
1395
|
*/
|
1373
1396
|
static VALUE
|
1374
|
-
static_AdvantageInterface_ads_sqlstate(VALUE imp_drh, VALUE ads_conn)
|
1375
|
-
{
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
char s_buffer[255];
|
1397
|
+
static_AdvantageInterface_ads_sqlstate( VALUE imp_drh, VALUE ads_conn )
|
1398
|
+
{
|
1399
|
+
imp_drh_st* s_imp_drh;
|
1400
|
+
a_ads_connection* s_ads_conn;
|
1401
|
+
UNSIGNED32 result;
|
1402
|
+
char s_buffer[255];
|
1381
1403
|
|
1382
|
-
|
1383
|
-
|
1404
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
1405
|
+
Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
|
1384
1406
|
|
1385
|
-
|
1407
|
+
result = s_imp_drh->api.ads_sqlstate( s_ads_conn, ( UNSIGNED8* )s_buffer, sizeof( s_buffer ) );
|
1386
1408
|
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
}
|
1409
|
+
if( result )
|
1410
|
+
return( rb_str_new( s_buffer, strlen( s_buffer ) ) );
|
1411
|
+
else
|
1412
|
+
return Qnil;
|
1413
|
+
}
|
1392
1414
|
|
1393
1415
|
/*
|
1394
1416
|
* call-seq:
|
1395
|
-
* ads_clear_error(VALUE imp_drh, VALUE ads_conn) -> nil
|
1417
|
+
* ads_clear_error( VALUE imp_drh, VALUE ads_conn ) -> nil
|
1396
1418
|
*
|
1397
1419
|
* Clears the last stored error code.
|
1398
1420
|
*
|
1399
1421
|
* <b>Parameters</b>:
|
1400
1422
|
* - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
|
1401
|
-
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
|
1423
|
+
* - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
|
1402
1424
|
*
|
1403
1425
|
* <b>Returns</b>:
|
1404
1426
|
* - <tt>nil</tt>:.
|
1405
1427
|
*
|
1406
1428
|
*/
|
1407
1429
|
static VALUE
|
1408
|
-
static_AdvantageInterface_ads_clear_error(VALUE imp_drh, VALUE ads_conn)
|
1409
|
-
{
|
1410
|
-
|
1411
|
-
|
1430
|
+
static_AdvantageInterface_ads_clear_error( VALUE imp_drh, VALUE ads_conn )
|
1431
|
+
{
|
1432
|
+
imp_drh_st* s_imp_drh;
|
1433
|
+
a_ads_connection* s_ads_conn;
|
1412
1434
|
|
1413
|
-
|
1414
|
-
|
1435
|
+
Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
|
1436
|
+
Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
|
1415
1437
|
|
1416
|
-
|
1438
|
+
s_imp_drh->api.ads_clear_error( s_ads_conn );
|
1417
1439
|
|
1418
|
-
|
1419
|
-
}
|
1440
|
+
return( Qnil );
|
1441
|
+
}
|
1420
1442
|
|
1421
1443
|
/*
|
1422
1444
|
* call-seq:
|
1423
|
-
* get_name(VALUE bind) -> VALUE name
|
1445
|
+
* get_name( VALUE bind ) -> VALUE name
|
1424
1446
|
*
|
1425
1447
|
* Gets the name of the bound parameter.
|
1426
1448
|
*
|
1427
1449
|
* <b>Parameters</b>:
|
1428
|
-
* - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param().
|
1450
|
+
* - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param( ).
|
1429
1451
|
*
|
1430
1452
|
* <b>Returns</b>:
|
1431
1453
|
* - <tt>VALUE name</tt>: The bound variable's name.
|
1432
1454
|
*
|
1433
1455
|
*/
|
1434
1456
|
static VALUE
|
1435
|
-
static_Bind_get_name(VALUE bind)
|
1436
|
-
{
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
}
|
1457
|
+
static_Bind_get_name( VALUE bind )
|
1458
|
+
{
|
1459
|
+
a_ads_bind_param* s_bind;
|
1460
|
+
Data_Get_Struct( bind, a_ads_bind_param, s_bind );
|
1461
|
+
return( rb_str_new2( ( char* )s_bind->name ) );
|
1462
|
+
}
|
1441
1463
|
|
1442
1464
|
/*
|
1443
1465
|
* call-seq:
|
1444
|
-
* set_value(VALUE bind, VALUE val) -> nil
|
1466
|
+
* set_value( VALUE bind, VALUE val ) -> nil
|
1445
1467
|
*
|
1446
1468
|
* Sets the value of a bind parameter.
|
1447
1469
|
*
|
@@ -1467,124 +1489,143 @@ static_Bind_get_name(VALUE bind)
|
|
1467
1489
|
* method twice, once to bind the INPUT, and once to bind the OUTPUT.
|
1468
1490
|
*
|
1469
1491
|
* <b>Parameters</b>:
|
1470
|
-
* - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param().
|
1492
|
+
* - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param( ).
|
1471
1493
|
* - <tt>VALUE val</tt> -- The value to bind into the bound variable.
|
1472
1494
|
*
|
1473
1495
|
* <b>Returns</b>:
|
1474
1496
|
* - <tt>nil</tt>.
|
1475
1497
|
*/
|
1476
1498
|
static VALUE
|
1477
|
-
static_Bind_set_value(VALUE bind, VALUE val)
|
1478
|
-
{
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1499
|
+
static_Bind_set_value( VALUE bind, VALUE val )
|
1500
|
+
{
|
1501
|
+
a_ads_bind_param* s_bind;
|
1502
|
+
int length;
|
1503
|
+
|
1504
|
+
Data_Get_Struct( bind, a_ads_bind_param, s_bind );
|
1505
|
+
|
1506
|
+
// FIXME: use Ruby's allocation routines?
|
1507
|
+
s_bind->value.is_null = malloc( sizeof( UNSIGNED32 ) );
|
1508
|
+
*s_bind->value.is_null = 0;
|
1509
|
+
|
1510
|
+
if( s_bind->direction == DD_INPUT )
|
1511
|
+
{
|
1512
|
+
switch( TYPE( val ) )
|
1513
|
+
{
|
1514
|
+
case T_STRING:
|
1515
|
+
s_bind->value.length = malloc( sizeof( size_t ) );
|
1516
|
+
length = RSTRING_LEN( val );
|
1517
|
+
*s_bind->value.length = length;
|
1518
|
+
s_bind->value.buffer = malloc( length );
|
1519
|
+
memcpy( s_bind->value.buffer, RSTRING_PTR( val ), length );
|
1520
|
+
s_bind->value.type = A_STRING;
|
1521
|
+
break;
|
1522
|
+
case T_FIXNUM:
|
1523
|
+
if( sizeof( void* ) == 4 ) //32-bit
|
1524
|
+
{
|
1525
|
+
s_bind->value.length = malloc( sizeof( size_t ) );
|
1526
|
+
s_bind->value.buffer = malloc( sizeof( int ) );
|
1527
|
+
*( ( int* )s_bind->value.buffer ) = FIX2INT( val );
|
1528
|
+
s_bind->value.type = A_VAL32;
|
1529
|
+
length = 1;
|
1530
|
+
*s_bind->value.length = length;
|
1531
|
+
}
|
1532
|
+
else //64-bit
|
1533
|
+
{
|
1534
|
+
s_bind->value.length = malloc( sizeof( size_t ) );
|
1535
|
+
s_bind->value.buffer = malloc( sizeof( long ) );
|
1536
|
+
*( ( long* )s_bind->value.buffer ) = FIX2LONG( val );
|
1537
|
+
s_bind->value.type = A_VAL64;
|
1538
|
+
length = 1;
|
1539
|
+
*s_bind->value.length = length;
|
1540
|
+
}
|
1541
|
+
break;
|
1542
|
+
case T_BIGNUM:
|
1543
|
+
s_bind->value.length = malloc( sizeof( size_t ) );
|
1544
|
+
s_bind->value.buffer = malloc( sizeof( LONG_LONG ) );
|
1545
|
+
*( ( LONG_LONG* )s_bind->value.buffer ) = rb_num2ll( val );
|
1512
1546
|
s_bind->value.type = A_VAL64;
|
1513
1547
|
length = 1;
|
1514
1548
|
*s_bind->value.length = length;
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
+
break;
|
1550
|
+
case T_FLOAT:
|
1551
|
+
s_bind->value.length = malloc( sizeof( size_t ) );
|
1552
|
+
s_bind->value.buffer = malloc( sizeof( double ) );
|
1553
|
+
*( ( double* )s_bind->value.buffer ) = NUM2DBL( val );
|
1554
|
+
s_bind->value.type = A_DOUBLE;
|
1555
|
+
length = 1;
|
1556
|
+
*s_bind->value.length = length;
|
1557
|
+
break;
|
1558
|
+
case T_FALSE:
|
1559
|
+
s_bind->value.length = malloc( sizeof( size_t ) );
|
1560
|
+
s_bind->value.buffer = malloc( sizeof( short ) );
|
1561
|
+
*( ( int* )s_bind->value.buffer ) = ADS_FALSE;
|
1562
|
+
s_bind->value.type = A_UVAL16;
|
1563
|
+
length = 1;
|
1564
|
+
*s_bind->value.length = length;
|
1565
|
+
break;
|
1566
|
+
case T_TRUE:
|
1567
|
+
s_bind->value.length = malloc( sizeof( size_t ) );
|
1568
|
+
s_bind->value.buffer = malloc( sizeof( short ) );
|
1569
|
+
*( ( int* )s_bind->value.buffer ) = ADS_TRUE;
|
1570
|
+
s_bind->value.type = A_UVAL16;
|
1571
|
+
length = 1;
|
1572
|
+
*s_bind->value.length = length;
|
1573
|
+
break;
|
1574
|
+
case T_NIL:
|
1575
|
+
s_bind->value.length = malloc( sizeof( size_t ) );
|
1576
|
+
*s_bind->value.is_null = 1;
|
1577
|
+
s_bind->value.buffer = malloc( sizeof( int ) );
|
1578
|
+
s_bind->value.type = A_VAL32;
|
1579
|
+
length = 1;
|
1580
|
+
*s_bind->value.length = length;
|
1581
|
+
break;
|
1582
|
+
default:
|
1583
|
+
rb_raise( rb_eTypeError, "Cannot convert type. Must be STRING, FIXNUM, BIGNUM, FLOAT, or NIL" );
|
1584
|
+
break;
|
1585
|
+
}
|
1586
|
+
}
|
1587
|
+
else
|
1549
1588
|
{
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1589
|
+
switch( s_bind->value.type )
|
1590
|
+
{
|
1591
|
+
case A_STRING:
|
1592
|
+
s_bind->value.buffer = malloc( s_bind->value.buffer_size );
|
1593
|
+
break;
|
1594
|
+
case A_DOUBLE:
|
1595
|
+
s_bind->value.buffer = malloc( sizeof( float ) );
|
1596
|
+
break;
|
1597
|
+
case A_VAL64:
|
1598
|
+
case A_UVAL64:
|
1599
|
+
s_bind->value.buffer = malloc( sizeof( LONG_LONG ) );
|
1600
|
+
break;
|
1560
1601
|
case A_VAL32:
|
1561
1602
|
case A_UVAL32:
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1603
|
+
s_bind->value.buffer = malloc( sizeof( int ) );
|
1604
|
+
break;
|
1605
|
+
case A_VAL16:
|
1606
|
+
case A_UVAL16:
|
1607
|
+
s_bind->value.buffer = malloc( sizeof( short ) );
|
1608
|
+
break;
|
1609
|
+
case A_VAL8:
|
1610
|
+
case A_UVAL8:
|
1611
|
+
s_bind->value.buffer = malloc( sizeof( char ) );
|
1612
|
+
break;
|
1613
|
+
default:
|
1614
|
+
rb_raise( rb_eTypeError, "Type unknown" );
|
1615
|
+
break;
|
1616
|
+
}
|
1575
1617
|
}
|
1576
|
-
|
1577
|
-
|
1578
|
-
}
|
1618
|
+
return( Qnil );
|
1619
|
+
}
|
1579
1620
|
|
1580
1621
|
/*
|
1581
1622
|
* call-seq:
|
1582
|
-
* set_direction(VALUE bind, VALUE direction) -> nil
|
1623
|
+
* set_direction( VALUE bind, VALUE direction ) -> nil
|
1583
1624
|
*
|
1584
1625
|
* Sets the direction of the bound parameter before binding.
|
1585
1626
|
*
|
1586
1627
|
* <b>Parameters</b>:
|
1587
|
-
* - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param().
|
1628
|
+
* - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param( ).
|
1588
1629
|
* - <tt>VALUE direction</tt> -- The direction of the binding variable.
|
1589
1630
|
*
|
1590
1631
|
* <b>Returns</b>:
|
@@ -1592,26 +1633,26 @@ static_Bind_set_value(VALUE bind, VALUE val)
|
|
1592
1633
|
*
|
1593
1634
|
*/
|
1594
1635
|
static VALUE
|
1595
|
-
static_Bind_set_direction(VALUE bind, VALUE direction)
|
1596
|
-
{
|
1597
|
-
|
1636
|
+
static_Bind_set_direction( VALUE bind, VALUE direction )
|
1637
|
+
{
|
1638
|
+
a_ads_bind_param* s_bind;
|
1598
1639
|
|
1599
|
-
|
1640
|
+
Data_Get_Struct( bind, a_ads_bind_param, s_bind );
|
1600
1641
|
|
1601
|
-
|
1642
|
+
s_bind->direction = NUM2CHR( direction );
|
1602
1643
|
|
1603
|
-
|
1604
|
-
}
|
1644
|
+
return( Qnil );
|
1645
|
+
}
|
1605
1646
|
|
1606
1647
|
/*
|
1607
1648
|
* call-seq:
|
1608
|
-
* set_buffer_size(VALUE bind, VALUE size) -> nil
|
1649
|
+
* set_buffer_size( VALUE bind, VALUE size ) -> nil
|
1609
1650
|
*
|
1610
1651
|
* Sets the buffer size of INOUT and OUT parameters for string and binary
|
1611
1652
|
* data.
|
1612
1653
|
*
|
1613
1654
|
* <b>Parameters</b>:
|
1614
|
-
* - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param().
|
1655
|
+
* - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param( ).
|
1615
1656
|
* - <tt>VALUE size</tt> -- The size of the buffer to hold the INOUT or OUT parameter.
|
1616
1657
|
*
|
1617
1658
|
* <b>Returns</b>:
|
@@ -1619,182 +1660,185 @@ static_Bind_set_direction(VALUE bind, VALUE direction)
|
|
1619
1660
|
*
|
1620
1661
|
*/
|
1621
1662
|
static VALUE
|
1622
|
-
static_Bind_set_buffer_size(VALUE bind, VALUE size)
|
1623
|
-
{
|
1624
|
-
|
1663
|
+
static_Bind_set_buffer_size( VALUE bind, VALUE size )
|
1664
|
+
{
|
1665
|
+
a_ads_bind_param* s_bind;
|
1625
1666
|
|
1626
|
-
|
1667
|
+
Data_Get_Struct( bind, a_ads_bind_param, s_bind );
|
1627
1668
|
|
1628
|
-
|
1669
|
+
s_bind->value.buffer_size = NUM2INT( size );
|
1629
1670
|
|
1630
|
-
|
1631
|
-
}
|
1671
|
+
return( Qnil );
|
1672
|
+
}
|
1632
1673
|
|
1633
1674
|
/*
|
1634
1675
|
* call-seq:
|
1635
|
-
* get_direction(VALUE bind) -> VALUE direction
|
1676
|
+
* get_direction( VALUE bind ) -> VALUE direction
|
1636
1677
|
*
|
1637
1678
|
* Gets the direction of the bound parameter.
|
1638
1679
|
*
|
1639
1680
|
* <b>Parameters</b>:
|
1640
|
-
* - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param().
|
1681
|
+
* - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param( ).
|
1641
1682
|
*
|
1642
1683
|
* <b>Returns</b>:
|
1643
1684
|
* - <tt>VALUE name</tt>: The direction of the bound parameter.
|
1644
1685
|
*
|
1645
1686
|
*/
|
1646
1687
|
static VALUE
|
1647
|
-
static_Bind_get_direction(VALUE bind)
|
1648
|
-
{
|
1649
|
-
|
1650
|
-
|
1688
|
+
static_Bind_get_direction( VALUE bind )
|
1689
|
+
{
|
1690
|
+
a_ads_bind_param* s_bind;
|
1691
|
+
Data_Get_Struct( bind, a_ads_bind_param, s_bind );
|
1651
1692
|
|
1652
|
-
|
1653
|
-
}
|
1693
|
+
return( CHR2FIX( s_bind->direction ) );
|
1694
|
+
}
|
1654
1695
|
|
1655
1696
|
/*
|
1656
1697
|
* call-seq:
|
1657
|
-
* finish(VALUE bind) -> nil
|
1698
|
+
* finish( VALUE bind ) -> nil
|
1658
1699
|
*
|
1659
1700
|
* Frees the resources associated with the bound parameter.
|
1660
1701
|
*
|
1661
1702
|
* <b>Parameters</b>:
|
1662
|
-
* - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param().
|
1703
|
+
* - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param( ).
|
1663
1704
|
*
|
1664
1705
|
* <b>Returns</b>:
|
1665
1706
|
* - <tt>nil</tt>.
|
1666
1707
|
*
|
1667
1708
|
*/
|
1668
1709
|
static VALUE
|
1669
|
-
static_Bind_finish(VALUE bind)
|
1670
|
-
{
|
1671
|
-
|
1710
|
+
static_Bind_finish( VALUE bind )
|
1711
|
+
{
|
1712
|
+
a_ads_bind_param* s_bind;
|
1672
1713
|
|
1673
|
-
|
1714
|
+
Data_Get_Struct( bind, a_ads_bind_param, s_bind );
|
1674
1715
|
|
1675
|
-
|
1676
|
-
|
1716
|
+
// FIXME: use Ruby's allocation routines?
|
1717
|
+
if( s_bind )
|
1718
|
+
{
|
1719
|
+
free( s_bind );
|
1720
|
+
};
|
1677
1721
|
|
1678
|
-
|
1679
|
-
}
|
1722
|
+
return( Qnil );
|
1723
|
+
}
|
1680
1724
|
|
1681
1725
|
/*
|
1682
1726
|
* call-seq:
|
1683
|
-
* get_info_direction(VALUE bind) -> VALUE direction
|
1727
|
+
* get_info_direction( VALUE bind ) -> VALUE direction
|
1684
1728
|
*
|
1685
1729
|
* Gets the name of the bound parameter info object.
|
1686
1730
|
*
|
1687
1731
|
* <b>Parameters</b>:
|
1688
|
-
* - <tt>VALUE bind</tt> -- Bound parameter info retrieved from ads_describe_bind_param_info().
|
1732
|
+
* - <tt>VALUE bind</tt> -- Bound parameter info retrieved from ads_describe_bind_param_info( ).
|
1689
1733
|
*
|
1690
1734
|
* <b>Returns</b>:
|
1691
1735
|
* - <tt>VALUE direction</tt>: The bound variable's direction.
|
1692
1736
|
*
|
1693
1737
|
*/
|
1694
1738
|
static VALUE
|
1695
|
-
static_Bind_get_info_direction(VALUE bind)
|
1696
|
-
{
|
1697
|
-
|
1698
|
-
|
1739
|
+
static_Bind_get_info_direction( VALUE bind )
|
1740
|
+
{
|
1741
|
+
a_ads_bind_param_info* s_bind;
|
1742
|
+
Data_Get_Struct( bind, a_ads_bind_param_info, s_bind );
|
1699
1743
|
|
1700
|
-
|
1701
|
-
}
|
1744
|
+
return( CHR2FIX( s_bind->direction ) );
|
1745
|
+
}
|
1702
1746
|
|
1703
1747
|
/*
|
1704
1748
|
* call-seq:
|
1705
|
-
* get_info_output(VALUE bind) -> VALUE name
|
1749
|
+
* get_info_output( VALUE bind ) -> VALUE name
|
1706
1750
|
*
|
1707
1751
|
* Gets the value of a bound parameter after execution.
|
1708
1752
|
*
|
1709
1753
|
* <b>Parameters</b>:
|
1710
|
-
* - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param().
|
1754
|
+
* - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param( ).
|
1711
1755
|
*
|
1712
1756
|
* <b>Returns</b>:
|
1713
1757
|
* - <tt>VALUE name</tt>: The bound variable value.
|
1714
1758
|
*
|
1715
1759
|
*/
|
1716
1760
|
static VALUE
|
1717
|
-
static_Bind_get_info_output(VALUE bind)
|
1718
|
-
{
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
}
|
1761
|
+
static_Bind_get_info_output( VALUE bind )
|
1762
|
+
{
|
1763
|
+
a_ads_bind_param_info* s_bind;
|
1764
|
+
Data_Get_Struct( bind, a_ads_bind_param_info, s_bind );
|
1765
|
+
return( C2RB( &s_bind->output_value ) );
|
1766
|
+
}
|
1723
1767
|
|
1724
1768
|
/*
|
1725
1769
|
*
|
1726
1770
|
*/
|
1727
|
-
void Init_advantage()
|
1728
|
-
{
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
}
|
1771
|
+
void Init_advantage( )
|
1772
|
+
{
|
1773
|
+
// Define top leve 'Advantage' module
|
1774
|
+
mAdvantage = rb_define_module( "Advantage" );
|
1775
|
+
|
1776
|
+
// Define a sub-module name 'API' under Advantage.
|
1777
|
+
// In Ruby, this is accessed as Advantage::API
|
1778
|
+
mAPI = rb_define_module_under( mAdvantage, "API" );
|
1779
|
+
|
1780
|
+
// Define ads interface functions
|
1781
|
+
rb_define_module_function( mAPI, "ads_initialize_interface", static_API_ads_initialize_interface, 1 );
|
1782
|
+
rb_define_module_function( mAPI, "ads_finalize_interface", static_API_ads_finalize_interface, 1 );
|
1783
|
+
rb_define_const( mAPI, "VERSION", rb_str_new2( VERSION ) );
|
1784
|
+
|
1785
|
+
|
1786
|
+
// Define interface classes under the Advantage module
|
1787
|
+
cAdvantageInterface = rb_define_class_under( mAdvantage, "AdvantageInterface", rb_cObject );
|
1788
|
+
rb_define_alloc_func( cAdvantageInterface, static_AdvantageInterface_alloc );
|
1789
|
+
|
1790
|
+
// Define all of the DBCAPI functions as methods under an interface instance
|
1791
|
+
rb_define_method( cAdvantageInterface, "ads_init", static_AdvantageInterface_ads_init, 0 );
|
1792
|
+
rb_define_method( cAdvantageInterface, "ads_new_connection", static_AdvantageInterface_ads_new_connection, 0 );
|
1793
|
+
rb_define_method( cAdvantageInterface, "ads_client_version", static_AdvantageInterface_ads_client_version, 0 );
|
1794
|
+
rb_define_method( cAdvantageInterface, "ads_connect", static_AdvantageInterface_ads_connect, 2 );
|
1795
|
+
rb_define_method( cAdvantageInterface, "ads_disconnect", static_AdvantageInterface_ads_disconnect, 1 );
|
1796
|
+
rb_define_method( cAdvantageInterface, "ads_free_connection", static_AdvantageInterface_ads_free_connection, 1 );
|
1797
|
+
rb_define_method( cAdvantageInterface, "ads_fini", static_AdvantageInterface_ads_fini, 0 );
|
1798
|
+
rb_define_method( cAdvantageInterface, "ads_error", static_AdvantageInterface_ads_error, 1 );
|
1799
|
+
rb_define_method( cAdvantageInterface, "ads_execute_immediate", static_AdvantageInterface_ads_execute_immediate, 2 );
|
1800
|
+
rb_define_method( cAdvantageInterface, "ads_execute_direct", static_AdvantageInterface_ads_execute_direct, 2 );
|
1801
|
+
rb_define_method( cAdvantageInterface, "ads_num_cols", static_AdvantageInterface_ads_num_cols, 1 );
|
1802
|
+
rb_define_method( cAdvantageInterface, "ads_num_rows", static_AdvantageInterface_ads_num_rows, 1 );
|
1803
|
+
rb_define_method( cAdvantageInterface, "ads_get_column", static_AdvantageInterface_ads_get_column, 2 );
|
1804
|
+
rb_define_method( cAdvantageInterface, "ads_fetch_next", static_AdvantageInterface_ads_fetch_next, 1 );
|
1805
|
+
rb_define_method( cAdvantageInterface, "ads_get_column_info", static_AdvantageInterface_ads_get_column_info, 2 );
|
1806
|
+
rb_define_method( cAdvantageInterface, "AdsBeginTransaction", static_AdvantageInterface_AdsBeginTransaction, 1 );
|
1807
|
+
rb_define_method( cAdvantageInterface, "ads_commit", static_AdvantageInterface_ads_commit, 1 );
|
1808
|
+
rb_define_method( cAdvantageInterface, "ads_rollback", static_AdvantageInterface_ads_rollback, 1 );
|
1809
|
+
rb_define_method( cAdvantageInterface, "ads_prepare", static_AdvantageInterface_ads_prepare, 2 );
|
1810
|
+
rb_define_method( cAdvantageInterface, "ads_free_stmt", static_AdvantageInterface_ads_free_stmt, 1 );
|
1811
|
+
rb_define_method( cAdvantageInterface, "ads_reset", static_AdvantageInterface_ads_reset, 1 );
|
1812
|
+
rb_define_method( cAdvantageInterface, "ads_execute", static_AdvantageInterface_ads_execute, 1 );
|
1813
|
+
rb_define_method( cAdvantageInterface, "ads_affected_rows", static_AdvantageInterface_ads_affected_rows, 1 );
|
1814
|
+
rb_define_method( cAdvantageInterface, "ads_describe_bind_param", static_AdvantageInterface_ads_describe_bind_param, 2 );
|
1815
|
+
rb_define_method( cAdvantageInterface, "ads_bind_param", static_AdvantageInterface_ads_bind_param, 3 );
|
1816
|
+
rb_define_method( cAdvantageInterface, "ads_get_bind_param_info", static_AdvantageInterface_ads_get_bind_param_info, 2 );
|
1817
|
+
rb_define_method( cAdvantageInterface, "ads_num_params", static_AdvantageInterface_ads_num_params, 1 );
|
1818
|
+
rb_define_method( cAdvantageInterface, "ads_get_next_result", static_AdvantageInterface_ads_get_next_result, 1 );
|
1819
|
+
rb_define_method( cAdvantageInterface, "ads_fetch_absolute", static_AdvantageInterface_ads_fetch_absolute, 2 );
|
1820
|
+
rb_define_method( cAdvantageInterface, "ads_sqlstate", static_AdvantageInterface_ads_sqlstate, 1 );
|
1821
|
+
rb_define_method( cAdvantageInterface, "ads_clear_error", static_AdvantageInterface_ads_clear_error, 1 );
|
1822
|
+
|
1823
|
+
// Define classes for accessing structures under Advantage module
|
1824
|
+
cA_ads_connection = rb_define_class_under ( mAdvantage, "a_ads_connection", rb_cObject );
|
1825
|
+
cA_ads_data_value = rb_define_class_under ( mAdvantage, "a_ads_data_value", rb_cObject );
|
1826
|
+
//cA_ads_stmt = rb_define_class_under ( mAdvantage, "ADSHANDLE", rb_cObject );
|
1827
|
+
cA_ads_bind_param = rb_define_class_under ( mAdvantage, "a_ads_bind_param", rb_cObject );
|
1828
|
+
cA_ads_bind_param_info = rb_define_class_under ( mAdvantage, "a_ads_bind_param_info", rb_cObject );
|
1829
|
+
|
1830
|
+
|
1831
|
+
// Define methods for obtaining bind_parameter fields
|
1832
|
+
rb_define_method( cA_ads_bind_param, "get_name", static_Bind_get_name, 0 );
|
1833
|
+
rb_define_method( cA_ads_bind_param, "set_value", static_Bind_set_value, 1 );
|
1834
|
+
rb_define_method( cA_ads_bind_param, "get_direction", static_Bind_get_direction, 0 );
|
1835
|
+
rb_define_method( cA_ads_bind_param, "set_direction", static_Bind_set_direction, 1 );
|
1836
|
+
rb_define_method( cA_ads_bind_param, "set_buffer_size", static_Bind_set_buffer_size, 1 );
|
1837
|
+
rb_define_method( cA_ads_bind_param, "finish", static_Bind_finish, 0 );
|
1838
|
+
|
1839
|
+
// Define methods for obtaining bind_parameter_info fields
|
1840
|
+
rb_define_method( cA_ads_bind_param_info, "get_direction", static_Bind_get_info_direction, 0 );
|
1841
|
+
rb_define_method( cA_ads_bind_param_info, "get_output", static_Bind_get_info_output, 0 );
|
1842
|
+
}
|
1799
1843
|
|
1800
1844
|
|