I think a bit more of your code controller would be required to understand
what's going on...

Richard

On Mon, Feb 13, 2012 at 4:29 PM, Bruce Wade <bruce.w...@gmail.com> wrote:

> Hi,
>
> db.define_table('cash_journal',
>     Field('transaction_type'),
>     Field('distributor_id', 'integer'),
>     Field('happen_time', 'datetime', default=request.now),
>     Field('happen_amount', 'decimal(10,2)'),
>     Field('ucash_before', 'decimal(10,2)'),
>     Field('ucash_after', 'decimal(10,2)'),
>     Field('transaction_id', 'integer', default=None),
>     Field('operator_id', 'integer', default=0)
> )
>
> Calling:
>
>            db.cash_journal.insert(
>                 transaction_type = UCashChangeType.buy_product,
>                 distributor_id = distributor.id,
>                 happen_amount = -int(payment_amount),
>                 ucash_before = ucash_before,
>                 ucash_after = ucash_after,
>                 transaction_id = payment,
>                 operator_id = distributor.id
>             )
>
> Gave me:
> Traceback (most recent call last):
>
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/restricted.py", 
> line 204, in restricted
>
>     exec ccode in environment
>
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/welcome/controllers/products.py"
>  <http://127.0.0.1:8000/admin/edit/welcome/controllers/products.py>, line 
> 565, in <module>
>
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/globals.py", 
> line 172, in <lambda>
>
>     self._caller = lambda f: f()
>
>   File 
> "/home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/welcome/controllers/products.py"
>  <http://127.0.0.1:8000/admin/edit/welcome/controllers/products.py>, line 
> 229, in payment
>
>     operator_id = distributor.id
>
>   File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/dal.py", 
> line 5597, in insert
>
>     return self._db._adapter.insert(self,self._listify(fields))
>
>   File "/home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/dal.py", 
> line 914, in insert
>
>     raise e
>
> IntegrityError: duplicate key value violates unique constraint 
> "cash_journal_pkey"
> DETAIL:  Key (id)=(1) already exists.
>
>
> Any reason why insert wouldn't just give you a new ID for primary key?
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>

Reply via email to