hey, thanks für ur fast reply (: Still cant make it work though.. I guess for the first version i need to convert rows to int somehow, as the MAX_id function does not return a single integer :/. Always get this error:
TypeError: int() argument must be a string or a number, not 'Rows' After failing dramatically trying to convert it myself, i trief the second version. Unluckily with some other errors i cant quite figure out :/ AttributeError: 'Query' object has no attribute 'update' ok, thought there might be some braces wrong, but it still gave me similar errors only that 'Query' was replaced by 'Expression' or other stuff :/. Sry for being such a pain, im really not good at this. On 28 Mai, 17:23, Massimo Di Pierro <[email protected]> wrote: > max_id = db(db.table).select(db.table.id.max()) > and > db(db.table.id==max_id).update(field='avariable') > > or > > db(db.table.id.belongs(db(db.table)._select(db.table.id.max())).update(field='avariable') > > but you should not count on id being sequential. That is not true on > GAE and it is not true for other NoSQL which we partially support. You > should use a datetime timestemp. > > On May 28, 3:22 am, Blackpainter <[email protected]> wrote: > > > Hi all, > > > im pretty new to web2py and encountered a little problem. > > i need to find the highest ID in my table ( which through other > > threads i > > already accomplished) and update another field in this entry with an > > variable. > > (db.table.insert(field=db.table.field.store(request.body,'picture.jpg')) > > > i started with: > > db.executesql(""" UPDATE table SET field='*variable*' WHERE id=(SELECT > > MAX(id) FROM table)""") > > > but kinda reached a dead end as its probably not possible to include > > my > > variable in the executesql command. > > The Variable comes from a flash application, which takes a webcam foto > > and > > accesses a function in web2py. > > plz, help, cant help myself :/ > > > Your newbie, > > Blackpainter > >

