[Opensource] How do I update a primary key with DBObject.update() ?
Dcomeau at xenos.com
Dcomeau at xenos.com
Sat Mar 1 11:34:14 PST 2003
Hi all,
I'm trying to figure out how to update a key field in a DBObject without
deleting the record and then re-adding it with the new key. Basically I
need to take advantage of the underlying cascading updates for the databases
I'm using (I need my code to work with both Postgres and SQL Server 2k).
The only thread I could find on this was this one, which didn't get any
replies :(
http://mail.jcorporate.com/pipermail/opensource/2001-August/008922.html
Can this be done?
Here's a code sample that shows what I am currently trying to do:
// ....snip....
// Need to update a group
group.setField("GroupID", existingGroupId);
group.retrieve();
// Now update it
if (existingGroupId.equals(formGroupId) == false) {
// ??? Make sure this does cascades properly!
group.setField("GroupID", formGroupId);
}
group.setField("Rights", "0");
group.setField("SendFinals", "0");
group.setField("Comments", formComments );
group.setField("WebEmailSubject", formWebSubject );
group.setField("WebEmailBody", formWebBody );
group.setField("NotifyEmailSubject", formNotifySubject);
group.setField("NotifyEmailBody", formNotifyBody );
group.update();
response.add(new Output("Group successfully updated."));
// ...snip...
Thanks!
Dave
More information about the Opensource
mailing list