Gitte Wange wrote:
On 05 Apr 2001 09:57:14 -0500, Steve Drees wrote:
I need to do one thing if any rows is returned and another if there is no records in the database
http://zope.nipltd.com/public/lists/zope-archive.nsf/ByKey/BEBF9A98F9A59B3F
Thanx but it only helped a bit ... See he has the same problem as me - if need to do one thing if there are records returned and another if no records are returned.
Actually I need to add a new item to my database with one number higher than the item with the highest number, e.g. if there are an item in the database with number 2 then the new one must have number 3. And if there are no items then the new one must have number 1.
ANy good ideas ? The ones I got earlyer doesn't work
Gitt
That is probably best accomplished within the SQL code. Most databases provide facilities for this to prevent race conditions. For example, if you are using a sequence in postgreSQL, you can call functions like nextval() and currval() within your SQL to accomplish this. You could also use the max() SQL function to return the maximum field value and add one to it and insert it in the new record. In fact, most databases have a sequence or serial type that does this entirely automatically for you. Take a peek at you database documentation. -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>