Received: from s20.highertech.net (root@s20.highertech.net [209.54.120.20]) by hub.org (8.9.3/8.9.3) with ESMTP id KAA45761 for ; Fri, 30 Apr 1999 10:28:59 -0400 (EDT) (envelope-from jt-kirkpatrick@mpsllc.com) Received: from kirkpatrickjt (whiteoak-34.highertech.net [209.140.56.34] (may be forged)) by s20.highertech.net (8.8.6/8.8.6) with SMTP id KAA04855 for ; Fri, 30 Apr 1999 10:28:12 -0400 Received: by localhost with Microsoft MAPI; Fri, 30 Apr 1999 10:31:06 -0400 Message-ID: <01BE92F4.8E44C660.jt-kirkpatrick@mpsllc.com> From: JT Kirkpatrick To: "'pgsql-sql@hub.org'" Subject: finding the most recent records Date: Fri, 30 Apr 1999 10:31:06 -0400 Organization: MPS, LLC X-Mailer: Microsoft Internet E-mail/MAPI - 8.0.0.4211 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit I didn't find who originally asked how to do this, but it IS possible to identify the most recent if you have a field in the table defined as "field1 datetime not null default text 'now'". you'll only run into a problem if more than one record is inserted AT THE EXACT SAME SECOND -- but postgres will just put the same timestamp in there (don't define the field as unique). I am putting this field (along with one that defaults to current_user) in ALL my tables for our application. the values are input "behind the scenes" by default whenever anyone adds a record, and it gives me a simple little audit trail. for instance, when that deceptive employee creates a "vendor" for himself and then creates a false purchase order and receipt thereby setting in motion a payment due to himself, i can see by whom and when the records were created. hopefully i have other controls in place to prevent this from happening, but the point is that the timestamp works fine and can help you identify the most recent records! jt