FYI, I implented the code similar to how it is shown below and it seem to work just fine. The main difference is that I used the bizObj's connection for the begin/end and insert statements to try to ensure that everything was wrapped in the same connection/transaction.
Thanks, Larry -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Friday, August 17, 2007 11:07 AM To: 'Dabo Users list' Subject: [dabo-users] Transaction handling I need input on the best way to implement the following...i.e. put into a transaction I have records with 0 or more parent, grandparent, etc levels up and need to ensure that quantities are not exceeded (i.e. qtyfield1-qtyfield2>=0) If currentrecord qtyfield1-(qtyfield2 + qty)>=0 AND every parent, grandparent, etc qtyfield1-(qtyfield2 + qty)>=0, then update qtyfield2 with qtyfield2+qty at all levels. Would putting something like this in the bizObj.validateRecord be sufficient...? ret='' self.tmpCursor= conn.getDaboCursor() self.tmpCursor.execute('begin transaction') If self.updateqty2(pk,self.tmpCursor,qty): self.tmpCursor.execute('commit') else: self.tmpCursor.execute('rollback') ret='No can do' return(ret) def updateqty2(self,pk,tmpCursor,qty): tmpCursor.execute('select fk_parentid, qtyfield1-qtyfield2 as testqty from public.table where pkid=%s'%(pk,)) if tmpCursor.RowCount==0: return(True) ## no more parent levels else: ds=tmpCursor.getDataSet() ##is there a better way to get the field values? for parentrecord in ds: if parentrecord["testqty"]-qty>0 tmpCursor.execute('update public.table set qtyfield2=qtyfield2+%s where pkid=%s'%(qty,pk)) ##is this recursive call ok? return(self.updateqty2(parentrecord["fk_parentid"],tmpCursor,qty)) else: return(False) TIA, Larry Long No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.484 / Virus Database: 269.12.0/957 - Release Date: 08/16/2007 1:46 PM [excessive quoting removed by server] _______________________________________________ Post Messages to: Dabo-users@leafe.com 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/dabo-users/[EMAIL PROTECTED]