// This file is under GNU General Public License 3.0
|
|
// see LICENSE.txt
|
|
|
|
// Copyleft (c) 2017, 2018, p≡p foundation
|
|
|
|
// Written by Volker Birk
|
|
|
|
|
|
// prepare SQL statement
|
|
|
|
function "init_sql" {
|
|
param "sql";
|
|
||
|
|
sqlite3_stmt *_sql;
|
|
int int_result = sqlite3_prepare_v2(session->db,
|
|
||
|
|
indent(2); copy '$sql';
|
|
||
|
|
, -1, &_sql, NULL);
|
|
assert(int_result == SQLITE_OK);
|
|
if (!(int_result == SQLITE_OK))
|
|
return PEP_UNKNOWN_ERROR;
|
|
|
|
||
|
|
}
|
|
|
|
// exec_sql_* is returning _result
|
|
|
|
function "exec_sql_int" {
|
|
param "sql";
|
|
call "init_sql" with "sql", "$sql";
|
|
||
|
|
int _result = 0;
|
|
int_result = sqlite3_step(_sql);
|
|
assert(int_result == SQLITE_ROW);
|
|
if (int_result == SQLITE_ROW)
|
|
_result = sqlite3_column_int(_sql, 0);
|
|
sqlite3_finalize(_sql);
|
|
if (int_result != SQLITE_ROW)
|
|
return PEP_UNKNOWN_ERROR;
|
|
|
|
||
|
|
}
|
|
|