I get the point. Thanks for your quick reply!

- Andreas

Am Mittwoch, 6. November 2013 23:44:14 UTC+1 schrieb Cliff Kachinske:
>
> form.process does the insertion, so your call to update_or_insert is too 
> late.
>
> how about this?
> db.define_table('name' Field('name', unique=True, requires=IS_NOT_IN_DB(...
>
> Look in the "Forms and Validators" chapter of the online manual for the 
> correct syntax for IS_NOT_IN_DB.
> Look in the "Database Abstraction Layer" chapter for more information 
> about the arguments to Field.
>
> On Wednesday, November 6, 2013 5:20:33 PM UTC-5, Andreas Wienes wrote:
>>
>> I want to use update_or_insert to insert a value to my DB if it doesn't 
>> exist.
>>
>> def add_name():
>>     form = SQLFORM(db.name)
>>     if form.process().accepted:
>>         db.name.update_or_insert(db.name.name==request.vars.name, name=
>> request.vars.name)
>>     return dict(form=form)
>>
>>
>> But it won't work. Names are also added to the DB, even if they already 
>> there. 
>>
>> Thanks for your help!
>>
>> - Andreas
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to