int SQLiteSetOnColumn(int (*callback)(char *value, char*name));

 

Specifies a callback to be called as each column is returned from the database.

 

Return Value

 

Returns one if the call was successful.

 

Parameters

 

callback

Specifies the function to be called as column data is returned from the executed query.  The value parameter passed to the callback is a string representation of the value in the column.  The name parameter passed to the callback is the name of the column.

 

Note: The maximum size of value is 1,000 bytes.

 

Remarks

 

SQLiteSetOnColumn() specifies the callback function to be called as column data is returned from the database.  See also: SQLiteSetOnRow().

 

DragonFireSDK supports SQLite version 3.7.6.2.

 

Availability

 

Available in DragonFireSDK 2.0 and later.

 

Example

 

#include "DragonFireSDK.h"

 

int OnColumn(char *value, char *name)

{

  // Print the column name and value to the console window:

   printf("OnColumn: %s\t%s\n", name, value);

  return(1);

}

 

int OnRow(char *value)

{

  // Print the row to the console window:

   printf("OnRow: %s\n", value);

  return(1);

}

 

void AppMain()

{

  int result;

 

  // Create or open the database:

   result=SQLiteOpen("mydatabase.db");

   printf("SQLiteOpen result: %d\n", result);

 

  // Set up the OnColumn callback:

   result=SQLiteSetOnColumn(OnColumn);

   printf("SQLiteSetOnColumn result: %d\n", result);

 

  // Set up the OnRow callback:

   result=SQLiteSetOnRow(OnRow);

   printf("SQLiteSetOnRow result: %d\n", result);

 

  // Drop the any existing 'mytable':

   result=SQLiteExec("drop table mytable");

   printf("SQLiteExec (drop table query) result: %d\n", result);

 

  // Create a table called 'mytable':

   result=SQLiteExec("create table mytable (firstname varchar(30), lastname varchar(30), address varchar(50))");

   printf("SQLiteExec (create query) result: %d\n", result);

 

  // Insert a record into 'mytable':

   result=SQLiteExec("insert into mytable (firstname, lastname, address) values ('John','Doe','123 Main Street')");

   printf("SQLiteExec (insert query) result: %d\n", result);

 

  // Select all the rows from 'mytable':

   result=SQLiteExec("select * from mytable");

   printf("SQLiteExec (select query) result: %d\n", result);

 

  // Print the last encountered error to the console:

   printf("SQLiteGetLastError: %s\n", SQLiteGetLastError());

}

 

void AppExit()

{

  int result;

 

  // Close the database:

   result=SQLiteClose();

   printf("SQLiteClose result: %d\n", result);

}

 

void OnTimer()

{

 

}