On Thu, Jul 14, 2011 at 06:00:38AM -0700, Hummingbird wrote: > Table names (field names) are are under-- > > customer (custid, custname, groupid), > custdetl (custid, address, tel, mobile, city) > group (groupid, groupname) > > There is a single form for handling tables "customer" and "custdetl". > Consider that a user wants to edit customer details in this form. > > He changes groupid, > deletes phone number, > changes address, > adds city (earlier, it was left blank by user). > > In effect, "customer" table should receive an update statement, > "custdetl" table should receive delete, update & insert statements.
This is the part I have trouble keeping up. Why should it need one DELETE, one UPDATE and one INSERT? All of that can be done with one single UPDATE statement in terms of UPDATE custdetl SET tel = NULL, address = <new address>, CITY = <new city> WHERE custid = <some ID>; Why on earth would you delete a row and then insert a row again? By issuing a DELETE you don't clear the value of a single column, you remove entire rows from the table. Same with INSERT. So either you just use one single UPDATE (which is perfectly fine with Django and if you use a ModelForm it is as easy as calling my_form.save()) or we're not talking about three tables with columns as you described but something much more complicated. Michal
signature.asc
Description: Digital signature