Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/10/2016 in all areas

  1. This schema seems to work (I did a 10-element buffer instead of 1000): CREATE TABLE Buffer (Value); CREATE TABLE BufferIndex (I); CREATE TRIGGER BufferIncr BEFORE INSERT ON Buffer FOR EACH ROW BEGIN UPDATE BufferIndex SET I = ((SELECT I from BufferIndex)+1)%10; END; INSERT INTO BufferIndex (I) VALUES (-1) -- Initial index is -1 Then insert data (the current time in this example) into the buffer with: INSERT OR REPLACE INTO Buffer (rowID, Value) Values ((SELECT I FROM BufferIndex),time('now')) The Trigger serves to increment the index before the INSERT. To get the ordered elements one can use a View: CREATE VIEW OrderedBuffer AS SELECT Value FROM Buffer,BufferIndex WHERE Buffer.rowID>I UNION ALL SELECT Value FROM Buffer,BufferIndex WHERE Buffer.rowID<=I;
    1 point
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.