Class: Advantage::AdvantageInterface
- Inherits:
-
Object
- Object
- Advantage::AdvantageInterface
- Defined in:
- ext/advantage.c
Instance Method Summary collapse
-
#ads_affected_rows(VALUEimp_drh, VALUEads_stmt) ⇒ Object
Returns the number of rows affected by execution of the prepared statement.
-
#ads_bind_param(VALUEimp_drh, VALUEads_stmt, VALUEindex, VALUEads_bind_param) ⇒ Object
Binds a user supplied buffer as a parameter to the prepared statement.
-
#ads_clear_error(VALUEimp_drh, VALUEads_conn) ⇒ nil
Clears the last stored error code.
-
#ads_client_version(VALUEimp_drh) ⇒ Array
Retrieves the client version as a string.
-
#ads_commit(VALUEimp_drh, VALUEads_conn) ⇒ Object
Commits the current transaction.
-
#ads_connect(VALUEimp_drh, VALUEads_conn, VALUEstr) ⇒ Object
Creates a connection object.
-
#ads_describe_bind_param(VALUEimp_drh, VALUEads_stmt, VALUEindex) ⇒ Array
Describes the bind parameters of a prepared statement.
-
#ads_disconnect(VALUEimp_drh, VALUEads_conn) ⇒ nil
Disconnect an already established connection.
-
#ads_error(VALUEimp_drh, VALUEads_conn) ⇒ Array
Retrieves the last error code and message.
-
#ads_execute(VALUEimp_drh, VALUEads_stmt) ⇒ Object
Executes a prepared statement.
-
#ads_execute_direct(VALUEimp_drh, VALUEads_conn, VALUEsql) ⇒ Object
Executes a SQL statement and possibly returns a result set.
-
#ads_execute_immediate(VALUEimp_drh, VALUEads_conn, VALUEsql) ⇒ Object
Executes a SQL statement immediately without returning a result set.
-
#ads_fetch_absolute(VALUEimp_drh, VALUEads_stmt, VALUEoffset) ⇒ Object
Fetches data at a specific row number in the result set.
-
#ads_fetch_next(VALUEimp_drh, VALUEads_stmt) ⇒ Object
Fetches the next row from the result set.
-
#ads_fini(VALUEimp_drh) ⇒ nil
Finalizes the interface.
-
#ads_free_connection(VALUEimp_drh, VALUEads_conn) ⇒ nil
Frees the resources associated with a connection object.
-
#ads_free_stmt(VALUEimp_drh, VALUEads_stmt) ⇒ nil
Frees resources associated with a prepared statement object.
-
#ads_get_bind_param_info(VALUEimp_drh, VALUEads_stmt, VALUEindex) ⇒ Array
Gets bound parameter info.
-
#ads_get_column(VALUEimp_drh, VALUEads_stmt, VALUEcol_num) ⇒ Array
Retrieves the data fetched for the specified column.
-
#ads_get_column_info(VALUEimp_drh, VALUEads_stmt, VALUEcol_num) ⇒ Array
Fetches the next row from the result set.
-
#ads_get_next_result(VALUEimp_drh, VALUEads_stmt) ⇒ Object
Advances to the next result set in a multiple result set query.
-
#ads_init(VALUEimp_drh) ⇒ Array
Initializes the interface.
-
#ads_new_connection(VALUEimp_drh) ⇒ Object
Creates a connection object.
-
#ads_num_cols(VALUEimp_drh, VALUEads_stmt) ⇒ Object
Returns number of columns in the result set.
-
#ads_num_params(VALUEimp_drh, VALUEads_stmt) ⇒ Object
Returns the number of parameters that are expected for a prepared statement.
-
#ads_num_rows(VALUEimp_drh, VALUEads_stmt) ⇒ Object
Returns number of rows in the result set.
-
#ads_prepare(VALUEimp_drh, VALUEads_conn, VALUEsql) ⇒ Object
Prepares a SQL statement.
-
#ads_reset(VALUEimp_drh, VALUEads_stmt) ⇒ Object
Parameters: -
VALUE imp_drh
– An initialized API structure to finalize. -
#ads_rollback(VALUEimp_drh, VALUEads_conn) ⇒ Object
Rolls back the current transaction.
-
#ads_sqlstate(VALUEimp_drh, VALUEads_conn) ⇒ Object
Retrieves the current SQL state.
-
#AdsBeginTransaction(VALUEimp_drh, VALUEads_conn) ⇒ Object
Starts a transaction on the current connection.
Instance Method Details
#ads_affected_rows(VALUEimp_drh, VALUEads_stmt) ⇒ Object
Returns the number of rows affected by execution of the prepared
statement.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_stmt</tt> -- A statement that was prepared and executed successfully with no result set returned.
<b>Returns</b>:
- <tt>VALUE result</tt>: The number of rows affected or <tt>-1</tt> on failure.
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 |
# File 'ext/advantage.c', line 1102
static VALUE
static_AdvantageInterface_ads_affected_rows(VALUE imp_drh, VALUE ads_stmt)
{
imp_drh_st* s_imp_drh;
ADSHANDLE s_stmt;
UNSIGNED32 result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
//Data_Get_Struct(ads_stmt, ADSHANDLE, s_ads_stmt);
s_stmt = NUM2ULONG(ads_stmt);
result = s_imp_drh->api.ads_affected_rows(s_stmt);
return ( INT2NUM(result) );
}
|
#ads_bind_param(VALUEimp_drh, VALUEads_stmt, VALUEindex, VALUEads_bind_param) ⇒ Object
Binds a user supplied buffer as a parameter to the prepared statement.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare().
- <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and ads_num_params() - 1.
- <tt>VALUE ads_bind_param</tt> -- A filled bind object retrieved from ads_describe_bind_param().
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on success or <tt>0</tt> on failure.
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 |
# File 'ext/advantage.c', line 1188
static VALUE
static_AdvantageInterface_ads_bind_param(VALUE imp_drh, VALUE ads_stmt, VALUE index, VALUE ads_bind_param )
{
imp_drh_st* s_imp_drh;
ADSHANDLE s_stmt;
a_ads_bind_param* s_ads_bind_param;
UNSIGNED32 result;
UNSIGNED32 s_index;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
//Data_Get_Struct(ads_stmt, ADSHANDLE, s_ads_stmt);
s_stmt = NUM2ULONG(ads_stmt);
Data_Get_Struct(ads_bind_param, a_ads_bind_param, s_ads_bind_param);
s_index = NUM2INT(index);
result = s_imp_drh->api.ads_bind_param(s_stmt, s_index, s_ads_bind_param);
return( INT2NUM(result) );
}
|
#ads_clear_error(VALUEimp_drh, VALUEads_conn) ⇒ nil
Clears the last stored error code.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
<b>Returns</b>:
- <tt>nil</tt>:.
1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 |
# File 'ext/advantage.c', line 1407
static VALUE
static_AdvantageInterface_ads_clear_error(VALUE imp_drh, VALUE ads_conn)
{
imp_drh_st* s_imp_drh;
a_ads_connection* s_ads_conn;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
s_imp_drh->api.ads_clear_error(s_ads_conn);
return( Qnil );
}
|
#ads_client_version(VALUEimp_drh) ⇒ Array
Retrieves the client version as a string.
This function can be used to retrieve the client version.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- an initialized API structure to finalize
<b>Returns</b>:
- <tt>VALUE verstr</tt>: The client version string.
351 352 353 354 355 356 357 358 359 360 361 362 363 |
# File 'ext/advantage.c', line 351
static VALUE
static_AdvantageInterface_ads_client_version(VALUE imp_drh)
{
imp_drh_st* s_imp_drh;
size_t s_size;
char s_buffer[255];
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
s_imp_drh->api.ads_client_version(s_buffer, 255);
return (rb_str_new2(s_buffer));
}
|
#ads_commit(VALUEimp_drh, VALUEads_conn) ⇒ Object
Commits the current transaction.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on successful commit, <tt>0</tt> otherwise.
874 875 876 877 878 879 880 881 882 883 884 885 886 887 |
# File 'ext/advantage.c', line 874
static VALUE
static_AdvantageInterface_ads_commit(VALUE imp_drh, VALUE ads_conn)
{
imp_drh_st* s_imp_drh;
a_ads_connection* s_ads_conn;
UNSIGNED32 result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
result = s_imp_drh->api.ads_commit(s_ads_conn);
return( INT2NUM(result) );
}
|
#ads_connect(VALUEimp_drh, VALUEads_conn, VALUEstr) ⇒ Object
Creates a connection object.
An API connection object needs to be created before a database connection
is established. Errors can be retrieved from the connection object. Only
one request can be processed on a connection at a time.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_conn</tt> -- A connection object that was created by ads_new_connection().
- <tt>VALUE str</tt> -- A connection string.
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on success, <tt>0</tt> on failure.
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
# File 'ext/advantage.c', line 384
static VALUE
static_AdvantageInterface_ads_connect(VALUE imp_drh, VALUE ads_conn, VALUE str)
{
imp_drh_st* s_imp_drh;
a_ads_connection* s_ads_conn;
char* s_str;
UNSIGNED32 result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
s_str = StringValueCStr( str );
result = s_imp_drh->api.ads_connect( s_ads_conn, s_str );
return( INT2NUM(result) );
}
|
#ads_describe_bind_param(VALUEimp_drh, VALUEads_stmt, VALUEindex) ⇒ Array
Describes the bind parameters of a prepared statement.
This function allows the caller to determine information about parameters
to a prepared statement. Depending on the type of the prepared statement
(call to stored procedure or a DML), only some information will be
provided. The information that will always be provided is the direction
of the parameters (input, output, or input-output).
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare().
- <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and ads_num_params()- 1.
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on success or <tt>0</tt> on failure.
- <tt>VALUE bind_param</tt>: The described param object.
1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 |
# File 'ext/advantage.c', line 1140
static VALUE
static_AdvantageInterface_ads_describe_bind_param(VALUE imp_drh, VALUE ads_stmt, VALUE index)
{
imp_drh_st* s_imp_drh;
ADSHANDLE s_stmt;
a_ads_bind_param* s_ads_bind_param;
UNSIGNED32 result;
UNSIGNED32 s_index;
VALUE tdata;
VALUE multi_result;
s_ads_bind_param = malloc(sizeof(a_ads_bind_param));
memset( s_ads_bind_param, 0, sizeof(a_ads_bind_param) );
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
s_stmt = NUM2ULONG(ads_stmt);
s_index = NUM2INT(index);
result = s_imp_drh->api.ads_describe_bind_param(s_stmt, s_index, s_ads_bind_param);
//FIXME handle failed result
multi_result = rb_ary_new();
rb_ary_push(multi_result, INT2NUM(result));
tdata = Data_Wrap_Struct(cA_ads_bind_param, 0, 0, s_ads_bind_param);
rb_ary_push(multi_result, tdata);
return( multi_result );
}
|
#ads_disconnect(VALUEimp_drh, VALUEads_conn) ⇒ nil
Disconnect an already established connection.
This function disconnects the connection. Any
uncommitted transactions will be rolled back.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
<b>Returns</b>:
- <tt>nil</tt>.
419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
# File 'ext/advantage.c', line 419
static VALUE
static_AdvantageInterface_ads_disconnect(VALUE imp_drh, VALUE ads_conn)
{
imp_drh_st* s_imp_drh;
a_ads_connection* s_ads_conn;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
s_imp_drh->api.ads_disconnect( s_ads_conn );
return( Qnil );
}
|
#ads_error(VALUEimp_drh, VALUEads_conn) ⇒ Array
Retrieves the last error code and message.
This function can be used to retrieve the last error code and message
stored in the connection object.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
<b>Returns</b>:
- <tt>VALUE result</tt>: The last error code. Positive values are warnings, negative values are errors, and <tt>0</tt> is success.
- <tt>VALUE errstr</tt>: The error message corresponding to the error code.
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 |
# File 'ext/advantage.c', line 509
static VALUE
static_AdvantageInterface_ads_error(VALUE imp_drh, VALUE ads_conn)
{
imp_drh_st* s_imp_drh;
a_ads_connection* s_ads_conn;
size_t s_size;
char s_buffer[255];
UNSIGNED32 result;
VALUE multi_result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
result = s_imp_drh->api.ads_error(s_ads_conn, s_buffer, 255);
multi_result = rb_ary_new();
rb_ary_push(multi_result, INT2NUM(result));
rb_ary_push(multi_result, rb_str_new2(s_buffer));
return( multi_result );
}
|
#ads_execute(VALUEimp_drh, VALUEads_stmt) ⇒ Object
Executes a prepared statement.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on successful execution, <tt>0</tt> otherwise.
1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 |
# File 'ext/advantage.c', line 1067
static VALUE
static_AdvantageInterface_ads_execute(VALUE imp_drh, VALUE ads_stmt)
{
imp_drh_st* s_imp_drh;
ADSHANDLE s_stmt;
UNSIGNED32 result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
//Data_Get_Struct(ads_stmt, ADSHANDLE, s_ads_stmt);
s_stmt = NUM2ULONG(ads_stmt);
//printf( "CEXT s_ads_stmt: %d \n", s_stmt);
result = s_imp_drh->api.ads_execute(s_stmt);
/*if ( result != AE_SUCCESS )
return (0);
else
return (1);*/
return (INT2NUM(result));
}
|
#ads_execute_direct(VALUEimp_drh, VALUEads_conn, VALUEsql) ⇒ Object
Executes a SQL statement and possibly returns a result set.
This function executes the SQL statement specified by the string argument.
This function is suitable if you want to prepare and then execute a
statement, and can be used instead of calling ads_prepare() followed
by ads_execute().
This function cannot be used for executing a SQL statement with
parameters.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
- <tt>VALUE sql</tt> -- A SQL query string.
<b>Returns</b>:
- <tt>VALUE result</tt>: A query result set if successful, nil if failed.
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 |
# File 'ext/advantage.c', line 592
static VALUE
static_AdvantageInterface_ads_execute_direct(VALUE imp_drh, VALUE ads_conn, VALUE sql)
{
imp_drh_st* s_imp_drh;
a_ads_connection* s_ads_conn;
ADSHANDLE resultset = 0;
char* s_sql;
VALUE tdata;
s_sql = StringValueCStr( sql );
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
resultset = s_imp_drh->api.ads_execute_direct(s_ads_conn, s_sql);
if (resultset)
{
tdata = INT2NUM(resultset);
}
else
{
tdata = Qnil;
}
return (tdata);
}
|
#ads_execute_immediate(VALUEimp_drh, VALUEads_conn, VALUEsql) ⇒ Object
Executes a SQL statement immediately without returning a result set.
This function executes the specified SQL statement immediately. It is
useful for SQL statements that do not return a result set.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
- <tt>VALUE sql</tt> -- A SQL query string.
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on success, <tt>0</tt> on failure.
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 |
# File 'ext/advantage.c', line 551
static VALUE
static_AdvantageInterface_ads_execute_immediate(VALUE imp_drh, VALUE ads_conn, VALUE sql)
{
imp_drh_st* s_imp_drh;
a_ads_connection* s_ads_conn;
char* s_sql;
UNSIGNED32 result;
s_sql = StringValueCStr( sql );
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
result = s_imp_drh->api.ads_execute_immediate(s_ads_conn, s_sql);
return( INT2NUM(result) );
}
|
#ads_fetch_absolute(VALUEimp_drh, VALUEads_stmt, VALUEoffset) ⇒ Object
Fetches data at a specific row number in the result set.
This function moves the current row in the result set to the row number
specified and fetches the data at that row.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_stmt</tt> -- A statement object that was executed by ads_execute() or ads_execute_direct().
- <tt>VALUE offset</tt> -- The row number to be fetched. The first row is <tt>1</tt>, the last row is <tt>-1</tt>.
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> if the fetch was successfully, <tt>0</tt> otherwise.
1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 |
# File 'ext/advantage.c', line 1342
static VALUE
static_AdvantageInterface_ads_fetch_absolute(VALUE imp_drh, VALUE ads_stmt, VALUE offset)
{
imp_drh_st* s_imp_drh;
ADSHANDLE s_stmt;
UNSIGNED32 s_offset;
UNSIGNED32 result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
//Data_Get_Struct(ads_stmt, ADSHANDLE, s_ads_stmt);
s_stmt = NUM2ULONG(ads_stmt);
s_offset = NUM2INT(offset);
result = s_imp_drh->api.ads_fetch_absolute(s_stmt, s_offset);
return( INT2NUM(result) );
}
|
#ads_fetch_next(VALUEimp_drh, VALUEads_stmt) ⇒ Object
Fetches the next row from the result set.
This function fetches the next row from the result set. When the result
object is first created, the current row pointer is set to point before
the first row (that is, row 0).
This function advances the row pointer first and then fetches the data
at the new row.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on successful fetch, <tt>0</tt> otherwise.
753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 |
# File 'ext/advantage.c', line 753
static VALUE
static_AdvantageInterface_ads_fetch_next(VALUE imp_drh, VALUE ads_stmt)
{
imp_drh_st* s_imp_drh;
ADSHANDLE s_stmt;
UNSIGNED32 result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
//Data_Get_Struct(ads_stmt, ADSHANDLE, s_stmt);
s_stmt = NUM2ULONG(ads_stmt);
result = s_imp_drh->api.ads_fetch_next(s_stmt);
return( INT2NUM(result) );
}
|
#ads_fini(VALUEimp_drh) ⇒ nil
Finalizes the interface.
Thus function frees any resources allocated by the API.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
<b>Returns</b>:
- <tt>nil</tt>.
478 479 480 481 482 483 484 485 486 487 488 |
# File 'ext/advantage.c', line 478
static VALUE
static_AdvantageInterface_ads_fini(VALUE imp_drh)
{
imp_drh_st* s_imp_drh;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
s_imp_drh->api.ads_fini();
return( Qnil );
}
|
#ads_free_connection(VALUEimp_drh, VALUEads_conn) ⇒ nil
Frees the resources associated with a connection object.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_conn</tt> -- A connection object that was disconnected by ads_disconnect().
<b>Returns</b>:
- <tt>nil</tt>.
448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
# File 'ext/advantage.c', line 448
static VALUE
static_AdvantageInterface_ads_free_connection(VALUE imp_drh, VALUE ads_conn)
{
imp_drh_st* s_imp_drh;
a_ads_connection* s_ads_conn;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
s_imp_drh->api.ads_free_connection( s_ads_conn );
return( Qnil );
}
|
#ads_free_stmt(VALUEimp_drh, VALUEads_stmt) ⇒ nil
Frees resources associated with a prepared statement object.
This function frees the resources associated with a prepared statement
object.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
<b>Returns</b>:
- <tt>nil</tt>.
986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 |
# File 'ext/advantage.c', line 986
static VALUE
static_AdvantageInterface_ads_free_stmt(VALUE imp_drh, VALUE ads_stmt)
{
imp_drh_st* s_imp_drh;
ADSHANDLE s_stmt;
int i;
int number_of_params = 0;
a_ads_bind_param_info bind_info;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
//Data_Get_Struct(ads_stmt, ADSHANDLE, s_ads_stmt);
s_stmt = NUM2ULONG(ads_stmt);
number_of_params = s_imp_drh->api.ads_num_params(s_stmt);
for (i = 0; i < number_of_params; i++)
{
if( s_imp_drh->api.ads_get_bind_param_info(s_stmt, i, &bind_info) )
{
// We don't free bind_info.name as it's not allocated
// if (bind_info.name) {free (bind_info.name);}
if (bind_info.input_value.is_null) {free(bind_info.input_value.is_null); }
if (bind_info.input_value.length) {free(bind_info.input_value.length); }
if (bind_info.input_value.buffer) {free(bind_info.input_value.buffer); }
if (bind_info.output_value.is_null) {free(bind_info.output_value.is_null); }
if (bind_info.output_value.length) {free(bind_info.output_value.length); }
if (bind_info.output_value.buffer) {free(bind_info.output_value.buffer); }
}
}
s_imp_drh->api.ads_free_stmt(s_stmt);
return ( Qnil );
}
|
#ads_get_bind_param_info(VALUEimp_drh, VALUEads_stmt, VALUEindex) ⇒ Array
Gets bound parameter info.
This function retrieves information about the parameters that were
bound using ads_bind_param().
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare().
- <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and ads_num_params() - 1.
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on success or <tt>0</tt> on failure.
- <tt>VALUE bind_param</tt>: The described param object.
1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 |
# File 'ext/advantage.c', line 1227
static VALUE
static_AdvantageInterface_ads_get_bind_param_info(VALUE imp_drh, VALUE ads_stmt, VALUE index)
{
imp_drh_st* s_imp_drh;
ADSHANDLE s_stmt;
a_ads_bind_param_info s_ads_bind_param_info;
UNSIGNED32 result;
UNSIGNED32 s_index;
VALUE tdata;
VALUE multi_result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
s_stmt = NUM2ULONG(ads_stmt);
s_index = NUM2INT(index);
result = s_imp_drh->api.ads_get_bind_param_info(s_stmt, s_index, &s_ads_bind_param_info);
//FIXME handle failed result
multi_result = rb_ary_new();
rb_ary_push(multi_result, INT2NUM(result));
// FIXME: Is this safe to be on the stack?
tdata = Data_Wrap_Struct(cA_ads_bind_param_info, 0, 0, &s_ads_bind_param_info);
rb_ary_push(multi_result, tdata);
return( multi_result );
}
|
#ads_get_column(VALUEimp_drh, VALUEads_stmt, VALUEcol_num) ⇒ Array
Retrieves the data fetched for the specified column.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
- <tt>VALUE col_num</tt> -- The number of the column to be retrieved. A column number is between 0 and ads_num_cols() - 1.
<b>Returns</b>:
- <tt>VALUE column_value</tt>: The value of the column. nil is returned if the value was NULL.
695 696 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 |
# File 'ext/advantage.c', line 695
static VALUE
static_AdvantageInterface_ads_get_column(VALUE imp_drh, VALUE ads_stmt, VALUE col_num)
{
imp_drh_st* s_imp_drh;
ADSHANDLE s_stmt;
UNSIGNED32 s_col_num;
a_ads_data_value value;
UNSIGNED32 result;
VALUE multi_result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
//Data_Get_Struct(ads_stmt, ADSHANDLE, s_stmt);
s_stmt = NUM2ULONG(ads_stmt);
s_col_num = NUM2INT(col_num);
result = s_imp_drh->api.ads_get_column(s_stmt, s_col_num, &value );
multi_result = rb_ary_new();
rb_ary_push(multi_result, INT2NUM(result));
if( !result ) {
rb_ary_push(multi_result, Qnil);
}
else
{
if( *value.is_null )
{
rb_ary_push(multi_result, Qnil);
}
else
{
rb_ary_push(multi_result, C2RB(&value));
}
}
return( multi_result );
}
|
#ads_get_column_info(VALUEimp_drh, VALUEads_stmt, VALUEcol_num) ⇒ Array
Fetches the next row from the result set.
This function fetches the next row from the result set. When the result
object is first created, the current row pointer is set to point before
the first row (that is, row 0).
This function advances the row pointer first and then fetches the data
at the new row.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
- <tt>VALUE col_num</tt> -- The number of the column to be retrieved. A column number is between 0 and ads_num_cols() - 1.
<b>Returns</b>:
- <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.
- <tt>VALUE col_num</tt>: The number of the column retrieved.
- <tt>VALUE name</tt>: The name of the column.
- <tt>VALUE type</tt>: The type of the column data.
- <tt>VALUE native_type</tt>: The Advantage native type of the column data.
- <tt>VALUE precision</tt>: The precision of the column.
- <tt>VALUE scale</tt>: The scale of the column.
- <tt>VALUE max_size</tt>: The maximum size a data value in this column can take.
- <tt>VALUE nullable</tt>: The nullability of the column.
798 799 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 |
# File 'ext/advantage.c', line 798
static VALUE
static_AdvantageInterface_ads_get_column_info(VALUE imp_drh, VALUE ads_stmt, VALUE col_num)
{
imp_drh_st* s_imp_drh;
ADSHANDLE s_stmt;
UNSIGNED32 s_col_num;
a_ads_column_info info;
UNSIGNED32 result;
VALUE multi_result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
//Data_Get_Struct(ads_stmt, ADSHANDLE, s_stmt);
s_stmt = NUM2ULONG(ads_stmt);
s_col_num = NUM2INT(col_num);
result = s_imp_drh->api.ads_get_column_info(s_stmt, s_col_num, &info );
multi_result = rb_ary_new();
rb_ary_push(multi_result, INT2NUM(result));
rb_ary_push(multi_result, col_num );
rb_ary_push(multi_result, rb_str_new2(info.name));
rb_ary_push(multi_result, INT2NUM(info.type));
rb_ary_push(multi_result, INT2NUM(info.native_type));
rb_ary_push(multi_result, INT2NUM(info.precision));
rb_ary_push(multi_result, INT2NUM(info.scale));
rb_ary_push(multi_result, INT2NUM(info.max_size));
rb_ary_push(multi_result, INT2NUM(info.nullable));
return( multi_result );
}
|
#ads_get_next_result(VALUEimp_drh, VALUEads_stmt) ⇒ Object
Advances to the next result set in a multiple result set query.
If a query (such as a call to a stored procedure) returns multiple result
sets, then this function advances from the current result set to the next.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_stmt</tt> -- A statement object that was executed by ads_execute() or ads_execute_direct().
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> if was successfully able to advance to the next result set, <tt>0</tt> otherwise.
1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 |
# File 'ext/advantage.c', line 1308
static VALUE
static_AdvantageInterface_ads_get_next_result(VALUE imp_drh, VALUE ads_stmt)
{
imp_drh_st* s_imp_drh;
ADSHANDLE s_stmt;
UNSIGNED32 result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
//Data_Get_Struct(ads_stmt, ADSHANDLE, s_ads_stmt);
s_stmt = NUM2ULONG(ads_stmt);
result = s_imp_drh->api.ads_get_next_result(s_stmt);
return( INT2NUM(result) );
}
|
#ads_init(VALUEimp_drh) ⇒ Array
Initializes the interface.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on success, <tt>0</tt> on failure.
- <tt>VALUE version</tt>: The maximum API version that is supported.
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'ext/advantage.c', line 279
static VALUE
static_AdvantageInterface_ads_init(VALUE imp_drh)
{
imp_drh_st* s_imp_drh;
UNSIGNED32 result;
UNSIGNED32 s_version_available;
VALUE multi_result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
multi_result = rb_ary_new();
if( &(s_imp_drh->api) == NULL ) {
rb_ary_push(multi_result, INT2NUM(0));
rb_ary_push(multi_result, Qnil );
} else {
result = s_imp_drh->api.ads_init((UNSIGNED8*)"RUBY", 1 , &s_version_available );
rb_ary_push(multi_result, INT2NUM(result));
rb_ary_push(multi_result, INT2NUM(s_version_available));
}
return( multi_result );
}
|
#ads_new_connection(VALUEimp_drh) ⇒ Object
Creates a connection object.
An API connection object needs to be created before a database connection
is established. Errors can be retrieved from the connection object. Only
one request can be processed on a connection at a time.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
<b>Returns</b>:
- <tt>VALUE connection</tt>: A connection object.
320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'ext/advantage.c', line 320
static VALUE
static_AdvantageInterface_ads_new_connection(VALUE imp_drh)
{
imp_drh_st* s_imp_drh;
a_ads_connection* ptr;
VALUE tdata;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
ptr = s_imp_drh->api.ads_new_connection();
tdata = Data_Wrap_Struct(cA_ads_connection, 0, 0, ptr);
return (tdata);
}
|
#ads_num_cols(VALUEimp_drh, VALUEads_stmt) ⇒ Object
Returns number of columns in the result set.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
<b>Returns</b>:
- <tt>VALUE num_cols</tt>: The number of columns in the result set or <tt>-1</tt> on a failure.
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
# File 'ext/advantage.c', line 634
static VALUE
static_AdvantageInterface_ads_num_cols(VALUE imp_drh, VALUE ads_stmt)
{
imp_drh_st* s_imp_drh;
ADSHANDLE s_stmt;
UNSIGNED32 result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
//Data_Get_Struct(ads_stmt, ADSHANDLE, s_stmt);
s_stmt = NUM2ULONG(ads_stmt);
result = s_imp_drh->api.ads_num_cols(s_stmt);
return( INT2NUM(result) );
}
|
#ads_num_params(VALUEimp_drh, VALUEads_stmt) ⇒ Object
Returns the number of parameters that are expected for a prepared
statement.
This function retrieves information about the parameters that were bound
using ads_bind_param().
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare().
<b>Returns</b>:
- <tt>VALUE result</tt>: The number of parameters that are expected. <tt>-1</tt> if the ads_stmt object is not valid.
1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 |
# File 'ext/advantage.c', line 1274
static VALUE
static_AdvantageInterface_ads_num_params(VALUE imp_drh, VALUE ads_stmt)
{
imp_drh_st* s_imp_drh;
ADSHANDLE s_stmt;
UNSIGNED32 result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
//Data_Get_Struct(ads_stmt, ADSHANDLE, s_ads_stmt);
s_stmt = NUM2ULONG(ads_stmt);
result = s_imp_drh->api.ads_num_params(s_stmt);
return( INT2NUM(result) );
}
|
#ads_num_rows(VALUEimp_drh, VALUEads_stmt) ⇒ Object
Returns number of rows in the result set.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
<b>Returns</b>:
- <tt>VALUE num_rows</tt>: The number of rows in the result set or <tt>-1</tt> on a failure.
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 |
# File 'ext/advantage.c', line 664
static VALUE
static_AdvantageInterface_ads_num_rows(VALUE imp_drh, VALUE ads_stmt)
{
imp_drh_st* s_imp_drh;
ADSHANDLE s_stmt;
UNSIGNED32 result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
//Data_Get_Struct(ads_stmt, ADSHANDLE, s_stmt);
s_stmt = NUM2ULONG(ads_stmt);
result = s_imp_drh->api.ads_num_rows(s_stmt);
return( INT2NUM(result) );
}
|
#ads_prepare(VALUEimp_drh, VALUEads_conn, VALUEsql) ⇒ Object
Prepares a SQL statement.
This function prepares the supplied SQL string. Execution does not
happen until ads_execute() is called. The returned statement object
should be freed using ads_free_stmt().
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
- <tt>VALUE sql</tt> -- SQL query to prepare.
<b>Returns</b>:
- <tt>VALUE stmt</tt>: A statement object, or nil on failure. The statement object can be used by ads_execute() to execute the statement.
939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 |
# File 'ext/advantage.c', line 939
static VALUE
static_AdvantageInterface_ads_prepare(VALUE imp_drh, VALUE ads_conn, VALUE sql)
{
imp_drh_st* s_imp_drh;
a_ads_connection* s_ads_conn;
ADSHANDLE s_stmt = 0;
char* s_sql;
int result;
VALUE tdata;
s_sql = StringValueCStr( sql );
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
//EJS Passing FALSE for isUnicode
s_stmt = s_imp_drh->api.ads_prepare(s_ads_conn, s_sql, '\0');
if (s_stmt)
{
tdata = INT2NUM( s_stmt );
}
else
{
tdata = Qnil;
}
return (tdata);
}
|
#ads_reset(VALUEimp_drh, VALUEads_stmt) ⇒ Object
Parameters:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on successful execution, <tt>0</tt> otherwise.
1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 |
# File 'ext/advantage.c', line 1036
static VALUE
static_AdvantageInterface_ads_reset(VALUE imp_drh, VALUE ads_stmt)
{
imp_drh_st* s_imp_drh;
ADSHANDLE s_stmt;
UNSIGNED32 result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
//Data_Get_Struct(ads_stmt, ADSHANDLE, s_ads_stmt);
s_stmt = NUM2ULONG(ads_stmt);
result = s_imp_drh->api.ads_reset(s_stmt);
return (INT2NUM(result));
}
|
#ads_rollback(VALUEimp_drh, VALUEads_conn) ⇒ Object
Rolls back the current transaction.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on successful rollback, <tt>0</tt> otherwise.
904 905 906 907 908 909 910 911 912 913 914 915 916 917 |
# File 'ext/advantage.c', line 904
static VALUE
static_AdvantageInterface_ads_rollback(VALUE imp_drh, VALUE ads_conn)
{
imp_drh_st* s_imp_drh;
a_ads_connection* s_ads_conn;
UNSIGNED32 result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
result = s_imp_drh->api.ads_rollback(s_ads_conn);
return( INT2NUM(result) );
}
|
#ads_sqlstate(VALUEimp_drh, VALUEads_conn) ⇒ Object
Retrieves the current SQL state.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
<b>Returns</b>:
- <tt>VALUE sqlstate_str</tt>: The SQL State.
1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 |
# File 'ext/advantage.c', line 1373
static VALUE
static_AdvantageInterface_ads_sqlstate(VALUE imp_drh, VALUE ads_conn)
{
imp_drh_st* s_imp_drh;
a_ads_connection* s_ads_conn;
UNSIGNED32 result;
size_t s_size;
char s_buffer[255];
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
result = s_imp_drh->api.ads_sqlstate(s_ads_conn, s_buffer, sizeof(s_buffer));
if ( result )
return( rb_str_new(s_buffer, strlen(s_buffer)));
else
return Qnil;
}
|
#AdsBeginTransaction(VALUEimp_drh, VALUEads_conn) ⇒ Object
Starts a transaction on the current connection.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on successful begining a transaction, <tt>0</tt> otherwise.
843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 |
# File 'ext/advantage.c', line 843
static VALUE
static_AdvantageInterface_AdsBeginTransaction(VALUE imp_drh, VALUE ads_conn)
{
imp_drh_st* s_imp_drh;
a_ads_connection* s_ads_conn;
UNSIGNED32 result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
result = s_imp_drh->api.AdsBeginTransaction(s_ads_conn->hConnect);
if ( result == 0 )
return( INT2NUM(1) );
else
return( INT2NUM(0) );
}
|