>Sean Wrote ===
>I'm considering using SQLLite for an embedded project. Some of the
data I'd like to store is timestamped sensor readings. I'd like to know
if there is a way to >configure a table so that it acts like a fixed
length FIFO queue, e.g. stores 10,000 records then once full drops off
the oldest record each time a new one is inserted.
.>Can anyone tell me if we can do that with SQLLite?
=====
You could use a simple trigger (example for queue of size 10000 below)
and a self-incrementing key column:
create table myqueue (limit_id integer not null primary key, myvalue
integer) ;
create trigger queue_limit after insert on myqueue
begin
update myqueue set limit_id = limit_id-1 where (select
max(limit_id) from myqueue ) > 10000;
delete from myqueue where limit_id <=0 ;
end ;
INSERT TO MYQUEUE:
insert into myqueue (myvalue) values (1) ;
insert into myqueue (myvalue) values(2) ;
......
insert into myqueue (myvalue) values (10050) ;
RESULTS:
limit_id myvalue
1 51
2 52
.....
10000 10050
Note: Its not very efficient.
Regards,
Eli
***********************************************************************************
This email message and any attachments thereto are intended only for use by the
addressee(s) named above, and may contain legally privileged and/or
confidential information. If the reader of this message is not the intended
recipient, or the employee or agent responsible to deliver it to the intended
recipient, you are hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited. If you have received this
communication in error, please immediately notify the [EMAIL PROTECTED] and
destroy the original message.
***********************************************************************************