include/hiker/sal.h File Reference

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sqlite3.h>
#include <hiker/types.h>
#include <hiker/sysclass.h>

Go to the source code of this file.

Other constants

#define ALP_SAL_UTF8_COLLATOR   "alp_sal_utf8_collator"
 The ALP_SAL_UTF8_COLLATOR does locale-sensitive UTF8 collation (aka sorting). You 'add' it to a SAL session by calling alp_sal_install_utf8_collator() after calling alp_sal_database_open(); you tell SAL to use it by adding "COLLATE " ALP_SAL_UTF8_COLLATOR to your SQL, after an "ORDER BY" clause.

Error Codes

#define ALP_STATUS_SAL_ABORT   (ALP_CLASS_SAL | 0x00170000)
#define ALP_STATUS_SAL_AUTH   (ALP_CLASS_SAL | 0x000D0000)
#define ALP_STATUS_SAL_BADPARAM   (ALP_CLASS_SAL | 0x00190000)
#define ALP_STATUS_SAL_BUSY   (ALP_CLASS_SAL | 0x00010000)
#define ALP_STATUS_SAL_CANTOPEN   (ALP_CLASS_SAL | 0x00090000)
#define ALP_STATUS_SAL_CONSTRAINT   (ALP_CLASS_SAL | 0x000B0000)
#define ALP_STATUS_SAL_CORRUPT   (ALP_CLASS_SAL | 0x00070000)
#define ALP_STATUS_SAL_DMLEXISTS   (ALP_CLASS_SAL | 0x001B0000)
#define ALP_STATUS_SAL_EMPTY   (ALP_CLASS_SAL | 0x00120000)
#define ALP_STATUS_SAL_ERROR   (ALP_CLASS_SAL | 0x000E0000)
#define ALP_STATUS_SAL_FULL   (ALP_CLASS_SAL | 0x00080000)
#define ALP_STATUS_SAL_INTERNAL   (ALP_CLASS_SAL | 0x00150000)
#define ALP_STATUS_SAL_INTERRUPT   (ALP_CLASS_SAL | 0x00050000)
#define ALP_STATUS_SAL_IOERR   (ALP_CLASS_SAL | 0x00060000)
#define ALP_STATUS_SAL_LOCKED   (ALP_CLASS_SAL | 0x00020000)
#define ALP_STATUS_SAL_MISMATCH   (ALP_CLASS_SAL | 0x000C0000)
#define ALP_STATUS_SAL_MISUSE   (ALP_CLASS_SAL | 0x000F0000)
#define ALP_STATUS_SAL_NO_VALUE   (ALP_CLASS_SAL | 0x001C0000)
#define ALP_STATUS_SAL_NOLFS   (ALP_CLASS_SAL | 0x00100000)
#define ALP_STATUS_SAL_NOMEM   (ALP_CLASS_SAL | 0x00030000)
#define ALP_STATUS_SAL_NORECORDS   (ALP_CLASS_SAL | 0x001A0000)
#define ALP_STATUS_SAL_NOTFOUND   (ALP_CLASS_SAL | 0x00140000)
#define ALP_STATUS_SAL_PERM   (ALP_CLASS_SAL | 0x00160000)
#define ALP_STATUS_SAL_PROTOCOL   (ALP_CLASS_SAL | 0x00110000)
#define ALP_STATUS_SAL_READONLY   (ALP_CLASS_SAL | 0x00040000)
#define ALP_STATUS_SAL_SCHEMA   (ALP_CLASS_SAL | 0x00130000)
#define ALP_STATUS_SAL_TOOBIG   (ALP_CLASS_SAL | 0x000A0000)
#define ALP_STATUS_SAL_UNKNOWN   (ALP_CLASS_SAL | 0x00180000)

Typedefs

typedef int(* AlpSalCollator )(void *user_data, int length1, const void *string1, int length2, const void *string2)
 A Sqlite3 collation function.
typedef void * AlpSALHandle
 An AlpSALHandle is an opaque pointer that must be passed around as a reference to a database opened with alp_sal_database_open().
typedef void * AlpSALStatement
 An AlpSALStatement is an opaque structure used to bind host variables to a sql statement to be prepared for execution, and ultimately passed to other alp_sal_statement_* calls.

Data Access Functions

alp_status_t alp_sal_changes (AlpSALHandle sal, uint32_t *nRows)
 Returns the number of database rows that where changed (or inserted or deleted) by the most recently executed INSERT, UPDATE, or DELETE statement.
alp_status_t alp_sal_database_close (AlpSALHandle sal)
 Close given database handle, sal.
alp_status_t alp_sal_database_create (const char *dbFileName, const char *schemaFileName)
 Create a database and initializes its schema.
alp_status_t alp_sal_database_open (AlpSALHandle *sal, const char *dbName)
 Open a given database and return handle for it.
alp_status_t alp_sal_execute_sql_script (AlpSALHandle sal, FILE *fd)
 Read in and execute SQL commands from the given file descriptor.
const char * alp_sal_get_error_message (AlpSALHandle sal)
 Return string describing the last error generated by database.
alp_status_t alp_sal_install_collator (AlpSALHandle sal, const char *collate_name, AlpSalCollator collate_function, void *user_data)
 'Add' an arbitrary UTF8 collator (sort function) to a SAL session. (Use it by adding "COLLATE " COLLATE_NAME to your SQL, after an "ORDER BY" clause.)
