I am not sure I fully understand.

You can do this:

id = db.sales.insert(invoice=invoice)
old_invoice = db.sales[id].invoice
new_invoice = old_invoice
db(db.sales.id==id).update(invoice=new_invoice)

Does this answer your question?


On Friday, 18 January 2013 15:36:30 UTC-6, greaneym wrote:
>
> Hello,
>
> I am working on a shopping cart, using the stable version of web2py, with 
> an
> sql lite database.
>
> In a checkout function, the order information is being inserted into a 
> sales db,(for example it has db.sales[id] == 2
>
> then in a buy function, after a user enters their card information in 
> order to buy the item,
> I want to insert an invoice number.
> I haven't used dbcommit().
>
> If I use db.sales.insert(invoice=invoice), this creates a new record, 
> db.sales[id] == 3 , with just the invoice number in it. I get an error if I 
> try db.sales.append(invoice=invoice).
>
> I see in the book that it's possible to try an update with
> something like this:
> db.sales[id]=dict(invoice=invoice)
>
> but if I try that literal example it is still creating a new record and 
> not updating the current session sales id record.
>
> How do I select the id of the current user's record and then use this
> update example as shown in the book to insert an invoice number into the 
> db.sales record that has been recently created? or how do I append
> a update to a record?
>
> Do I use rollback or something else?  Thanks for suggesions.
>
>
>
> Margaret
>
>

-- 



Reply via email to