Ed, thanks for pointing out the 2 things to me. But these are on purpose as explained under.
> First, you have a column 'wrmstnm' that is marked as NOT NULL, but with no > default value. When you try to associate a value to the mdlmst record, if > that value isn't found, the >record is added. Unless the field you are using to associate is 'wrmstnm', >there will be no value, and the insert will fail. In case a user does not specify a value for 'wrmstnm', and suppose that form-level validation is also deceived or bye-passed somehow. Then, if the database will insert 'default value' and silently save the record, without any error (which is, in some casaes, undesirable). That's why it is is marked as NOT NULL, but with no default value. Sothat the DB will raise error. >Probably the bigger problem is that you are associating PKs, rather than >actual values. This is never a good idea; PKs should be used by the database >to identify records, but not by >humans. Think of it this way: you don't want >to associate the warranty with PK=2 with the model with PK=1; instead, you >want to associate the "30-day" warranty with the >"Basic" model. To the users, the pkids will not be shown, but the names will be shown on form / report. It is very natural to use pkid to link parent & child tables. Some of the reasons are-- i) There can be duplicate names. But pkids will be unique. ii) Maintainability: Suppose a name of warranty (wrmstnm) is changed in master (wrmst) (maybe to correct a typo) If pkid of that table is referenced in child table, then nothing else needs to be changed in earlier transaction tables. >To do that, you'd call: >mdlBizObj.mmAddToBoth(wrBizObj, "mdlmstnm", "Basic", "wrmstnm", "30-Day") > If either of those values do not exist in their respective tables, they will > be added, and the association created. In my code, mdlBizObj.mmAddToBoth(wrBizObj,"mdlmstid", '1', "wrmstid", '1') fails. Traceback (most recent call last): File "<interactive input>", line 1, in <module> File "f:\py\dabovmd\bo3.py", line 117, in <module> mdlBizObj.mmAddToBoth(wrBizObj,"mdlmstid", '1', "wrmstid", '1') File "f:\py\dabo\biz\dBizobj.py", line 2164, in mmAddToBoth return assoc["cursor"].mmAddToBoth(thisField, thisVal, otherField, otherVal) File "f:\py\dabo\db\dCursorMixin.py", line 1274, in mmAddToBoth aux.execute(sql, (thisPK, otherPK)) File "f:\py\dabo\db\dCursorMixin.py", line 386, in execute raise dException.DBQueryException(errMsg) DBQueryException: (1048, "Column 'wrmstid' cannot be null") >Does that make it clearer? Whether my code is failing because I am using pkids for M:M association? If not, can you pl. try associating pkids at your end? Thanks again. -- Vineet --- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html --- _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/[email protected]
