ULRegisterSQLPassthroughCallback

Registers a callback function that provides ongoing status.

Syntax
void ULRegisterSQLPassthroughCallback (
    SQLCA * sqlca,
    ul_sql_passthrough_observer_fncallback,
    ul_void *   user_data
);
Parameters
  • sqlca   A pointer to the SQL Communications Area.

    In the C++ API use the Sqlca.GetCA method.

  • callback   The name of your callback function.

    A callback value of UL_NULL disables any previously registered callback function.

  • user_data   An alternative to global variables to make any context information globally accessible. This is required because you can call the callback function from any location in your application. UltraLite does not modify the supplied data; it simply passes it to your callback function when it is invoked.

    You can declare any data type and cast it into the correct type in your callback function. For example, you could include a line of the following form in your callback function:

    MyContextType * context = (MyContextType *)user_data;

Example

Here is a sample callback and code to invoke ULRegisterSQLPassthroughCallback:

static void UL_GENNED_FN_MOD passthroughCallback( ul_sql_passthrough_status * status )
{
	switch( status->state ) {
		case UL_SQL_PASSTHROUGH_STATE_STARTING:
			printf( "SQL Passthrough script execution starting\n" );
			break;
		case UL_SQL_PASSTHROUGH_STATE_RUNNING_SCRIPT:
			printf( "Executing script %d of %d\n", status->cur_script, status->script_count );
			break;
		case UL_SQL_PASSTHROUGH_STATE_DONE:
			printf( "Finished executing SQL Passthrough scripts\n" );
			break;
		default:
			printf( "SQL Passthrough script execution has failed\n" );
			break;
	}
}

int main() {
	ULSqlca	sqlca;

	sqlca.Initialize();
	ULRegisterSQLPassthroughCallback( sqlca.GetCA(), passthroughCallback, NULL );
	DatabaseManager * dm = ULInitDatabaseManager( sqlca );
	...
}
See also