Class: Advantage::AdvantageInterface
- Inherits:
-
Object
- Object
- Advantage::AdvantageInterface
- Defined in:
- ext/advantage/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.
1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 |
# File 'ext/advantage/advantage.c', line 1121
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 (INT2FIX(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.
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 |
# File 'ext/advantage/advantage.c', line 1207
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 (INT2FIX(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>:.
1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 |
# File 'ext/advantage/advantage.c', line 1425
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.
358 359 360 361 362 363 364 365 366 367 368 369 |
# File 'ext/advantage/advantage.c', line 358
static VALUE
static_AdvantageInterface_ads_client_version(VALUE imp_drh)
{
imp_drh_st *s_imp_drh;
char s_buffer[255];
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
s_imp_drh->api.ads_client_version((UNSIGNED8 *)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.
878 879 880 881 882 883 884 885 886 887 888 889 890 891 |
# File 'ext/advantage/advantage.c', line 878
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 (INT2FIX(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.
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
# File 'ext/advantage/advantage.c', line 390
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, (UNSIGNED8 *)s_str);
return (INT2FIX(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.
1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 |
# File 'ext/advantage/advantage.c', line 1159
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, INT2FIX(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>.
425 426 427 428 429 430 431 432 433 434 435 436 437 |
# File 'ext/advantage/advantage.c', line 425
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.
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 |
# File 'ext/advantage/advantage.c', line 513
static VALUE
static_AdvantageInterface_ads_error(VALUE imp_drh, VALUE ads_conn)
{
imp_drh_st *s_imp_drh;
a_ads_connection *s_ads_conn;
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, (UNSIGNED8 *)s_buffer, 255);
multi_result = rb_ary_new();
rb_ary_push(multi_result, INT2FIX(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.
1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 |
# File 'ext/advantage/advantage.c', line 1086
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 (INT2FIX(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.
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 |
# File 'ext/advantage/advantage.c', line 595
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, (UNSIGNED8 *)s_sql);
if (resultset)
{
tdata = INT2FIX(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.
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 |
# File 'ext/advantage/advantage.c', line 554
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, (UNSIGNED8 *)s_sql);
return (INT2FIX(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.
1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 |
# File 'ext/advantage/advantage.c', line 1361
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 (INT2FIX(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.
757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 |
# File 'ext/advantage/advantage.c', line 757
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 (INT2FIX(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>.
482 483 484 485 486 487 488 489 490 491 492 |
# File 'ext/advantage/advantage.c', line 482
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>.
453 454 455 456 457 458 459 460 461 462 463 464 465 |
# File 'ext/advantage/advantage.c', line 453
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>.
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 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 |
# File 'ext/advantage/advantage.c', line 988
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.
1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 |
# File 'ext/advantage/advantage.c', line 1246
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, INT2FIX(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.
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 732 733 734 735 |
# File 'ext/advantage/advantage.c', line 698
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, INT2FIX(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.
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 828 829 830 831 |
# File 'ext/advantage/advantage.c', line 802
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, INT2FIX(result));
rb_ary_push(multi_result, col_num);
rb_ary_push(multi_result, rb_str_new2((char *)info.name));
rb_ary_push(multi_result, INT2FIX(info.type));
rb_ary_push(multi_result, INT2FIX(info.native_type));
rb_ary_push(multi_result, INT2FIX(info.precision));
rb_ary_push(multi_result, INT2FIX(info.scale));
rb_ary_push(multi_result, INT2FIX(info.max_size));
rb_ary_push(multi_result, INT2FIX(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.
1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 |
# File 'ext/advantage/advantage.c', line 1327
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 (INT2FIX(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.
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
# File 'ext/advantage/advantage.c', line 283
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, INT2FIX(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, INT2FIX(result));
rb_ary_push(multi_result, INT2FIX(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.
327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'ext/advantage/advantage.c', line 327
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.
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 |
# File 'ext/advantage/advantage.c', line 637
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.
1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 |
# File 'ext/advantage/advantage.c', line 1293
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 (INT2FIX(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.
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 |
# File 'ext/advantage/advantage.c', line 667
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 (INT2FIX(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.
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 968 969 |
# File 'ext/advantage/advantage.c', line 942
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;
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, (UNSIGNED8 *)s_sql, '\0');
if (s_stmt)
{
tdata = INT2FIX(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.
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 |
# File 'ext/advantage/advantage.c', line 1056
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 (INT2FIX(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.
907 908 909 910 911 912 913 914 915 916 917 918 919 920 |
# File 'ext/advantage/advantage.c', line 907
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 (INT2FIX(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.
1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 |
# File 'ext/advantage/advantage.c', line 1392
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;
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, (UNSIGNED8 *)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.
847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 |
# File 'ext/advantage/advantage.c', line 847
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 (INT2FIX(1));
else
return (INT2FIX(0));
}
|