Class: SQLAnywhere::SQLAnywhereInterface
- Inherits:
-
Object
- Object
- SQLAnywhere::SQLAnywhereInterface
- Defined in:
- ext/sqlanywhere.c
Instance Method Summary collapse
-
#sqlany_affected_rows(VALUEimp_drh, VALUEsqlany_stmt) ⇒ Object
Returns the number of rows affected by execution of the prepared statement.
-
#sqlany_bind_param(VALUEimp_drh, VALUEsqlany_stmt, VALUEindex, VALUEsqlany_bind_param) ⇒ Object
Binds a user supplied buffer as a parameter to the prepared statement.
-
#sqlany_clear_error(VALUEimp_drh, VALUEsqlany_conn) ⇒ nil
Clears the last stored error code.
-
#sqlany_client_version(VALUEimp_drh) ⇒ Array
Retrieves the client version as a string.
-
#sqlany_commit(VALUEimp_drh, VALUEsqlany_conn) ⇒ Object
Commits the current transaction.
-
#sqlany_connect(VALUEimp_drh, VALUEsqlany_conn, VALUEstr) ⇒ Object
Creates a connection object.
-
#sqlany_describe_bind_param(VALUEimp_drh, VALUEsqlany_stmt, VALUEindex) ⇒ Array
Describes the bind parameters of a prepared statement.
-
#sqlany_disconnect(VALUEimp_drh, VALUEsqlany_conn) ⇒ nil
Disconnect an already established connection.
-
#sqlany_error(VALUEimp_drh, VALUEsqlany_conn) ⇒ Array
Retrieves the last error code and message.
-
#sqlany_execute(VALUEimp_drh, VALUEsqlany_stmt) ⇒ Object
Executes a prepared statement.
-
#sqlany_execute_direct(VALUEimp_drh, VALUEsqlany_conn, VALUEsql) ⇒ Object
Executes a SQL statement and possibly returns a result set.
-
#sqlany_execute_immediate(VALUEimp_drh, VALUEsqlany_conn, VALUEsql) ⇒ Object
Executes a SQL statement immediately without returning a result set.
-
#sqlany_fetch_absolute(VALUEimp_drh, VALUEsqlany_stmt, VALUEoffset) ⇒ Object
Fetches data at a specific row number in the result set.
-
#sqlany_fetch_next(VALUEimp_drh, VALUEsqlany_stmt) ⇒ Object
Fetches the next row from the result set.
-
#sqlany_fini(VALUEimp_drh) ⇒ nil
Finalizes the interface.
-
#sqlany_free_connection(VALUEimp_drh, VALUEsqlany_conn) ⇒ nil
Frees the resources associated with a connection object.
-
#sqlany_free_stmt(VALUEimp_drh, VALUEsqlany_stmt) ⇒ nil
Frees resources associated with a prepared statement object.
-
#sqlany_get_bind_param_info(VALUEimp_drh, VALUEsqlany_stmt, VALUEindex) ⇒ Array
Gets bound parameter info.
-
#sqlany_get_column(VALUEimp_drh, VALUEsqlany_stmt, VALUEcol_num) ⇒ Array
Retrieves the data fetched for the specified column.
-
#sqlany_get_column_info(VALUEimp_drh, VALUEsqlany_stmt, VALUEcol_num) ⇒ Array
Fetches the next row from the result set.
-
#sqlany_get_next_result(VALUEimp_drh, VALUEsqlany_stmt) ⇒ Object
Advances to the next result set in a multiple result set query.
-
#sqlany_init(VALUEimp_drh) ⇒ Array
Initializes the interface.
-
#sqlany_new_connection(VALUEimp_drh) ⇒ Object
Creates a connection object.
-
#sqlany_num_cols(VALUEimp_drh, VALUEsqlany_stmt) ⇒ Object
Returns number of columns in the result set.
-
#sqlany_num_params(VALUEimp_drh, VALUEsqlany_stmt) ⇒ Object
Returns the number of parameters that are expected for a prepared statement.
-
#sqlany_num_rows(VALUEimp_drh, VALUEsqlany_stmt) ⇒ Object
Returns number of rows in the result set.
-
#sqlany_prepare(VALUEimp_drh, VALUEsqlany_conn, VALUEsql) ⇒ Object
Prepares a SQL statement.
-
#sqlany_reset(VALUEimp_drh, VALUEsqlany_stmt) ⇒ Object
Parameters: -
VALUE imp_drh– An initialized API structure to finalize. -
#sqlany_rollback(VALUEimp_drh, VALUEsqlany_conn) ⇒ Object
Rolls back the current transaction.
-
#sqlany_sqlstate(VALUEimp_drh, VALUEsqlany_conn) ⇒ Object
Retrieves the current SQL state.
Instance Method Details
#sqlany_affected_rows(VALUEimp_drh, VALUEsqlany_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 sqlany_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.
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 |
# File 'ext/sqlanywhere.c', line 1080
static VALUE
static_SQLAnywhereInterface_sqlany_affected_rows(VALUE imp_drh, VALUE sqlany_stmt)
{
imp_drh_st* s_imp_drh;
a_sqlany_stmt* s_sqlany_stmt;
sacapi_i32 result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
result = s_imp_drh->api.sqlany_affected_rows(s_sqlany_stmt);
return ( INT2NUM(result) );
}
|
#sqlany_bind_param(VALUEimp_drh, VALUEsqlany_stmt, VALUEindex, VALUEsqlany_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 sqlany_stmt</tt> -- A statement object that was returned from sqlany_prepare().
- <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and sqlany_num_params() - 1.
- <tt>VALUE sqlany_bind_param</tt> -- A filled bind object retrieved from sqlany_describe_bind_param().
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on success or <tt>0</tt> on failure.
1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 |
# File 'ext/sqlanywhere.c', line 1165
static VALUE
static_SQLAnywhereInterface_sqlany_bind_param(VALUE imp_drh, VALUE sqlany_stmt, VALUE index, VALUE sqlany_bind_param )
{
imp_drh_st* s_imp_drh;
a_sqlany_stmt* s_sqlany_stmt;
a_sqlany_bind_param* s_sqlany_bind_param;
sacapi_bool result;
sacapi_u32 s_index;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
Data_Get_Struct(sqlany_bind_param, a_sqlany_bind_param, s_sqlany_bind_param);
s_index = NUM2INT(index);
result = s_imp_drh->api.sqlany_bind_param(s_sqlany_stmt, s_index, s_sqlany_bind_param);
return( INT2NUM(result) );
}
|
#sqlany_clear_error(VALUEimp_drh, VALUEsqlany_conn) ⇒ nil
Clears the last stored error code.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE sqlany_conn</tt> -- A connection object that was connected by sqlany_connect().
<b>Returns</b>:
- <tt>nil</tt>:.
1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 |
# File 'ext/sqlanywhere.c', line 1376
static VALUE
static_SQLAnywhereInterface_sqlany_clear_error(VALUE imp_drh, VALUE sqlany_conn)
{
imp_drh_st* s_imp_drh;
a_sqlany_connection* s_sqlany_conn;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
s_imp_drh->api.sqlany_clear_error(s_sqlany_conn);
return( Qnil );
}
|
#sqlany_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.
363 364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'ext/sqlanywhere.c', line 363
static VALUE
static_SQLAnywhereInterface_sqlany_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.sqlany_client_version(s_buffer, 255);
return (rb_str_new2(s_buffer));
}
|
#sqlany_commit(VALUEimp_drh, VALUEsqlany_conn) ⇒ Object
Commits the current transaction.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE sqlany_conn</tt> -- A connection object that was connected by sqlany_connect().
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on successful commit, <tt>0</tt> otherwise.
860 861 862 863 864 865 866 867 868 869 870 871 872 873 |
# File 'ext/sqlanywhere.c', line 860
static VALUE
static_SQLAnywhereInterface_sqlany_commit(VALUE imp_drh, VALUE sqlany_conn)
{
imp_drh_st* s_imp_drh;
a_sqlany_connection* s_sqlany_conn;
sacapi_bool result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
result = s_imp_drh->api.sqlany_commit(s_sqlany_conn);
return( INT2NUM(result) );
}
|
#sqlany_connect(VALUEimp_drh, VALUEsqlany_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 sqlany_conn</tt> -- A connection object that was created by sqlany_new_connection().
- <tt>VALUE str</tt> -- A SQL Anywhere connection string.
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on success, <tt>0</tt> on failure.
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
# File 'ext/sqlanywhere.c', line 396
static VALUE
static_SQLAnywhereInterface_sqlany_connect(VALUE imp_drh, VALUE sqlany_conn, VALUE str)
{
imp_drh_st* s_imp_drh;
a_sqlany_connection* s_sqlany_conn;
char* s_str;
sacapi_bool result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
s_str = StringValueCStr( str );
result = s_imp_drh->api.sqlany_connect( s_sqlany_conn, s_str );
return( INT2NUM(result) );
}
|
#sqlany_describe_bind_param(VALUEimp_drh, VALUEsqlany_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 sqlany_stmt</tt> -- A statement object that was returned from sqlany_prepare().
- <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and sqlany_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.
1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 |
# File 'ext/sqlanywhere.c', line 1117
static VALUE
static_SQLAnywhereInterface_sqlany_describe_bind_param(VALUE imp_drh, VALUE sqlany_stmt, VALUE index)
{
imp_drh_st* s_imp_drh;
a_sqlany_stmt* s_sqlany_stmt;
a_sqlany_bind_param* s_sqlany_bind_param;
sacapi_bool result;
sacapi_u32 s_index;
VALUE tdata;
VALUE multi_result;
s_sqlany_bind_param = malloc(sizeof(a_sqlany_bind_param));
memset( s_sqlany_bind_param, 0, sizeof(a_sqlany_bind_param) );
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
s_index = NUM2INT(index);
result = s_imp_drh->api.sqlany_describe_bind_param(s_sqlany_stmt, s_index, s_sqlany_bind_param);
//FIXME handle failed result
multi_result = rb_ary_new();
rb_ary_push(multi_result, INT2NUM(result));
tdata = Data_Wrap_Struct(cA_sqlany_bind_param, 0, 0, s_sqlany_bind_param);
rb_ary_push(multi_result, tdata);
return( multi_result );
}
|
#sqlany_disconnect(VALUEimp_drh, VALUEsqlany_conn) ⇒ nil
Disconnect an already established connection.
This function disconnects a SQL Anywhere connection. Any
uncommitted transactions will be rolled back.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE sqlany_conn</tt> -- A connection object that was connected by sqlany_connect().
<b>Returns</b>:
- <tt>nil</tt>.
431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
# File 'ext/sqlanywhere.c', line 431
static VALUE
static_SQLAnywhereInterface_sqlany_disconnect(VALUE imp_drh, VALUE sqlany_conn)
{
imp_drh_st* s_imp_drh;
a_sqlany_connection* s_sqlany_conn;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
s_imp_drh->api.sqlany_disconnect( s_sqlany_conn );
return( Qnil );
}
|
#sqlany_error(VALUEimp_drh, VALUEsqlany_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 sqlany_conn</tt> -- A connection object that was connected by sqlany_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.
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
# File 'ext/sqlanywhere.c', line 527
static VALUE
static_SQLAnywhereInterface_sqlany_error(VALUE imp_drh, VALUE sqlany_conn)
{
imp_drh_st* s_imp_drh;
a_sqlany_connection* s_sqlany_conn;
size_t s_size;
char s_buffer[255];
sacapi_i32 result;
VALUE multi_result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
result = s_imp_drh->api.sqlany_error(s_sqlany_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 );
}
|
#sqlany_execute(VALUEimp_drh, VALUEsqlany_stmt) ⇒ Object
Executes a prepared statement.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE sqlany_stmt</tt> -- A statement object that was created by sqlany_prepare() or sqlany_execute_direct().
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on successful execution, <tt>0</tt> otherwise.
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 |
# File 'ext/sqlanywhere.c', line 1050
static VALUE
static_SQLAnywhereInterface_sqlany_execute(VALUE imp_drh, VALUE sqlany_stmt)
{
imp_drh_st* s_imp_drh;
a_sqlany_stmt* s_sqlany_stmt;
sacapi_bool result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
result = s_imp_drh->api.sqlany_execute(s_sqlany_stmt);
return (INT2NUM(result));
}
|
#sqlany_execute_direct(VALUEimp_drh, VALUEsqlany_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 sqlany_prepare() followed
by sqlany_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 sqlany_conn</tt> -- A connection object that was connected by sqlany_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.
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 |
# File 'ext/sqlanywhere.c', line 610
static VALUE
static_SQLAnywhereInterface_sqlany_execute_direct(VALUE imp_drh, VALUE sqlany_conn, VALUE sql)
{
imp_drh_st* s_imp_drh;
a_sqlany_connection* s_sqlany_conn;
a_sqlany_stmt* resultset = NULL;
char* s_sql;
VALUE tdata;
s_sql = StringValueCStr( sql );
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
resultset = s_imp_drh->api.sqlany_execute_direct(s_sqlany_conn, s_sql);
if (resultset)
{
tdata = Data_Wrap_Struct(cA_sqlany_stmt, 0, 0, resultset);
}
else
{
tdata = Qnil;
}
return (tdata);
}
|
#sqlany_execute_immediate(VALUEimp_drh, VALUEsqlany_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 sqlany_conn</tt> -- A connection object that was connected by sqlany_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.
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
# File 'ext/sqlanywhere.c', line 569
static VALUE
static_SQLAnywhereInterface_sqlany_execute_immediate(VALUE imp_drh, VALUE sqlany_conn, VALUE sql)
{
imp_drh_st* s_imp_drh;
a_sqlany_connection* s_sqlany_conn;
char* s_sql;
sacapi_bool result;
s_sql = StringValueCStr( sql );
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
result = s_imp_drh->api.sqlany_execute_immediate(s_sqlany_conn, s_sql);
return( INT2NUM(result) );
}
|
#sqlany_fetch_absolute(VALUEimp_drh, VALUEsqlany_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 sqlany_stmt</tt> -- A statement object that was executed by sqlany_execute() or sqlany_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.
1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 |
# File 'ext/sqlanywhere.c', line 1316
static VALUE
static_SQLAnywhereInterface_sqlany_fetch_absolute(VALUE imp_drh, VALUE sqlany_stmt, VALUE offset)
{
imp_drh_st* s_imp_drh;
a_sqlany_stmt* s_sqlany_stmt;
sacapi_i32 s_offset;
sacapi_bool result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
s_offset = NUM2INT(offset);
result = s_imp_drh->api.sqlany_fetch_absolute(s_sqlany_stmt, s_offset);
return( INT2NUM(result) );
}
|
#sqlany_fetch_next(VALUEimp_drh, VALUEsqlany_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 sqlany_stmt</tt> -- A statement object that was created by sqlany_prepare() or sqlany_execute_direct().
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on successful fetch, <tt>0</tt> otherwise.
772 773 774 775 776 777 778 779 780 781 782 783 784 785 |
# File 'ext/sqlanywhere.c', line 772
static VALUE
static_SQLAnywhereInterface_sqlany_fetch_next(VALUE imp_drh, VALUE sqlany_stmt)
{
imp_drh_st* s_imp_drh;
a_sqlany_stmt* s_stmt;
sacapi_bool result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_stmt);
result = s_imp_drh->api.sqlany_fetch_next(s_stmt);
return( INT2NUM(result) );
}
|
#sqlany_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>.
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
# File 'ext/sqlanywhere.c', line 490
static VALUE
static_SQLAnywhereInterface_sqlany_fini(VALUE imp_drh)
{
imp_drh_st* s_imp_drh;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
if( IS_SACAPI_V2(s_imp_drh->api) ) {
s_imp_drh->api.sqlany_fini_ex(s_imp_drh->sacapi_context);
s_imp_drh->sacapi_context = NULL;
}
else {
s_imp_drh->api.sqlany_fini();
}
return( Qnil );
}
|
#sqlany_free_connection(VALUEimp_drh, VALUEsqlany_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 sqlany_conn</tt> -- A connection object that was disconnected by sqlany_disconnect().
<b>Returns</b>:
- <tt>nil</tt>.
460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
# File 'ext/sqlanywhere.c', line 460
static VALUE
static_SQLAnywhereInterface_sqlany_free_connection(VALUE imp_drh, VALUE sqlany_conn)
{
imp_drh_st* s_imp_drh;
a_sqlany_connection* s_sqlany_conn;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
s_imp_drh->api.sqlany_free_connection( s_sqlany_conn );
return( Qnil );
}
|
#sqlany_free_stmt(VALUEimp_drh, VALUEsqlany_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 sqlany_stmt</tt> -- A statement object that was created by sqlany_prepare() or sqlany_execute_direct().
<b>Returns</b>:
- <tt>nil</tt>.
971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 |
# File 'ext/sqlanywhere.c', line 971
static VALUE
static_SQLAnywhereInterface_sqlany_free_stmt(VALUE imp_drh, VALUE sqlany_stmt)
{
imp_drh_st* s_imp_drh;
a_sqlany_stmt* s_sqlany_stmt;
int i;
int number_of_params = 0;
a_sqlany_bind_param_info bind_info;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
number_of_params = s_imp_drh->api.sqlany_num_params(s_sqlany_stmt);
for (i = 0; i < number_of_params; i++)
{
if( s_imp_drh->api.sqlany_get_bind_param_info(s_sqlany_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.sqlany_free_stmt(s_sqlany_stmt);
return ( Qnil );
}
|
#sqlany_get_bind_param_info(VALUEimp_drh, VALUEsqlany_stmt, VALUEindex) ⇒ Array
Gets bound parameter info.
This function retrieves information about the parameters that were
bound using sqlany_bind_param().
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE sqlany_stmt</tt> -- A statement object that was returned from sqlany_prepare().
- <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and sqlany_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.
1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 |
# File 'ext/sqlanywhere.c', line 1203
static VALUE
static_SQLAnywhereInterface_sqlany_get_bind_param_info(VALUE imp_drh, VALUE sqlany_stmt, VALUE index)
{
imp_drh_st* s_imp_drh;
a_sqlany_stmt* s_sqlany_stmt;
a_sqlany_bind_param_info s_sqlany_bind_param_info;
sacapi_bool result;
sacapi_u32 s_index;
VALUE tdata;
VALUE multi_result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
s_index = NUM2INT(index);
result = s_imp_drh->api.sqlany_get_bind_param_info(s_sqlany_stmt, s_index, &s_sqlany_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_sqlany_bind_param_info, 0, 0, &s_sqlany_bind_param_info);
rb_ary_push(multi_result, tdata);
return( multi_result );
}
|
#sqlany_get_column(VALUEimp_drh, VALUEsqlany_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 sqlany_stmt</tt> -- A statement object that was created by sqlany_prepare() or sqlany_execute_direct().
- <tt>VALUE col_num</tt> -- The number of the column to be retrieved. A column number is between 0 and sqlany_num_cols() - 1.
<b>Returns</b>:
- <tt>VALUE column_value</tt>: The value of the column. nil is returned if the value was NULL.
715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 |
# File 'ext/sqlanywhere.c', line 715
static VALUE
static_SQLAnywhereInterface_sqlany_get_column(VALUE imp_drh, VALUE sqlany_stmt, VALUE col_num)
{
imp_drh_st* s_imp_drh;
a_sqlany_stmt* s_stmt;
sacapi_u32 s_col_num;
a_sqlany_data_value value;
sacapi_bool result;
VALUE multi_result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_stmt);
s_col_num = NUM2INT(col_num);
result = s_imp_drh->api.sqlany_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 );
}
|
#sqlany_get_column_info(VALUEimp_drh, VALUEsqlany_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 sqlany_stmt</tt> -- A statement object that was created by sqlany_prepare() or sqlany_execute_direct().
- <tt>VALUE col_num</tt> -- The number of the column to be retrieved. A column number is between 0 and sqlany_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 SQL Anywhere 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.
816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 |
# File 'ext/sqlanywhere.c', line 816
static VALUE
static_SQLAnywhereInterface_sqlany_get_column_info(VALUE imp_drh, VALUE sqlany_stmt, VALUE col_num)
{
imp_drh_st* s_imp_drh;
a_sqlany_stmt* s_stmt;
sacapi_u32 s_col_num;
a_sqlany_column_info info;
sacapi_bool result;
VALUE multi_result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_stmt);
s_col_num = NUM2INT(col_num);
result = s_imp_drh->api.sqlany_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 );
}
|
#sqlany_get_next_result(VALUEimp_drh, VALUEsqlany_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 sqlany_stmt</tt> -- A statement object that was executed by sqlany_execute() or sqlany_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.
1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 |
# File 'ext/sqlanywhere.c', line 1283
static VALUE
static_SQLAnywhereInterface_sqlany_get_next_result(VALUE imp_drh, VALUE sqlany_stmt)
{
imp_drh_st* s_imp_drh;
a_sqlany_stmt* s_sqlany_stmt;
sacapi_bool result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
result = s_imp_drh->api.sqlany_get_next_result(s_sqlany_stmt);
return( INT2NUM(result) );
}
|
#sqlany_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 302 303 304 305 306 307 308 309 310 311 312 313 |
# File 'ext/sqlanywhere.c', line 279
static VALUE
static_SQLAnywhereInterface_sqlany_init(VALUE imp_drh)
{
imp_drh_st* s_imp_drh;
sacapi_bool result;
sacapi_u32 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 {
if (IS_SACAPI_V2(s_imp_drh->api)) {
s_imp_drh->sacapi_context = s_imp_drh->api.sqlany_init_ex("RUBY", SQLANY_API_VERSION_2 , &s_version_available );
if ( s_imp_drh->sacapi_context == NULL ) {
rb_ary_push(multi_result, INT2NUM(0));
}
else {
rb_ary_push(multi_result, INT2NUM(1));
}
rb_ary_push(multi_result, INT2NUM(s_version_available));
}
else {
result = s_imp_drh->api.sqlany_init("RUBY", SQLANY_API_VERSION_1 , &s_version_available );
rb_ary_push(multi_result, INT2NUM(result));
rb_ary_push(multi_result, INT2NUM(s_version_available));
}
}
return( multi_result );
}
|
#sqlany_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.
332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'ext/sqlanywhere.c', line 332
static VALUE
static_SQLAnywhereInterface_sqlany_new_connection(VALUE imp_drh)
{
imp_drh_st* s_imp_drh;
a_sqlany_connection* ptr;
VALUE tdata;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
ptr = s_imp_drh->api.sqlany_new_connection();
tdata = Data_Wrap_Struct(cA_sqlany_connection, 0, 0, ptr);
return (tdata);
}
|
#sqlany_num_cols(VALUEimp_drh, VALUEsqlany_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 sqlany_stmt</tt> -- A statement object that was created by sqlany_prepare() or sqlany_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.
652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
# File 'ext/sqlanywhere.c', line 652
static VALUE
static_SQLAnywhereInterface_sqlany_num_cols(VALUE imp_drh, VALUE sqlany_stmt)
{
imp_drh_st* s_imp_drh;
a_sqlany_stmt* s_stmt;
sacapi_i32 result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_stmt);
result = s_imp_drh->api.sqlany_num_cols(s_stmt);
return( INT2NUM(result) );
}
|
#sqlany_num_params(VALUEimp_drh, VALUEsqlany_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 sqlany_bind_param().
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE sqlany_stmt</tt> -- A statement object that was returned from sqlany_prepare().
<b>Returns</b>:
- <tt>VALUE result</tt>: The number of parameters that are expected. <tt>-1</tt> if the sqlany_stmt object is not valid.
1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 |
# File 'ext/sqlanywhere.c', line 1250
static VALUE
static_SQLAnywhereInterface_sqlany_num_params(VALUE imp_drh, VALUE sqlany_stmt)
{
imp_drh_st* s_imp_drh;
a_sqlany_stmt* s_sqlany_stmt;
sacapi_i32 result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
result = s_imp_drh->api.sqlany_num_params(s_sqlany_stmt);
return( INT2NUM(result) );
}
|
#sqlany_num_rows(VALUEimp_drh, VALUEsqlany_stmt) ⇒ Object
Returns number of rows in the result set.
By default, this function only returns an estimate. To return an exact
count, users must set the ROW_COUNTS option on the connection.
Refer to SQL Anywhere documentation for the SQL syntax to set this option.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE sqlany_stmt</tt> -- A statement object that was created by sqlany_prepare() or sqlany_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.
685 686 687 688 689 690 691 692 693 694 695 696 697 698 |
# File 'ext/sqlanywhere.c', line 685
static VALUE
static_SQLAnywhereInterface_sqlany_num_rows(VALUE imp_drh, VALUE sqlany_stmt)
{
imp_drh_st* s_imp_drh;
a_sqlany_stmt* s_stmt;
sacapi_i32 result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_stmt);
result = s_imp_drh->api.sqlany_num_rows(s_stmt);
return( INT2NUM(result) );
}
|
#sqlany_prepare(VALUEimp_drh, VALUEsqlany_conn, VALUEsql) ⇒ Object
Prepares a SQL statement.
This function prepares the supplied SQL string. Execution does not
happen until sqlany_execute() is called. The returned statement object
should be freed using sqlany_free_stmt().
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE sqlany_conn</tt> -- A connection object that was connected by sqlany_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 sqlany_execute() to execute the statement.
925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 |
# File 'ext/sqlanywhere.c', line 925
static VALUE
static_SQLAnywhereInterface_sqlany_prepare(VALUE imp_drh, VALUE sqlany_conn, VALUE sql)
{
imp_drh_st* s_imp_drh;
a_sqlany_connection* s_sqlany_conn;
a_sqlany_stmt* ptr = NULL;
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(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
ptr = s_imp_drh->api.sqlany_prepare(s_sqlany_conn, s_sql);
if (ptr)
{
tdata = Data_Wrap_Struct(cA_sqlany_stmt, 0, 0, ptr);
}
else
{
tdata = Qnil;
}
return (tdata);
}
|
#sqlany_reset(VALUEimp_drh, VALUEsqlany_stmt) ⇒ Object
Parameters:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE sqlany_stmt</tt> -- A statement object that was created by sqlany_prepare() or sqlany_execute_direct().
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on successful execution, <tt>0</tt> otherwise.
1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 |
# File 'ext/sqlanywhere.c', line 1020
static VALUE
static_SQLAnywhereInterface_sqlany_reset(VALUE imp_drh, VALUE sqlany_stmt)
{
imp_drh_st* s_imp_drh;
a_sqlany_stmt* s_sqlany_stmt;
sacapi_bool result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_stmt, a_sqlany_stmt, s_sqlany_stmt);
result = s_imp_drh->api.sqlany_reset(s_sqlany_stmt);
return (INT2NUM(result));
}
|
#sqlany_rollback(VALUEimp_drh, VALUEsqlany_conn) ⇒ Object
Rolls back the current transaction.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE sqlany_conn</tt> -- A connection object that was connected by sqlany_connect().
<b>Returns</b>:
- <tt>VALUE result</tt>: <tt>1</tt> on successful rollback, <tt>0</tt> otherwise.
890 891 892 893 894 895 896 897 898 899 900 901 902 903 |
# File 'ext/sqlanywhere.c', line 890
static VALUE
static_SQLAnywhereInterface_sqlany_rollback(VALUE imp_drh, VALUE sqlany_conn)
{
imp_drh_st* s_imp_drh;
a_sqlany_connection* s_sqlany_conn;
sacapi_bool result;
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
result = s_imp_drh->api.sqlany_rollback(s_sqlany_conn);
return( INT2NUM(result) );
}
|
#sqlany_sqlstate(VALUEimp_drh, VALUEsqlany_conn) ⇒ Object
Retrieves the current SQL state.
<b>Parameters</b>:
- <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
- <tt>VALUE sqlany_conn</tt> -- A connection object that was connected by sqlany_connect().
<b>Returns</b>:
- <tt>VALUE sqlstate_str</tt>: The SQL State.
1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 |
# File 'ext/sqlanywhere.c', line 1346
static VALUE
static_SQLAnywhereInterface_sqlany_sqlstate(VALUE imp_drh, VALUE sqlany_conn)
{
imp_drh_st* s_imp_drh;
a_sqlany_connection* s_sqlany_conn;
size_t s_size;
char s_buffer[255];
Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
Data_Get_Struct(sqlany_conn, a_sqlany_connection, s_sqlany_conn);
s_size = s_imp_drh->api.sqlany_sqlstate(s_sqlany_conn, s_buffer, sizeof(s_buffer));
return( rb_str_new(s_buffer, s_size));
}
|