It will be faster if the update is performed on the set (without selecting each one):
db(db.products.id>0).update(product_code=db.products.product_code[:2]) You can do _update to see what SQL will be generated. On Mar 16, 6:12 am, selecta <[email protected]> wrote: > for p in db(db.products.id>0).select(): > p.update(product_name = 'Tiger Woods') > > or > > [p.update(product_name = 'Tiger Woods') for p in > db(db.products.id>0).select()] > > On Mar 16, 12:06 pm, Russell <[email protected]> wrote: > > > Hi, > > > I'm trying to update some text fields in a database. In SQL I would > > do something like this... > > > UPDATE products SET product_code=substr(product_code,2); > > > or even... > > > UPDATE products SET product_name = replace(product_name, 'Tiger', > > 'Woods'); > > > Does anyone have an example of how to do this with the DAL? > > > Thanks > > Russell > > -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.

