/* ==================================================== * * Copyright 2008-2011 iAnywhere Solutions, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * limitations under the License. * * While not a requirement of the license, if you do modify this file, we * would appreciate hearing about it. Please email * sqlany_interfaces@sybase.com * * ==================================================== */ #ifndef SACAPI_H #define SACAPI_H /** \mainpage SQL Anywhere C API * * \section intro_sec Introduction * The purpose of this API is to simplify creating C/C++ wrapper drivers for various interpreted languages * such as PHP, Perl, Python, Ruby, and others. This API layer sits on top of DBLIB and was implemented * using Embedded SQL. This API is not a replacement of DBLIB. It is just a way to simplify creating applications * from C/C++ code without having to learn all the details of Embedded SQL. * * \section distribution Distribution of the API * The API is built as a DLL (shared object on UNIX). The name of the DLL is \b dbcapi.dll * ( \b libdbcapi.so on UNIX). This DLL is linked statically to DBLIB of the SQL Anywhere version that it was * built against. When dbcapi.dll is loaded, the corresponding dblibX.dll is loaded by the OS. Applications that * interface with dbcapi.dll can either link directly to it or load it dynamically. For dynamic * loading of the DLL, please refer to the Dynamic Loading section below. * * The file sacapi.h is the main header file for the API. It describes all the data types and the entry * points of the API. * * \section dynamic_loading Dynamically Loading the DLL * The header file sacapidll.h contains the proper code to dynamically load the DLL. An application would * need to include the sacapidll.h header file and compile in sacapidll.c with their source. * sqlany_initialize_interface() can be used to dynamically load the DLL and lookup all the entry points. * * \section threading_support Threading Support * The C API library is thread-unaware, meaning that the library does not perform any tasks that require * mutual exclusion. In order to allow the library to work in threaded applications, there is only one rule to * follow: no more than one request is allowed on a single connection . With this rule, the application * is responsible for doing mutual exclusion when accessing any connection-specific resource. This includes * connection handles, prepared statements, and result set objects. * * \version 2.0 */ /** \file sacapi.h * Main API header file. * This file describes all the data types and entry points of the API. */ /** Defines to indicate the API versions */ #define SQLANY_API_VERSION_1 1 /** Version 2 introduced the "_ex" functions and the ability to cancel requests. */ #define SQLANY_API_VERSION_2 2 /** Returns the minimal error buffer size. */ #define SACAPI_ERROR_SIZE 256 #if defined(__cplusplus) extern "C" { #endif /** A handle to an interface context */ typedef struct a_sqlany_interface_context a_sqlany_interface_context; /** A handle to a connection object */ typedef struct a_sqlany_connection a_sqlany_connection; /** A handle to a statement object */ typedef struct a_sqlany_stmt a_sqlany_stmt; #ifdef WIN32 /** A portable 32-bit signed value */ typedef __int32 sacapi_i32; /** A portable 32-bit unsigned value */ typedef unsigned __int32 sacapi_u32; /** A portable boolean value */ typedef sacapi_i32 sacapi_bool; #else /** A portable 32-bit signed value */ typedef signed int sacapi_i32; /** A portable 32-bit unsigned value */ typedef unsigned int sacapi_u32; /** A portable boolean value */ typedef sacapi_i32 sacapi_bool; #endif // TODO:Character set issues /** Specifies the data type being passed in or retrieved. */ typedef enum a_sqlany_data_type { /// Invalid data type. A_INVALID_TYPE, /// Binary data. Binary data is treated as-is and no character set conversion is performed. A_BINARY, /// String data. The data where character set conversion is performed. A_STRING, /// Double data. Includes float values. A_DOUBLE, /// 64-bit integer. A_VAL64, /// 64-bit unsigned integer. A_UVAL64, /// 32-bit integer. A_VAL32, /// 32-bit unsigned integer. A_UVAL32, /// 16-bit integer. A_VAL16, /// 16-bit unsigned integer. A_UVAL16, /// 8-bit integer. A_VAL8, /// 8-bit unsigned integer. A_UVAL8 } a_sqlany_data_type; /** Returns a description of the attributes of a data value. * * To view examples of the a_sqlany_data_value structure in use, * see any of the following sample files in the sdk\\dbcapi\\examples directory * of your SQL Anywhere installation. * *
* sacapi_u32 api_version;
* if( sqlany_init( "PHP", SQLANY_API_VERSION_1, &api_version ) ) {
* printf( "Interface initialized successfully!\n" );
* } else {
* printf( "Failed to initialize the interface! Supported version=%d\n", api_version );
* }
*
*
* \param app_name A string that names the application that is using the API. For example, "PHP", "PERL", or "RUBY".
* \param api_version The version of the compiled application.
* \param version_available An optional argument to return the maximum supported API version.
* \return 1 on success, 0 otherwise
* \sa sqlany_fini()
*/
sacapi_bool sqlany_init( const char * app_name, sacapi_u32 api_version, sacapi_u32 * version_available );
#if _SACAPI_VERSION+0 >= 2
/** Initializes the interface using a context.
*
* \param app_name A string that names the API used, for example "PHP", "PERL", or "RUBY".
* \param api_version The current API version that the application is using.
* This should normally be one of the SQLANY_API_VERSION_* macros
* \param version_available An optional argument to return the maximum API version that is supported.
* \return a context object on success and NULL on failure.
* \sa sqlany_fini_ex()
*/
a_sqlany_interface_context *sqlany_init_ex( const char * app_name, sacapi_u32 api_version, sacapi_u32 * version_available );
#endif
/** Finalizes the interface.
*
* Frees any resources allocated by the API.
*
* \sa sqlany_init()
*/
void sqlany_fini();
#if _SACAPI_VERSION+0 >= 2
/** Finalize the interface that was created using the specified context.
* Frees any resources allocated by the API.
* \param context A context object that was returned from sqlany_init_ex()
* \sa sqlany_init_ex()
*/
void sqlany_fini_ex( a_sqlany_interface_context *context );
#endif
/** Creates a connection object.
*
* You must create an API connection object before establishing a database connection. Errors can be retrieved
* from the connection object. Only one request can be processed on a connection at a time. In addition,
* not more than one thread is allowed to access a connection object at a time. Undefined behavior or a failure
* occurs when multiple threads attempt to access a connection object simultaneously.
*
* \return A connection object
* \sa sqlany_connect(), sqlany_disconnect()
*/
a_sqlany_connection * sqlany_new_connection( void );
#if _SACAPI_VERSION+0 >= 2
/** Creates a connection object using a context.
* 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. In addition,
* not more than one thread is allowed to access a connection object at a time. If multiple threads attempt
* to access a connection object simultaneously, then undefined behaviour/crashes will occur.
* \param context A context object that was returned from sqlany_init_ex()
* \return A connection object
* \sa sqlany_connect(), sqlany_disconnect(), sqlany_init_ex()
*/
a_sqlany_connection *sqlany_new_connection_ex( a_sqlany_interface_context *context );
#endif
/** Frees the resources associated with a connection object.
*
* \param sqlany_conn A connection object created with sqlany_new_connection().
* \sa sqlany_new_connection()
*/
void sqlany_free_connection( a_sqlany_connection *sqlany_conn );
/** Creates a connection object based on a supplied DBLIB SQLCA pointer.
*
* \param arg A void * pointer to a DBLIB SQLCA object.
* \return A connection object.
* \sa sqlany_new_connection(), sqlany_execute(), sqlany_execute_direct(), sqlany_execute_immediate(), sqlany_prepare()
*/
a_sqlany_connection * sqlany_make_connection( void * arg );
#if _SACAPI_VERSION+0 >= 2
/** Creates a connection object based on a supplied DBLIB SQLCA pointer and context.
* \param context A valid context object that was created by sqlany_init_ex()
* \param arg A void * pointer to a DBLIB SQLCA object.
* \return A connection object.
* \sa sqlany_init_ex(), sqlany_execute(), sqlany_execute_direct(), sqlany_execute_immediate(), sqlany_prepare()
*/
a_sqlany_connection *sqlany_make_connection_ex( a_sqlany_interface_context *context, void *arg );
#endif
/** Creates a connection to a SQL Anywhere database server using the supplied connection object and connection string.
*
* The supplied connection object must first be allocated using sqlany_new_connection().
*
* The following example demonstrates how to retrieve the error code of a failed connection attempt:
*
*
* a_sqlany_connection * sqlany_conn;
* sqlany_conn = sqlany_new_connection();
* if( !sqlany_connect( sqlany_conn, "uid=dba;pwd=sql" ) ) {
* char reason[SACAPI_ERROR_SIZE];
* sacapi_i32 code;
* code = sqlany_error( sqlany_conn, reason, sizeof(reason) );
* printf( "Connection failed. Code: %d Reason: %s\n", code, reason );
* } else {
* printf( "Connected successfully!\n" );
* sqlany_disconnect( sqlany_conn );
* }
* sqlany_free_connection( sqlany_conn );
*
*
* For more information on connecting to a SQL Anywhere database server, see
* \salink{Connection parameters, "http://dcx.sybase.com/selectproduct?turl=1201en/dbadmin/da-conparm.html", "dbadmin", "da-conparm"} and
* \salink{SQL Anywhere database connections, "http://dcx.sybase.com/selectproduct?turl=1201en/dbadmin/da-dbconnections.html", "dbadmin", "da-dbconnections"}.
*
* \param sqlany_conn A connection object created by sqlany_new_connection().
* \param str A SQL Anywhere connection string.
* \return 1 if the connection is established successfully or 0 when the connection fails. Use sqlany_error() to
* retrieve the error code and message.
* \sa sqlany_new_connection(), sqlany_error()
*/
sacapi_bool sqlany_connect( a_sqlany_connection * sqlany_conn, const char * str );
/** Disconnects an already established SQL Anywhere connection.
*
* All uncommitted transactions are rolled back.
*
* \param sqlany_conn A connection object with a connection established using sqlany_connect().
* \return 1 when successful or 0 when unsuccessful.
* \sa sqlany_connect(), sqlany_new_connection()
*/
sacapi_bool sqlany_disconnect( a_sqlany_connection * sqlany_conn );
#if _SACAPI_VERSION+0 >= 2
/** Cancel an outstanding request on a connection.
* This function can be used to cancel an outstanding request on a specific connection.
* \param sqlany_conn A connection object with a connection established using sqlany_connect().
*/
void sqlany_cancel( a_sqlany_connection * sqlany_conn );
#endif
/** Executes the supplied SQL statement immediately without returning a result set.
*
* This function is useful for SQL statements that do not return a result set.
*
* \param sqlany_conn A connection object with a connection established using sqlany_connect().
* \param sql A string representing the SQL statement to be executed.
* \return 1 on success or 0 on failure.
*/
sacapi_bool sqlany_execute_immediate( a_sqlany_connection * sqlany_conn, const char * sql );
/** Prepares a supplied SQL string.
*
* Execution does not happen until sqlany_execute() is
* called. The returned statement object should be freed using sqlany_free_stmt().
*
* The following statement demonstrates how to prepare a SELECT SQL string:
*
*
* char * str;
* a_sqlany_stmt * stmt;
*
* str = "select * from employees where salary >= ?";
* stmt = sqlany_prepare( sqlany_conn, str );
* if( stmt == NULL ) {
* // Failed to prepare statement, call sqlany_error() for more info
* }
*
*
* \param sqlany_conn A connection object with a connection established using sqlany_connect().
* \param sql_str The SQL statement to be prepared.
* \return A handle to a SQL Anywhere statement object. The statement object can be used by sqlany_execute()
* to execute the statement.
* \sa sqlany_free_stmt(), sqlany_connect(), sqlany_execute(), sqlany_num_params(), sqlany_describe_bind_param(), sqlany_bind_param()
*/
a_sqlany_stmt * sqlany_prepare( a_sqlany_connection * sqlany_conn, const char * sql_str );
/** Frees resources associated with a prepared statement object.
*
* \param sqlany_stmt A statement object returned by the successful execution of sqlany_prepare() or sqlany_execute_direct().
* \sa sqlany_prepare(), sqlany_execute_direct()
*/
void sqlany_free_stmt( a_sqlany_stmt * sqlany_stmt );
/** Returns the number of parameters expected for a prepared statement.
*
* \param sqlany_stmt A statement object returned by the successful execution of sqlany_prepare().
* \return The expected number of parameters, or -1 if the statement object is not valid.
* \sa sqlany_prepare()
*/
sacapi_i32 sqlany_num_params( a_sqlany_stmt * sqlany_stmt );
/** Describes the bind parameters of a prepared statement.
*
* This function allows the caller to determine information about prepared statement parameters. The type of prepared
* statement, stored procedured or a DML, determines the amount of information provided. The direction of the parameters
* (input, output, or input-output) are always provided.
*
* \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
* \param index The index of the parameter. This number must be between 0 and sqlany_num_params() - 1.
* \param param A a_sqlany_bind_param structure that is populated with information.
* \return 1 when successful or 0 when unsuccessful.
* \sa sqlany_bind_param(), sqlany_prepare()
*/
sacapi_bool sqlany_describe_bind_param( a_sqlany_stmt * sqlany_stmt, sacapi_u32 index, a_sqlany_bind_param * param );
/** Bind a user-supplied buffer as a parameter to the prepared statement.
*
* \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
* \param index The index of the parameter. This number must be between 0 and sqlany_num_params() - 1.
* \param param A a_sqlany_bind_param structure description of the parameter to be bound.
* \return 1 on success or 0 on unsuccessful.
* \sa sqlany_describe_bind_param()
*/
sacapi_bool sqlany_bind_param( a_sqlany_stmt * sqlany_stmt, sacapi_u32 index, a_sqlany_bind_param * param );
/** Sends data as part of a bound parameter.
*
* This method can be used to send a large amount of data for a bound parameter in chunks.
*
* \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
* \param index The index of the parameter. This should be a number between 0 and sqlany_num_params() - 1.
* \param buffer The data to be sent.
* \param size The number of bytes to send.
* \return 1 on success or 0 on failure.
* \sa sqlany_prepare()
*/
sacapi_bool sqlany_send_param_data( a_sqlany_stmt * sqlany_stmt, sacapi_u32 index, char * buffer, size_t size );
/** Resets a statement to its prepared state condition.
*
* \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
* \return 1 on success, 0 on failure.
* \sa sqlany_prepare()
*/
sacapi_bool sqlany_reset( a_sqlany_stmt * sqlany_stmt );
/** Retrieves information about the parameters that were bound using sqlany_bind_param().
*
* \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
* \param index The index of the parameter. This number should be between 0 and sqlany_num_params() - 1.
* \param info A sqlany_bind_param_info buffer to be populated with the bound parameter's information.
* \return 1 on success or 0 on failure.
* \sa sqlany_bind_param(), sqlany_describe_bind_param(), sqlany_prepare()
*/
sacapi_bool sqlany_get_bind_param_info( a_sqlany_stmt * sqlany_stmt, sacapi_u32 index, a_sqlany_bind_param_info * info );
/** Executes a prepared statement.
*
* You can use sqlany_num_cols() to verify if the executed statement returned a result set.
*
* The following example shows how to execute a statement that does not return a result set:
*
*
* a_sqlany_stmt * stmt;
* int i;
* a_sqlany_bind_param param;
*
* stmt = sqlany_prepare( sqlany_conn, "insert into moe(id,value) values( ?,? )" );
* if( stmt ) {
* sqlany_describe_bind_param( stmt, 0, ¶m );
* param.value.buffer = (char *)\&i;
* param.value.type = A_VAL32;
* sqlany_bind_param( stmt, 0, ¶m );
*
* sqlany_describe_bind_param( stmt, 1, ¶m );
* param.value.buffer = (char *)\&i;
* param.value.type = A_VAL32;
* sqlany_bind_param( stmt, 1, ¶m );
*
* for( i = 0; i < 10; i++ ) {
* if( !sqlany_execute( stmt ) ) {
* // call sqlany_error()
* }
* }
* sqlany_free_stmt( stmt );
* }
*
*
* \param sqlany_stmt A statement prepared successfully using sqlany_prepare().
* \return 1 if the statement is executed successfully or 0 on failure.
* \sa sqlany_prepare()
*/
sacapi_bool sqlany_execute( a_sqlany_stmt * sqlany_stmt );
/** Executes the SQL statement specified by the string argument and possibly returns a result set.
*
* Use this method if you want to prepare and execute a statement,
* or instead of calling sqlany_prepare() followed by sqlany_execute().
*
* The following example shows how to execute a statement that returns a result set:
*
*
* a_sqlany_stmt * stmt;
*
* stmt = sqlany_execute_direct( sqlany_conn, "select * from employees" );
* if( stmt && sqlany_num_cols( stmt ) > 0 ) {
* while( sqlany_fetch_next( stmt ) ) {
* int i;
* for( i = 0; i < sqlany_num_cols( stmt ); i++ ) {
* // Get column i data
* }
* }
* sqlany_free_stmt( stmt );
* }
*
*
* Note: This function cannot be used for executing a SQL statement with parameters.
*
* \param sqlany_conn A connection object with a connection established using sqlany_connect().
* \param sql_str A SQL string. The SQL string should not have parameters such as ?.
* \return A statement handle if the function executes successfully, NULL when the function executes unsuccessfully.
* \sa sqlany_fetch_absolute(), sqlany_fetch_next(), sqlany_num_cols(), sqlany_get_column()
*/
a_sqlany_stmt * sqlany_execute_direct( a_sqlany_connection * sqlany_conn, const char * sql_str );
/** Moves the current row in the result set to the row number specified and then fetches the data at that row.
*
* \param sqlany_stmt A statement object that was executed by
* sqlany_execute() or sqlany_execute_direct().
* \param row_num The row number to be fetched. The first row is 1, the last row is -1.
* \return 1 if the fetch was successfully, 0 when the fetch is unsuccessful.
* \sa sqlany_execute_direct(), sqlany_execute(), sqlany_error(), sqlany_fetch_next()
*/
sacapi_bool sqlany_fetch_absolute( a_sqlany_stmt * sqlany_stmt, sacapi_i32 row_num );
/** Returns 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 before the first row, that is, row 0.
* This function first advances the row pointer and then fetches
* the data at the new row.
*
* \param sqlany_stmt A statement object that was executed by
* sqlany_execute() or sqlany_execute_direct().
* \return 1 if the fetch was successfully, 0 when the fetch is unsuccessful.
* \sa sqlany_fetch_absolute(), sqlany_execute_direct(), sqlany_execute(), sqlany_error()
*/
sacapi_bool sqlany_fetch_next( a_sqlany_stmt * sqlany_stmt );
/** 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.
*
* The following example demonstrates how to advance to the next result set in a multiple result set query:
*
*
* stmt = sqlany_execute_direct( sqlany_conn, "call my_multiple_results_procedure()" );
* if( result ) {
* do {
* while( sqlany_fetch_next( stmt ) ) {
* // get column data
* }
* } while( sqlany_get_next_result( stmt ) );
* sqlany_free_stmt( stmt );
* }
*
*
* \param sqlany_stmt A statement object executed by
* sqlany_execute() or sqlany_execute_direct().
* \return 1 if the statement successfully advances to the next result set, 0 otherwise.
* \sa sqlany_execute_direct(), sqlany_execute()
*/
sacapi_bool sqlany_get_next_result( a_sqlany_stmt * sqlany_stmt );
/** Returns the number of rows affected by execution of the prepared statement.
*
* \param sqlany_stmt A statement that was prepared and executed successfully with no result set returned.
* For example, an INSERT, UPDATE or DELETE statement was executed.
* \return The number of rows affected or -1 on failure.
* \sa sqlany_execute(), sqlany_execute_direct()
*/
sacapi_i32 sqlany_affected_rows( a_sqlany_stmt * sqlany_stmt );
/** Returns number of columns in the result set.
*
* \param sqlany_stmt A statement object created by sqlany_prepare() or sqlany_execute_direct().
* \return The number of columns in the result set or -1 on a failure.
* \sa sqlany_execute(), sqlany_execute_direct(), sqlany_prepare()
*/
sacapi_i32 sqlany_num_cols( a_sqlany_stmt * sqlany_stmt );
/** Returns the number of rows in the result set.
*
* By default this function only returns an estimate. To return an exact count, set the row_counts option
* on the connection. For more information on the row_counts option, see
* \salink{row_counts option [database], "http://dcx.sybase.com/selectproduct?turl=1201en/dbadmin/row-counts-option.html", "dbadmin", "row-counts-option"}.
*
* \param sqlany_stmt A statement object that was executed by
* sqlany_execute() or sqlany_execute_direct().
* \return The number rows in the result set. If the number of rows is an estimate, the number returned is
* negative and the estimate is the absolute value of the returned integer. The value returned is positive
* if the number of rows is exact.
* \sa sqlany_execute_direct(), sqlany_execute()
*/
sacapi_i32 sqlany_num_rows( a_sqlany_stmt * sqlany_stmt );
/** Fills the supplied buffer with the value fetched for the specified column.
*
* For A_BINARY and A_STRING * data types,
* value->buffer points to an internal buffer associated with the result set.
* Do not rely upon or alter the content of the pointer buffer as it changes when a
* new row is fetched or when the result set object is freed. Users should copy the
* data out of those pointers into their own buffers.
*
* The value->length field indicates the number of valid characters that
* value->buffer points to. The data returned in value->buffer is not
* null-terminated. This function fetches all the returned values from the SQL
* Anywhere database server. For example, if the column contains
* a 2GB blob, this function attempts to allocate enough memory to hold that value.
* If you do not want to allocate memory, use sqlany_get_data() instead.
*
* \param sqlany_stmt A statement object executed by
* sqlany_execute() or sqlany_execute_direct().
* \param col_index The number of the column to be retrieved.
* A column number is between 0 and sqlany_num_cols() - 1.
* \param buffer A a_sqlany_data_value object to be filled with the data fetched for column col_index.
* \return 1 on success or 0 for failure. A failure can happen if any of the parameters are invalid or if there is
* not enough memory to retrieve the full value from the SQL Anywhere database server.
* \sa sqlany_execute_direct(), sqlany_execute(), sqlany_fetch_absolute(), sqlany_fetch_next()
*/
sacapi_bool sqlany_get_column( a_sqlany_stmt * sqlany_stmt, sacapi_u32 col_index, a_sqlany_data_value * buffer );
/** Retrieves the data fetched for the specified column into the supplied buffer memory.
*
* \param sqlany_stmt A statement object executed by
* sqlany_execute() or sqlany_execute_direct().
* \param col_index The number of the column to be retrieved.
* A column number is between 0 and sqlany_num_cols() - 1.
* \param offset The starting offset of the data to get.
* \param buffer A buffer to be filled with the contents of the column. The buffer pointer must be aligned correctly
* for the data type copied into it.
* \param size The size of the buffer in bytes. The function fails
* if you specify a size greater than 2GB.
* \return The number of bytes successfully copied into the supplied buffer.
* This number must not exceed 2GB.
* 0 indicates that no data remains to be copied. -1 indicates a failure.
* \sa sqlany_execute(), sqlany_execute_direct(), sqlany_fetch_absolute(), sqlany_fetch_next()
*/
sacapi_i32 sqlany_get_data( a_sqlany_stmt * sqlany_stmt, sacapi_u32 col_index, size_t offset, void * buffer, size_t size );
/** Retrieves information about the data that was fetched by the last fetch operation.
*
* \param sqlany_stmt A statement object executed by
* sqlany_execute() or sqlany_execute_direct().
* \param col_index The column number between 0 and sqlany_num_cols() - 1.
* \param buffer A data info buffer to be filled with the metadata about the data fetched.
* \return 1 on success, and 0 on failure. Failure is returned when any of the supplied parameters are invalid.
* \sa sqlany_execute(), sqlany_execute_direct(), sqlany_fetch_absolute(), sqlany_fetch_next()
*/
sacapi_bool sqlany_get_data_info( a_sqlany_stmt * sqlany_stmt, sacapi_u32 col_index, a_sqlany_data_info * buffer );
/** Retrieves column metadata information and fills the a_sqlany_column_info structure with information about the column.
*
* \param sqlany_stmt A statement object created by sqlany_prepare() or sqlany_execute_direct().
* \param col_index The column number between 0 and sqlany_num_cols() - 1.
* \param buffer A column info structure to be filled with column information.
* \return 1 on success or 0 if the column index is out of range,
* or if the statement does not return a result set.
* \sa sqlany_execute(), sqlany_execute_direct(), sqlany_prepare()
*/
sacapi_bool sqlany_get_column_info( a_sqlany_stmt * sqlany_stmt, sacapi_u32 col_index, a_sqlany_column_info * buffer );
/** Commits the current transaction.
*
* \param sqlany_conn The connection object on which the commit operation is performed.
* \return 1 when successful or 0 when unsuccessful.
* \sa sqlany_rollback()
*/
sacapi_bool sqlany_commit( a_sqlany_connection * sqlany_conn );
/** Rolls back the current transaction.
*
* \param sqlany_conn The connection object on which the rollback operation is to be performed.
* \return 1 on success, 0 otherwise.
* \sa sqlany_commit()
*/
sacapi_bool sqlany_rollback( a_sqlany_connection * sqlany_conn );
/** Returns the current client version.
*
* This method fills the buffer passed with the major, minor, patch, and build number of the client library.
* The buffer will be null-terminated.
*
* \param buffer The buffer to be filled with the client version string.
* \param len The length of the buffer supplied.
* \return 1 when successful or 0 when unsuccessful.
*/
sacapi_bool sqlany_client_version( char * buffer, size_t len );
#if _SACAPI_VERSION+0 >= 2
/** Returns the current client version.
*
* This method fills the buffer passed with the major, minor, patch, and build number of the client library.
* The buffer will be null-terminated.
*
* \param context object that was create with sqlany_init_ex()
* \param buffer The buffer to be filled with the client version string.
* \param len The length of the buffer supplied.
* \return 1 when successful or 0 when unsuccessful.
* \sa sqlany_init_ex()
*/
sacapi_bool sqlany_client_version_ex( a_sqlany_interface_context *context, char *buffer, size_t len );
#endif
/** Retrieves the last error code and message stored in the connection object.
*
* For more information on SQLCODE error messages, see
* \salink{SQL Anywhere error messages sorted by SQLCODE, "http://dcx.sybase.com/selectproduct?turl=1201en/saerrors/sa-errors-by-sqlcode.html", "errors", "sa-errors-by-sqlcode"}.
*
* \param sqlany_conn A connection object returned from sqlany_new_connection().
* \param buffer A buffer to be filled with the error message.
* \param size The size of the supplied buffer.
* \return The last error code. Positive values are warnings, negative values are errors, and 0 indicates success.
* \sa sqlany_connect()
*/
sacapi_i32 sqlany_error( a_sqlany_connection * sqlany_conn, char * buffer, size_t size );
/** Retrieves the current SQLSTATE.
*
* For more information on SQLSTATE error messages, see
* \salink{SQL Anywhere error messages sorted by SQLSTATE, "http://dcx.sybase.com/selectproduct?turl=1201en/saerrors/sa-errors-by-sqlstate.html", "errors", "sa-errors-by-sqlstate"}.
*
* \param sqlany_conn A connection object returned from sqlany_new_connection().
* \param buffer A buffer to be filled with the current 5-character SQLSTATE.
* \param size The buffer size.
* \return The number of bytes copied into the buffer.
* \sa sqlany_error()
*/
size_t sqlany_sqlstate( a_sqlany_connection * sqlany_conn, char * buffer, size_t size );
/** Clears the last stored error code
*
* \param sqlany_conn A connection object returned from sqlany_new_connection().
* \sa sqlany_new_connection()
*/
void sqlany_clear_error( a_sqlany_connection * sqlany_conn );
#if defined(__cplusplus)
}
#endif
/** \example connecting.cpp
* This is an example of how to create a connection object and connect with it to SQL Anywhere.
*/
/** \example fetching_a_result_set.cpp
* This example shows how to fetch data from a result set.
*/
/** \example preparing_statements.cpp
* This example shows how to prepare and execute a statement.
*/
/** \example fetching_multiple_from_sp.cpp
* This example shows how to fetch multiple result sets from a stored procedure.
*/
/** \example send_retrieve_part_blob.cpp
* This example shows how to insert a blob in chunks and retrieve it in chunks too.
*/
/** \example send_retrieve_full_blob.cpp
* This example shows how to insert and retrieve a blob in one chunk .
*/
/** \example dbcapi_isql.cpp
* This example shows how to write an ISQL application using dbcapi.
*/
#endif