On Mar 16, 2010, at 10:20:31 AM, Rick Genter wrote: >> From: Gabriele Kahlout [mailto:[email protected]] >> Sent: Tuesday, March 16, 2010 12:26 AM >> To: Derby Discussion >> Subject: Re: how to cascade on update? Not possible? >> >> Okay, and how do you recommend I work around it? >> I should retrieve the effected tuples (the referencing) and store >> their values (onto the stack/heap) and then delete the records (since >> the referencing fields are primary keys), and then finally updated the >> referred to tuples, and then re-insert the data into the referencing >> table, with the appropriate modification. >> Unfortunately violation checking is done after each statement, and may >> not be deffered. > > When I've had to do something like this in the past, I do it in three steps: > > 1) Insert the new value to be referenced in the referenced table. > 2) Update the referencing records in the referencing table(s) to use the new > value. > 3) Delete the old value that was referenced from the referenced table. > > I do this in a single transaction so that logical data integrity is > maintained. > > -- > Rick Genter > Principal Software Engineer > Silverlink Communications >
This is probably a better way than my trigger "hack" :-)
