Since you mentioned
database
in your question I'll assume you want to store data into a table and fetch it in a FIFO manner. For that you can utilize the auto increment column feature that most databases posses. So when you insert a record into your table the next higher value will be assigned to that column. For the rest of this answer let's call this auto increment column
id
. If the last row from your table has been processed it will be deleted from you table. So the workflow will be as follows:
- Insert (a) record(s) into your table.
- Fetch records in a FIFO manner:
SELECT TOP 1 * FROM YourTable ORDER BY id ASC
- After processing of record is done delete the record in FIFO manner:
DELETE FROM YourTable WHERE id = (SELECT TOP 1 id FROM YourTable ORDER BY id ASC)
Cheers!
—MRB