pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
To: 'pgsql-sql@hub.org' <pgsql-sql@hub.org>
Subject: finding the most recent records
Date: Fri, 30 Apr 1999 10:31:06 -0400
Message-ID: <01BE92F4.8E44C660.jt-kirkpatrick@mpsllc.com> (raw)

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



view thread (3+ messages)  latest in thread

Message-ID: <01BE92F4.8E44C660.jt-kirkpatrick@mpsllc.com>
Permalink:  ../01BE92F4.8E44C660.jt-kirkpatrick@mpsllc.com/
Also on:    postgresql.org/message-id/01BE92F4.8E44C660.jt-kirkpatrick@mpsllc.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: jt-kirkpatrick@mpsllc.com, pgsql-sql@hub.org
  Subject: Re: finding the most recent records
  In-Reply-To: <01BE92F4.8E44C660.jt-kirkpatrick@mpsllc.com>
  References: <01BE92F4.8E44C660.jt-kirkpatrick@mpsllc.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox