Received: from qw01.qwsecure.com (qw01.qwsecure.com [209.98.210.57]) by hub.org (8.9.3/8.9.3) with ESMTP id TAA72960 for ; Thu, 27 May 1999 19:12:22 -0400 (EDT) (envelope-from mwright@pro-ns.net) Received: from markw_compaq (204.124.82.48 [204.124.82.48]) by qw01.qwsecure.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2232.9) id LKQBV4BJ; Thu, 27 May 1999 18:34:14 -0500 Message-ID: <000901bea896$60addb80$c62812ac@markw_compaq> Reply-To: "Mark Wright" From: "Mark Wright" To: Subject: How do I implement FIFO? Date: Thu, 27 May 1999 18:12:17 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3110.5 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 I want to be able to have multiple clients pulling single, mutually exclusive records from a table in the same order that they were inserted into the table. Imagine one group of people placing objects on a conveyor belt, while at the other end another group of people are grabbing the first item to come off the belt. I think I know how to lay out the table: create table XYZ ( insert_seq_num serial, is_processed boolean default FALSE, some_data varchar(10) ); Inserts are obvious. What I'm stumped by is how to write a SELECT that will return the next available row in a way that two clients querying at the same time can't grab the same one. I think I can do it with temporary tables. I.e. select * into temp ABC from XYZ where is_processed = FALSE and insert_seq_num = (select MIN(insert_seq_num) from XYZ where is_processed = FALSE); update XYZ set XYZ.is_processed = TRUE where exists (select * from temp where ABC.insert_seq_num = XYZ.insert_seq_num); select * from temp; commit; But even if that would work, temp tables aren't supported in 6.4. Is there another way to do this without using temp tables? Mark --- Mark Wright mwright@pro-ns.net mark_wright@datacard.com