Re: selecting the last record from a table

From: Medi Montaseri <medi(dot)montaseri(at)intransa(dot)com>
To: Doug McNaught <doug(at)mcnaught(dot)org>
Cc: MT <mt(at)open2web(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: selecting the last record from a table
Date: 2002-11-19 19:24:53
Message-ID: 3DDA9005.4040900@intransa.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Actually when you insert into a table, PG gives allows you to fetch the
OID it just created...what
language are you using.....

Here is psql(1)'s session

Test1=> insert into test values ('something');
INSERT 36205 1
Test1=>

Doug McNaught wrote:

>MT <mt(at)open2web(dot)com> writes:
>
>
>
>>I have a script that inserts a record into a table and increments the
>>unique field using nextval('my_sequence'). My problem is once I have
>>inserted the record, I'd like to select this same record and display
>>it so that the user knows he has actually inserted the record. I'm
>>wondering if there's a bit of sql to select the last record.
>>
>>
>
>SELECT * FROM mytable WHERE my_unique_field = currval('my_sequence');
>
>-Doug
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: Have you searched our list archives?
>
>http://archives.postgresql.org
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dan Winslow 2002-11-19 19:30:46 Re: Update table with max occurance from another table
Previous Message Mike Beachy 2002-11-19 19:19:46 Re: Update table with max occurance from another table