sqlany_execute_direct( a_sqlany_connection *, const char *) method

Executes the SQL statement specified by the string argument and possibly returns a result set.

Syntax

public a_sqlany_stmt * sqlany_execute_direct ( a_sqlany_connection * sqlany_conn, const char * sql_str)

Parameters

Returns

A statement handle if the function executes successfully, NULL when the function executes unsuccessfully.

Usage

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.