public void commit() { checkThread(); checkConnection(); if (inTransaction) { sqlite3_stmt statement = null; string tail = null; int rc = Sqlite3.sqlite3_prepare(this.db, "COMMIT", -1, ref statement, ref tail); if (rc != Sqlite3.SQLITE_OK) { throw GetSqliteError(this.db, null); } rc = Util.Step(statement); if (rc == Sqlite3.SQLITE_DONE) { this.inTransaction = false; } else { throw GetSqliteError(this.db, statement); } rc = Sqlite3.sqlite3_finalize(statement); if (rc != Sqlite3.SQLITE_OK) { GetSqliteError(this.db, null); } } }
internal void begin() { sqlite3_stmt statement = null; string tail = null; int rc = Sqlite3.sqlite3_prepare(this.db, this.begin_statement, -1, ref statement, ref tail); if (rc != Sqlite3.SQLITE_OK) { throw GetSqliteError(this.db, statement); } rc = Util.Step(statement); if (rc == Sqlite3.SQLITE_DONE) { this.inTransaction = true; } else { throw GetSqliteError(this.db, statement); } rc = Sqlite3.sqlite3_finalize(statement); if (rc != Sqlite3.SQLITE_OK) { GetSqliteError(this.db, null); } }
public void rollback() { checkThread(); checkConnection(); if (inTransaction) { doAllStatements(AllStatmentsAction.Reset); sqlite3_stmt statement = null; string tail = null; int rc = Sqlite3.sqlite3_prepare(this.db, "ROLLBACK", -1, ref statement, ref tail); if (rc != Sqlite3.SQLITE_OK) { throw GetSqliteError(this.db, null); } rc = Util.Step(statement); if (rc == Sqlite3.SQLITE_DONE) { this.inTransaction = false; } else { throw GetSqliteError(this.db, statement); } rc = Sqlite3.sqlite3_finalize(statement); if (rc != Sqlite3.SQLITE_OK) { GetSqliteError(this.db, null); } } }
public Cursor executescript(string operation) { connection.checkThread(); connection.checkConnection(); this.connection.commit(); sqlite3_stmt statement = null; string script = operation; bool statement_completed = false; while (true) { if (Sqlite3.sqlite3_complete(operation) == 0) { break; } statement_completed = true; int rc = Sqlite3.sqlite3_prepare(this.connection.db, operation, -1, ref statement, ref script); if (rc != Sqlite3.SQLITE_OK) { throw GetSqliteError(this.connection.db, null); } /* execute statement, and ignore results of SELECT statements */ rc = Sqlite3.SQLITE_ROW; while (rc == Sqlite3.SQLITE_ROW) { rc = Sqlite3.sqlite3_step(statement); } if (rc != Sqlite3.SQLITE_DONE) { Sqlite3.sqlite3_finalize(statement); throw GetSqliteError(this.connection.db, null); } rc = Sqlite3.sqlite3_finalize(statement); if (rc != Sqlite3.SQLITE_OK) { throw GetSqliteError(this.connection.db, null); } } if (!statement_completed) { throw MakeProgrammingError("you did not provide a complete SQL statement"); } return(this); }
public static int BindBlob(Sqlite3Statement stmt, int index, byte[] val, int n, IntPtr free) { #if USE_WP8_NATIVE_SQLITE return(Sqlite3.sqlite3_bind_blob(stmt, index, val, n)); #elif USE_SQLITEPCL_RAW return(Sqlite3.sqlite3_bind_blob(stmt, index, val)); #else return(Sqlite3.sqlite3_bind_blob(stmt, index, val, n, null)); #endif }
private Statement(Sqlite3.sqlite3 db, sqlite3_stmt stmt, string operation, string tail) { this.uniqueid = Guid.NewGuid(); this.db = db; this.sql = operation; this.st = stmt; this.Tail = tail; }
private Statement(Sqlite3.sqlite3 db, sqlite3_stmt stmt, string operation, string tail) { this.uniqueid = Guid.NewGuid(); this.db = db; this.sql = operation; this.st = stmt; this.Tail = tail; }
public static int BindText(Sqlite3Statement stmt, int index, string val, int n, IntPtr free) { #if USE_WP8_NATIVE_SQLITE return(Sqlite3.sqlite3_bind_text(stmt, index, val, n)); #elif USE_SQLITEPCL_RAW return(Sqlite3.sqlite3_bind_text(stmt, index, val)); #else return(Sqlite3.sqlite3_bind_text(stmt, index, val, n, null)); #endif }
public static int sqlite3_prepare( SqliteConnectionHandle connection, string sql, int sqlLength, out SqliteStatementHandle statement, out string remainingSql) { Community.CsharpSqlite.Sqlite3.Vdbe stmt = null; string remSql = null; var result = Community.CsharpSqlite.Sqlite3.sqlite3_prepare(connection.Handle, sql, sqlLength, ref stmt, ref remSql); statement = new SqliteStatementHandle(stmt); remainingSql = remSql; return(result); }
public int SqliteFinalize() { int rc = Sqlite3.SQLITE_OK; if (this.st != null) { rc = Sqlite3.sqlite3_finalize(this.st); this.st = null; } this.in_use = false; return(rc); }
private void Dispose(bool disposing) { if (Statement != NullStatement) { try { SQLite3.Finalize(Statement); } finally { Statement = NullStatement; Connection = null; } } }
public static Sqlite3Statement Prepare2(Sqlite3DatabaseHandle db, string query) { Sqlite3Statement stmt = default(Sqlite3Statement); #if USE_WP8_NATIVE_SQLITE || USE_SQLITEPCL_RAW var r = Sqlite3.sqlite3_prepare_v2(db, query, out stmt); #else stmt = new Sqlite3Statement(); var r = Sqlite3.sqlite3_prepare_v2(db, query, -1, ref stmt, 0); #endif if (r != 0) { throw SQLiteException.New((Result)r, GetErrmsg(db)); } return(stmt); }
internal int Recompile(CodeContext context, object parameters) { sqlite3_stmt new_st = null; string tail = null; int rc = Sqlite3.sqlite3_prepare(this.db, this.sql, -1, ref new_st, ref tail); if (rc == Sqlite3.SQLITE_OK) { Statement new_stmt = new Statement(this.st.db, new_st, this.sql, tail); new_stmt.BindParameters(context, parameters); Sqlite3.sqlite3_finalize(this.st); this.st = new_st; } return(rc); }
public Statement(PythonSQLite.Connection connection, string operation) { this.uniqueid = Guid.NewGuid(); this.db = connection.db; this.sql = operation; this.st = null; string tail = null; if(Sqlite3.sqlite3_prepare(this.db, this.sql, -1, ref this.st, ref tail) != Sqlite3.SQLITE_OK /*TODO: || too much sql */) { Sqlite3.sqlite3_finalize(st); this.st = null; throw PythonSQLite.GetSqliteError(this.db, null); } this.Tail = tail; }
void BindAll(Sqlite3Statement stmt) { int nextIdx = 1; foreach (var b in _bindings) { if (b.Name != null) { b.Index = SQLite3.BindParameterIndex(stmt, b.Name); } else { b.Index = nextIdx++; } BindParameter(stmt, b.Index, b.Value, _conn.StoreDateTimeAsTicks); } }
public Statement(PythonSQLite.Connection connection, string operation) { this.uniqueid = Guid.NewGuid(); this.db = connection.db; this.sql = operation; this.st = null; string tail = null; if (Sqlite3.sqlite3_prepare(this.db, this.sql, -1, ref this.st, ref tail) != Sqlite3.SQLITE_OK /*TODO: || too much sql */) { Sqlite3.sqlite3_finalize(st); this.st = null; throw PythonSQLite.GetSqliteError(this.db, null); } this.Tail = tail; }
public int ExecuteNonQuery(object[] source) { if (Connection.Trace) { Debug.WriteLine("Executing: " + CommandText); } var r = SQLite3.Result.OK; if (!Initialized) { Statement = Prepare(); Initialized = true; } //bind the values. if (source != null) { for (int i = 0; i < source.Length; i++) { SQLiteCommand.BindParameter(Statement, i + 1, source[i], Connection.StoreDateTimeAsTicks); } } r = SQLite3.Step(Statement); if (r == SQLite3.Result.Done) { int rowsAffected = SQLite3.Changes(Connection.Handle); SQLite3.Reset(Statement); return(rowsAffected); } else if (r == SQLite3.Result.Error) { string msg = SQLite3.GetErrmsg(Connection.Handle); SQLite3.Reset(Statement); throw SQLiteException.New(r, msg); } else { SQLite3.Reset(Statement); throw SQLiteException.New(r, r.ToString()); } }
public static byte[] ColumnByteArray(Sqlite3Statement stmt, int index) { return(ColumnBlob(stmt, index)); }
public static string ColumnString(Sqlite3Statement stmt, int index) { return(Sqlite3.sqlite3_column_text(stmt, index)); }
public static int ColumnBytes(Sqlite3Statement stmt, int index) { return(Sqlite3.sqlite3_column_bytes(stmt, index)); }
public static int BindDouble(Sqlite3Statement stmt, int index, double val) { return(Sqlite3.sqlite3_bind_double(stmt, index, val)); }
internal int Recompile(CodeContext context, object parameters) { sqlite3_stmt new_st = null; string tail = null; int rc = Sqlite3.sqlite3_prepare(this.db, this.sql, -1, ref new_st, ref tail); if(rc == Sqlite3.SQLITE_OK) { Statement new_stmt = new Statement(this.st.db, new_st, this.sql, tail); new_stmt.BindParameters(context, parameters); Sqlite3.sqlite3_finalize(this.st); this.st = new_st; } return rc; }
public static long ColumnInt64(Sqlite3Statement stmt, int index) { return(Sqlite3.sqlite3_column_int64(stmt, index)); }
public static int ColumnInt(Sqlite3Statement stmt, int index) { return(Sqlite3.sqlite3_column_int(stmt, index)); }
public static ColType ColumnType(Sqlite3Statement stmt, int index) { return((ColType)Sqlite3.sqlite3_column_type(stmt, index)); }
public static Result Finalize(Sqlite3Statement stmt) { return((Result)Sqlite3.sqlite3_finalize(stmt)); }
public BBSQLStatement() { stmt = null; sqlite = null; }
public static int BindParameterIndex(Sqlite3Statement stmt, string name) { return(Sqlite3.sqlite3_bind_parameter_index(stmt, name)); }
public static int BindNull(Sqlite3Statement stmt, int index) { return(Sqlite3.sqlite3_bind_null(stmt, index)); }
public static double ColumnDouble(Sqlite3Statement stmt, int index) { return(Sqlite3.sqlite3_column_double(stmt, index)); }
public int SqliteFinalize() { int rc = Sqlite3.SQLITE_OK; if(this.st != null) { rc = Sqlite3.sqlite3_finalize(this.st); this.st = null; } this.in_use = false; return rc; }
public static byte[] ColumnBlob(Sqlite3Statement stmt, int index) { return(Sqlite3.sqlite3_column_blob(stmt, index)); }
public static string ColumnName16(Sqlite3Statement stmt, int index) { return(Sqlite3.sqlite3_column_name(stmt, index)); }
public static int BindInt64(Sqlite3Statement stmt, int index, long val) { return(Sqlite3.sqlite3_bind_int64(stmt, index, val)); }
public static int ColumnCount(Sqlite3Statement stmt) { return(Sqlite3.sqlite3_column_count(stmt)); }
public void Dispose() { if( stmt != null ) { int ret = Community.CsharpSqlite.Sqlite3.sqlite3_finalize(stmt); stmt = null; } }