[lug] (OT) postgresql

j davis davis_compz at hotmail.com
Sun Nov 10 16:11:46 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/


thanks...im a sql newbie...so i tried the max query against my inventory 
numbers..
it worked...and brought something to my attention...lol

it appares as if 65 is bigger that 165 to sql so I changed 65 to 00065...now
its smaller...is this normal.

thanks again,
jd

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail




More information about the LUG mailing list