alp_status_t alp_sal_install_utf8_collator (AlpSALHandle sal)
 'Add' a standard, locale-sensitive UTF8 collator (sort function) to a SAL session. (Use it by adding "COLLATE " ALP_SAL_UTF8_COLLATOR to your SQL, after an "ORDER BY" clause.)
alp_status_t alp_sal_last_insert_rowid (AlpSALHandle sal, uint32_t *rowID)
 Return rowID used as the last auto-generated primary key created by an SQL INSERT statement.
alp_status_t alp_sal_set_timeout (AlpSALHandle sal, int ms)
 Set the SQLite busy timeout.
alp_status_t alp_sal_sql_execute (AlpSALHandle sal, const char *sql,...)
 Execute a sql command given in a string buffer with a variable list of host parameter arguments.
alp_status_t alp_sal_sql_get_value (AlpSALHandle sal, int32_t *value, const char *sql,...)
 Execute a given SQL statement and return the value of the first column of the first row.
alp_status_t alp_sal_string_build (char **combined, const char *sql,...)
 Create a SQL string build up from the first parameter and the resulting substitution of supplied variables.
void alp_sal_string_destroy (char *s)
 Free the string created by alp_sal_string_build().
alp_status_t alp_sal_transaction_begin (AlpSALHandle sal, char exclusive)
 Execute "BEGIN TRANSACTION;" on the given database.
alp_status_t alp_sal_transaction_commit (AlpSALHandle sal)
 Execute "COMMIT TRANSACTION;" on the given database.
alp_status_t alp_sal_transaction_rollback (AlpSALHandle sal)
 Execute "ROLLBACK TRANSACTION;" on the given database.

Statement Functions

alp_status_t alp_sal_statement_destroy (AlpSALStatement *stmt)
 Destroys the AlpSALStatement stmt.
alp_status_t alp_sal_statement_execute (AlpSALStatement *stmt)
 Executes a AlpSALStatement that has been initalized with alp_sal_statement_initialize and which has had host parameters required by its SQL statement using AlpSALStatementSet commands.
void * alp_sal_statement_get_blob (AlpSALStatement *stmt, int pos, int32_t *size, bool copy)
 Retrieves blob value and size from the pos column of the current result set of the specified statement, stmt.
float alp_sal_statement_get_float (AlpSALStatement *stmt, int pos)
 Retrieve float value from the pos column of the current result set of the specified statement, stmt.
AlpSALHandle alp_sal_statement_get_handle (AlpSALStatement *stmt)
 Returns the AlpSALHandle bound to the statement, or NULL, if the stmt handle is invalid.
int32_t alp_sal_statement_get_int (AlpSALStatement *stmt, int pos)
 Retrieve integer value from the pos column of the current result set of the specified statement, stmt.
int64_t alp_sal_statement_get_int64 (AlpSALStatement *stmt, int pos)
 Retrieve 64 bit integer value from the pos column of the current result set of the specified statement, stmt.
char * alp_sal_statement_get_text (AlpSALStatement *stmt, int pos, bool copy)
 Retrieve text value from pos column of the current result set of the specified statement, stmt.
alp_status_t alp_sal_statement_initialize (AlpSALHandle sal, AlpSALStatement **stmt, const char *sql)
 Mallocs and initializes a AlpSALStatement pointed to by the AlpSALStatement handle parameter.
bool alp_sal_statement_is_null (AlpSALStatement *stmt, int pos)
 Check for NULL value in column of current result in stmt.
alp_status_t alp_sal_statement_next_result (AlpSALStatement *stmt)
 Get next result set of the specified statement, stmt.
alp_status_t alp_sal_statement_reset (AlpSALStatement *stmt)
 Reset a SQL query for specified statement, stmt, so it may be re-executed.
alp_status_t alp_sal_statement_set_blob (AlpSALStatement *stmt, int16_t pos, void *blob, int32_t size, bool copy)
 Bind a host blob variable to the specified position in the statement.
alp_status_t alp_sal_statement_set_float (AlpSALStatement *stmt, int16_t pos, float f)
 Bind a host float variable to the specified position in the statement.
alp_status_t alp_sal_statement_set_int (AlpSALStatement *stmt, int16_t pos, int32_t n)
 Bind a host integer variable to the specified position in statement.
alp_status_t alp_sal_statement_set_int64 (AlpSALStatement *stmt, int16_t pos, int64_t n)
 Bind a 64 bit host integer to the specified position in the statement.
alp_status_t alp_sal_statement_set_null (AlpSALStatement *stmt, int16_t pos)
 Bind a null to the specified position in the statement.
alp_status_t alp_sal_statement_set_text (AlpSALStatement *stmt, int16_t pos, const char *s, bool copy)
 Bind a host text variable to the specified position in the statement.

Defines

#define HIKER_SAL_H_   1


Define Documentation

#define HIKER_SAL_H_   1
 


Generated on Wed Jul 30 07:06:40 2008 by Doxygen 1.4.6 for ALP SDK + Hiker Documentation

Copyright © 1999-2008 ACCESS CO., LTD. All rights reserved.