Access RESTRICT CONSTRAINT support
I had plenty of tables that needed conversion and I was growing tired of testing the migration process which requires a few steps before implimentation of the final product.
As such I added RESTRICT CONTRAINT support to the MS Access reverse engeneering. It's rather simple too...
Here's the investigation:
NO ACTION
33554435 = 10000000000000000000000011
RESTRICT
33554433 = 10000000000000000000000001
UPDATE CASCADE
33554689 = 10000000000000000100000001
DELETE CASCADE
33558529 = 10000000000001000000000001
CASCADE BOTH
16781569 = 1000000000001000100000001
MS Access doesn't really support NO ACTION on a specific trigger (though perhaps the Jet engine does?)
This confirms that if the second bit is set, then it's NO ACTION for both (as expected), otherwise the CASCADE option is handled properly, albeit as soon as you enable the "Enforce referential integrity" then NO ACTION is replaced with RESTRICT...
As such, here is the code I've tested (Note: I did NOT test "NO ACTION" tables, this should be done before implimenting anything albeit the code is simple is done):
if ((grbit & 2) != 0) {
foreignKey.setDeleteRule("NO ACTION");
foreignKey.setUpdateRule("NO ACTION");
} else {
if ((grbit & 256) != 0)
foreignKey.setUpdateRule("CASCADE");
else
foreignKey.setUpdateRule("RESTRICT");
if ((grbit & 4096) != 0)
foreignKey.setDeleteRule("CASCADE");
else
foreignKey.setDeleteRule("RESTRICT");
}
Hope this gets implimented in the next version, or otherwise helps someone else...
Edited 4 time(s). Last edit at 10/31/2005 11:47AM by Sebastien Caisse.
Subject
Written By
Posted
Access RESTRICT CONSTRAINT support
October 31, 2005 11:39AM
November 11, 2005 05:34AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.