Hello everybody.
I ask you because I can’t make queries in my database with the DAL as I
wish.
Here my context. I have two tables like this:
db.define_table(‘spare_parts’,
Field('name',…),
Field(‘best_price’,…)
Field(‘best_delay’,…)
db.define_table(‘supplier_choice’,
Field(‘parts’,…) #reference to spare parts id from table ‘spare_parts’
Field(‘supplier’,…),
Field(‘price’, 'decimal(10,2)' ,…),
Field(‘Delay’, 'integer' ,…),
In the ‘spare_parts’ table I define all my spare parts individually. There
are normally no duplicates.
In the ‘supplier_choice’ table I define a ‘supplier’, a ‘price’ and a
‘delay’ for each ‘parts’. But I can create as many lines as I want to
define as many ‘suppliers’ ‘price’ or ‘delay’ for the same ‘part’.
What I want to do is a function which, for each id of the field 'parts' of
'supplier_choice', select all the lines with this id and find the
‘supplier’ with the lowest ‘price’ and the ‘supplier’ who has the shortest
‘delay’. Then, the idea is to update the 'best_price' field of the
'spare_parts' table with the name of the best price 'supplier' just find
before and in the same way update the ‘best_delay’.
It's been 2 weeks since I try lots of things but all I managed to do is
create bugs.
If anyone could help me do this, it would be fantastic !!
Thanks in advance.
Arthur
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.