Main Page | Modules | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals

Data Access
[SQL Abstraction Layer]


Functions

alp_status_t alp_sal_database_open (AlpSALHandle *sal, const char *dbName)
alp_status_t alp_sal_database_close (AlpSALHandle sal)
alp_status_t alp_sal_database_create (const char *dbFileName, const char *schemaFileName)
alp_status_t alp_sal_transaction_commit (AlpSALHandle sal)
alp_status_t alp_sal_transaction_begin (AlpSALHandle sal, char exclusive)
alp_status_t alp_sal_transaction_rollback (AlpSALHandle sal)
alp_status_t alp_sal_sql_execute (AlpSALHandle sal, const char *sql,...)
alp_status_t alp_sal_last_insert_rowid (AlpSALHandle sal, uint32_t *rowID)
alp_status_t alp_sal_execute_sql_script (AlpSALHandle sal, FILE *fd)
alp_status_t alp_sal_sql_get_value (AlpSALHandle sal, int32_t *value, const char *sql,...)
const char * alp_sal_get_error_message (AlpSALHandle sal)
alp_status_t alp_sal_string_build (char **combined, const char *sql,...)
void alp_sal_string_destroy (char *s)


Function Documentation

alp_status_t alp_sal_database_close AlpSALHandle  sal  ) 
 

Closes a given database handle.

Parameters:
[in] sal The AlpSALHandle to close
Returns:
alp_status_t
See also:
alp_sal_database_open

alp_status_t alp_sal_database_create const char *  dbFileName,
const char *  schemaFileName
 

Creates a database and initializes its schema.

Parameters:
[in] dbFileName Path to file to store the created database
Returns:
alp_status_t

alp_status_t alp_sal_database_open AlpSALHandle sal,
const char *  dbName
 

Opens a given database handle. The database should be closed when no longer needed with alp_sal_database_close()

Parameters:
[out] sal Address of a pointer to the AlpSALHandle
[in] dbName Filename of the SQL database
Returns:
alp_status_t
See also:
alp_sal_database_close

alp_status_t alp_sal_execute_sql_script AlpSALHandle  sal,
FILE *  fd
 

Reads in all the text from the given file descriptor for a file that contains SQL commands. Once the file is read into memory, it's the executed and the buffer is freed. This is usful for initializing a table or schema using a resource file.

Parameters:
[in] sal AlpSALHandle of database to execute against
[in] fd Open file descriptor of a text file containing SQL commands
Returns:
alp_status_t

const char* alp_sal_get_error_message AlpSALHandle  sal  ) 
 

Returns string describing last error generated by Database

Parameters:
[in] sal database to read error string from
Returns:
pointer to string owned by SQL engine representing last error message generated

alp_status_t alp_sal_last_insert_rowid AlpSALHandle  sal,
uint32_t *  rowID
 

Assigns rowID to be the last auto-generated primary key created by an SQL INSERT statement

Parameters:
[in] sal AlpSALHandle of database to execute against
[out] rowID Primary Key generated by last INSERT statement
Returns:
alp_status_t

alp_status_t alp_sal_sql_execute AlpSALHandle  sal,
const char *  sql,
  ...
 

Executes a sql command given in a string buffer with a variable list of host parameter arguments. After plugging in the host variables to the sql string, the sql is executed and the buffer created by this routine is freed.

In addition to the subsitution variables supported by printf, this routine also supports the variable: "%Q". When using Q, the string passed will get single quote escaped, or will get "NULL" if the string is null. If the string contains a single quote, it will be escaped (doubled) to form ''

Parameters:
[in] sal AlpSALHandle of database to execute against
[in] sql SQL string
[in] variables va_list of host variables to plug into SQL string
Returns:
alp_status_t

alp_status_t alp_sal_sql_get_value AlpSALHandle  sal,
int32_t *  value,
const char *  sql,
  ...
 

Given a SQL statement, usually of the form "SELECT COUNT(*) FROM..." this function will prepare the statement from the SQL string and given host variables, if any, then execute the statement and read back the first column of the first row returned in the result set and assign that to value.

Parameters:
[in] sal The database to execute the selection statement against
[out] value Will obtain the result from the selection.
[in] va_list Host parameters, if any to plug into sql statement
Returns:
alp_status_t

alp_status_t alp_sal_string_build char **  combined,
const char *  sql,
  ...
 

Creates a copy of the given SQL string returned in the first parameter, that has been resized and had it's substitution variables filled in.

The SQL string can embed any of the standard C variable types (ie, "%d", "%s", etc) and it also provides a new variable type: "%q" that should be used for any string substitution which may have a single quotation mark. Single quotation marks are escaped (doubled) when substitution is performed on them.

The caller should free the string returned in the first parameter by calling alp_sal_string_destroy

Parameters:
[out] combined The resulting SQL statement with all variables substituted in.
[in] sql Any string (usually a SQL statement) that has substitution variables such as "%d", "%s" and the special "%q" described above
[in] varargs Host variables that will be substituted into the sql string.
See also:
SALStringDestroy
Returns:
alp_status_t

void alp_sal_string_destroy char *  s  ) 
 

Frees a string created by SALBuildString. On most platforms (except notably Windows) it should be safe to just call "free" instead of SALStringDestroy(), so this API may be depricated

Parameters:
[in] s String to free
See also:
SALBuildString

alp_status_t alp_sal_transaction_begin AlpSALHandle  sal,
char  exclusive
 

Executes "BEGIN TRANSACTION;" on the given Database.

Parameters:
[in] sal Database to execute against.
[in] exclusive flag indicating whether to use "BEGIN EXCLUSIVE TRANSACTION;"
Returns:
alp_status_t

alp_status_t alp_sal_transaction_commit AlpSALHandle  sal  ) 
 

Executes "COMMIT TRANSACTION;" on the given Database.

Parameters:
[in] sal Database to execute against.
Returns:
alp_status_t

alp_status_t alp_sal_transaction_rollback AlpSALHandle  sal  ) 
 

Executes "ROLLBACK TRANSACTION;" on the given Database.

Parameters:
[in] sal Database to execute against.
Returns:
alp_status_t


Generated on Sat Dec 16 20:29:50 2006 for hiker-0.9 by  doxygen 1.4.4