[lug] (OT) postgresql
Evelyn Mitchell
efm at tummy.com
Sun Nov 10 15:25:44 MST 2002
* On 2002-11-10 22:22 j davis <davis_compz at hotmail.com> wrote:
>
> Hello,
> is there a postgresql select query i can enter to specify
> the last row of a table...i.e. i want to make a new invoice number based
> on the inv_num field of the last customer entry into a table.the only thing
> i can think off is to run a loop on the data base using perl to increment
> a var + 1 for every row in the table...then use this var to get a query
> to the last row...hope this is coherent :)
If you have a increment count field, then I do:
select max(key) from table;
In the program I do:
newkey = cursor.key + 1
And in sql I do:
insert into table (key, entry) values (newkey, 'this is the entry);
--
Regards, tummy.com, ltd
Evelyn Mitchell Linux Consulting since 1995
efm at tummy.com Senior System and Network Administrators
http://www.tummy.com/
More information about the LUG
mailing list