Пример #1
0
 void ExecSql(string statement, string table, bool isCreate)
 {
     if (NumberOfThreads > 1)
     {
         Monitor.Enter(Locker);
         try
         {
             if (isCreate)
             {
                 tables.Add(table);
             }
             Sqlite3.sqlite3_exec(pDb, statement, 0, 0, 0);
             rc = Sqlite3.sqlite3_errcode(pDb);
             //Monitor.Pulse(Locker);
         }
         finally
         {
             Monitor.Exit(Locker);
             //Debug.Print(String.Format("Section {0} Thread {1} released Locker", table, Thread.CurrentThread.ManagedThreadId));
         }
     }
     else
     {
         if (isCreate)
         {
             tables.Add(table);
         }
         Sqlite3.sqlite3_exec(pDb, statement, 0, 0, 0);
         rc = Sqlite3.sqlite3_errcode(pDb);
     }
 }
Пример #2
0
        public void DiskMerge()
        {
            string strQueryFront = "ATTACH database '" + dbToMergeWith + "' AS disk;";

            Sqlite3.sqlite3_exec(pDb, strQueryFront, 0, 0, 0);
            rc = Sqlite3.sqlite3_errcode(pDb);
            if (rc == 0)
            {
                foreach (string table in tables)
                {
                    Sqlite3.sqlite3_exec(pDb, "CREATE TABLE disk." + table + " AS SELECT * FROM " + table + ";", 0, 0, 0);
                    rc = Sqlite3.sqlite3_errcode(pDb);
                    if (rc != 0)
                    {
                        Sqlite3.sqlite3_close(pDb);
                        return;
                    }
                }
                rc = Sqlite3.exec(pDb, "DETACH disk;", 0, 0, 0);
            }
            Sqlite3.sqlite3_close(pDb);
        }