sqlite3_wrapper.h

Go to the documentation of this file.
00001 #ifndef __SQLITE3_WRAPPER_H__
00002 #define __SQLITE3_WRAPPER_H__
00003 
00004 /**
00005  * File Name  : sqlite3_wrapper.h
00006  *
00007  * Description: Wrapper layer around the sqlite3 C API
00008  */
00009 
00010 /*
00011  * This file is part of libermetadb.
00012  *
00013  * libermetadb is free software: you can redistribute it and/or modify
00014  * it under the terms of the GNU General Public License as published by
00015  * the Free Software Foundation, either version 2 of the License, or
00016  * (at your option) any later version.
00017  *
00018  * libermetadb is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License
00024  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00025  */
00026 
00027 /**
00028  * Copyright (C) 2008 iRex Technologies B.V.
00029  * All rights reserved.
00030  */
00031 
00032 
00033 //----------------------------------------------------------------------------
00034 // Include Files
00035 //----------------------------------------------------------------------------
00036 
00037 #include <glib.h>
00038 
00039 #include "ermetadb.h"
00040 #include "metadata_table.h"
00041 
00042 G_BEGIN_DECLS
00043 
00044 /**---------------------------------------------------------------------------
00045  *
00046  * Name :  sql3_execute_query
00047  *
00048  * @brief  Execute sql query.
00049  *         A convenience wrapper around sql3_prepare_statements(), sql3_execute_statements(),
00050  *         sql3_finalize_statements() for queries that have no parameters.
00051  *
00052  * @param  [in]  db - sqlite database object
00053  * @param  [in]  sql - SQL statement(s) as text
00054  * @param  [in]  parameters - metadata_table with parameters (value), or NULL
00055  *                            table must have exactly one row
00056  * @param  [in]  result_table - location to store metadata_table holding query results,
00057  *                              or NULL when caller is not interested in query results
00058  * @param  [out] result_table - metadata_table holding query results, or NULL when no results
00059  *                              First row holds column names and cell values,
00060  *                              other rows hold cell values only.
00061  *
00062  * @return ER_OK or error code
00063  *
00064  *--------------------------------------------------------------------------*/
00065 int sql3_execute_query (       sqlite3        *db,
00066                          const char           *sql,
00067                          const metadata_table *parameters,
00068                                metadata_table **result_table );
00069 
00070 
00071 /**---------------------------------------------------------------------------
00072  *
00073  * Name :  sql3_begin_transaction
00074  *
00075  * @brief  Start a database transaction.
00076  *         Transactions may be nested, as long as the calls to sql3_begin_transaction() and
00077  *         sql3_begin_transaction_readonly() are balanced with calls to sql3_commit_or_rollback.
00078  *
00079  * @param  [in]  thiz - erMetadb object on which to start a transaction
00080  *
00081  * @return ER_OK or error
00082  *
00083  *--------------------------------------------------------------------------*/
00084 int sql3_begin_transaction (erMetadb thiz);
00085 
00086 
00087 /**---------------------------------------------------------------------------
00088  *
00089  * Name :  sql3_begin_transaction_readonly
00090  *
00091  * @brief  Start a read-only database transaction.
00092  *         Transactions may be nested, as long as the calls to sql3_begin_transaction() and
00093  *         sql3_begin_transaction_readonly() are balanced with calls to sql3_commit_or_rollback.
00094  *
00095  * @param  [in]  thiz - erMetadb object on which to start a transaction
00096  *
00097  * @return ER_OK or error
00098  *
00099  *--------------------------------------------------------------------------*/
00100 int sql3_begin_transaction_readonly (erMetadb thiz);
00101 
00102 
00103 /**---------------------------------------------------------------------------
00104  *
00105  * Name :  sql3_commit_or_rollback
00106  *
00107  * @brief  Commit or rollback a database transaction
00108  *         Transactions may be nested, as long as the calls to sql3_begin_transaction()
00109  *         are balanced with calls to sql3_commit_or_rollback.
00110  *         Superfluous calls to sql3_commit_or_rollback are allowed.
00111  *
00112  * @param  [in]  thiz - erMetadb object on which to end a transaction
00113  * @param  [in]  err - ER_OK or error code
00114  *
00115  * @return ER_OK or error
00116  *         or 'err' value when this is not ER_OK
00117  *
00118  *--------------------------------------------------------------------------*/
00119 int sql3_commit_or_rollback (erMetadb thiz, int err);
00120 
00121 
00122 /**---------------------------------------------------------------------------
00123  *
00124  * Name :  sql3_strcase_cmp
00125  *
00126  * @brief  Compare function to be used in custom collation sequence
00127  *         See documentation on sqlite3_create_collation() for details
00128  *
00129  *--------------------------------------------------------------------------*/
00130 int sql3_strcase_compare( void        *user_data,
00131                           int         left_len,
00132                           const void  *left_void,
00133                           int         right_len,
00134                           const void  *right_void );
00135 
00136 G_END_DECLS
00137 
00138 #endif // __SQLITE3_WRAPPER_H__
00139 
Generated by  doxygen 1.6.2-20100208