On 9 September 2010 23:13, Rodrigo Quezada <rotarantino(at)gmail(dot)com> wrote:
> Hello,
> I need to get de last entry from a table. I try using:
> DECLARE variable CURSOR FOR SELECT id FROM table;
> FETCH LAST FROM variable;
> And works fine, but when i try to use this code in a procedure, appears the
> following message:
> ERROR: syntax error at or near "FETCH"
> LINE XX: FETCH LAST FROM raton;
> ^
> ********** Error **********
> Is there another way to get that last ID?
Try:
SELECT id FROM table ORDER BY id DESC LIMIT 1;
--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935