Re: [GENERAL] Re: [INTERFACES] the last row in a table

From: Stuart Rison <stuart(at)ludwig(dot)ucl(dot)ac(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] Re: [INTERFACES] the last row in a table
Date: 1999-03-10 11:38:39
Message-ID: v04003a00b30c0982939e@[128.40.242.190]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-interfaces

>On Tue, 9 Mar 1999, Marcin Grondecki wrote:
>
># There is better answer, i think. Simply read smth about cursors -
># declaring, using, droping. I think this is what u need. In case of
># troubles with understanding, i'd serve with some examples in Perl.
>
> If it's the exact last input row you want, a trigger or rule would
>be still yet better. :)

Or another possibility (again, if it's the last inputed row you want) is

SELECT * FROM <table> WHERE oid=( SELECT max(oid::float) FROM <table> );

I'm assuming here that the largest the oid the latest it was put in...
that's right isn't it (he said, all of a sudden hesitant).

Also, I could only get this to work by typecasting oid as float. Anybody
know why?

Regards,

Stuart.

+-------------------------+--------------------------------------+
| Stuart Rison | Ludwig Institute for Cancer Research |
+-------------------------+ 91 Riding House Street |
| Tel. (0171) 878 4041 | London, W1P 8BT, UNITED KINGDOM. |
| Fax. (0171) 878 4040 | stuart(at)ludwig(dot)ucl(dot)ac(dot)uk |
+-------------------------+--------------------------------------+

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Maerten Gaetan 1999-03-10 13:45:48
Previous Message Gilles Darold 1999-03-10 09:16:35 Re: [GENERAL] Postgres tutorial examples !

Browse pgsql-interfaces by date

  From Date Subject
Next Message James Olin Oden 1999-03-10 13:17:30 Re: [INTERFACES] Retrieve rows 1 by 1
Previous Message Oleg Broytmann 1999-03-10 08:42:06 Re: [GENERAL] the last row in a table