In the book it says


"And you can update all records in a set by passing named arguments 
corresponding to the fields that need to be updated:

update

1.

>>> db(db.person.id > 3).update(name='Ken')

Expressions

The value assigned an update statement can be an expression. For example 
consider this model

1.
2.
3.
4.
5.

>>> db.define_table('person',
        Field('name'),
        Field('visits', 'integer', default=0))
>>> db(db.person.name == 'Massimo').update(
        visits = db.person.visits + 1)


"

*def update():
    db(db.clubs).update(postcode=db.clubs.postcode)*

*
*

*Where postcode is simply **Field('postcode') and already has a value.*

*
*

*I am doing this because I want a 'compute' field that uses the postcode to 
calculate*

*
*

*What I find is that postcode does not get updated to the value it already 
contains, but gets updated to 'clubs.postcode'.*

*This does not seem consistent with the book.*

*I know I could do a loop and update_record, but this seems to do a commit on 
each update_record, and therefore take a lot longer than*

*if I can do it in one update.*

*
*

*
*

*Peter*

*
*

*
*

* 

*


Reply via email to