android - Atomically update multiple related tables -
i working sqlite in android. have model object contains 3 lists, 1 of list of lists. have 5 tables: object, b list of lists, c lists, , d , e other 2 lists. case has me stumped if user updating existing object, , may or may not have made changes lists. think have query each table b through e records foreign keys match primary key of record i'm updating, , loop through results see if have matching item in lists, manually deleting/inserting/updating necessary. seems me there should better way?
related questions: if wrap whole operation in begintransaction()
, settransactionsuccessful()
, need else ensure atomicity? have never dealt directly locks in databases, need add error checking existing queries handle event in blocked? there error case in need manually cancel transaction, or occur automatically when close database connection?
have on sqlite triggers here, need.
if error has occurred somewhere after begintransaction()
, try catch exception , not mark transaction successful. without settransactionsuccessful()
call data wont affected.
Comments
Post a Comment