Thanks for the help Though, I am not quite clear on how to get the FIFO aspect of it.
Assuming three tables: task_log => (id, code, time_stamp) task_fifo = > (id, fk_task_log) task_status_log => (id, fk_task_incoming_log, status_code, time_stamp) How do I create the correct stored procedures / triggers to make this work? (Or, is this even the correct approach?) Thank you, :) ----- Original Message ---- > From: Christopher Taylor <mojoso...@gmail.com> > To: General Discussion of SQLite Database <sqlite-users@sqlite.org> > Sent: Monday, May 18, 2009 11:42:16 AM > Subject: Re: [sqlite] Sqlite as a FIFO buffer? > > I took a slightly different approach and used a trigger. This is the create > table function from my event log class. The string handler is proprietary > but other than that there should be enough there to give you an idea. > > void DbEventLog::CreateTable(sqlite3* pDatabase) > { > // create the table and insert the record > char* db_err; > CmnNarrowString createQuery = "create table tbl_EventLog ("; > createQuery += "m_key integer primary key autoincrement, "; > createQuery += "m_eventCode integer, "; > createQuery += "m_timestamp integer, "; > createQuery += ");"; > int rc = sqlite3_exec(pDatabase, createQuery.c_str(), NULL, 0, &db_err); > if ( rc != SQLITE_OK ) > { > // TODO - log error > } > else > { > // create the index on the unique id used for queries from ics > createQuery = "create index idx_EventLog on tbl_EventLog (m_key)"; > rc = sqlite3_exec(pDatabase, createQuery.c_str(), NULL, 0, &db_err); > if ( rc != SQLITE_OK ) > { > // TODO - log error > } > else > { > createQuery = "create trigger trg_EventLog after insert on > tbl_EventLog begin delete from tbl_EventLog where m_key <= (SELECT > max(m_key) FROM tbl_EventLog) - 4000; end;"; > rc = sqlite3_exec(pDatabase, createQuery.c_str(), NULL, 0, > &db_err); > if ( rc != SQLITE_OK ) > { > // TODO - log the error > } > } > } > } > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users