From: | John R Pierce <pierce(at)hogranch(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Last inserted row id with complex PK |
Date: | 2014-01-09 07:22:54 |
Message-ID: | 52CE4E4E.8070502@hogranch.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 1/8/2014 10:14 AM, Nelson Green wrote:
>
>
> On Wed, Jan 8, 2014 at 4:54 PM, Nelson Green
> <nelsongreen84(at)gmail(dot)com <mailto:nelsongreen84(at)gmail(dot)com>> wrote:
> > I have a projects log table with a three column PK, project_num,
> person_num,
> > and sequence, where each new entry for a project/person combination
> > increments the sequence, which is not an auto incrementing
> sequence. Is
> > there any way to retrieve the last entry to the table? For
> instance, if the
> > last entry for person 427 on project 15 was sequence number 125,
> is that
> > information available to me anywhere?
>
> SELECT MAX(sequence) FROM project_log_table WHERE person_num=427 AND
> project_num=15
>
>
> Hi Francisco,
>
> My apologies, I was not completely clear. I will not know any of the
> columns in advance. The most recent insert is the result of user input
> from a web form, so I won't know what project or what user generated
> the last insert. That was why I wandered if that information was
> stored anywhere in the system.
wait, so you just want the latest record inserted with -any-
project/person ? add a timestamptz field to your table with default
current_timestamp;
--
john r pierce 37N 122W
somewhere on the middle of the left coast
From | Date | Subject | |
---|---|---|---|
Next Message | ambilalmca | 2014-01-09 07:26:42 | Re: How to know server status variable in postgresql? |
Previous Message | Sameer Kumar | 2014-01-09 07:19:09 | Re: How to know server status variable in postgresql? |