@Test public void testDeferrable() throws SQLException { WbConnection conn = OracleTestUtil.getOracleConnection(); assertNotNull("No Oracle connection available", conn); OracleFKHandler fkHandler = new OracleFKHandler(conn); String create = "create table parent (id integer not null primary key);\n" + "create table child_deferred (id integer not null primary key, pid integer not null,\n" + " constraint fk_aaa foreign key (pid) references parent (id) deferrable initially deferred);\n" + "create table child_immediate (id integer not null primary key, pid integer not null,\n" + " constraint fk_bbb foreign key (pid) references parent (id) deferrable initially immediate);\n" + "create table child_not_deferred (id integer not null primary key, pid integer not null,\n" + " constraint fk_ccc foreign key (pid) references parent (id));\n"; TestUtil.executeScript(conn, create); TableIdentifier parent = conn.getMetadata().findTable(new TableIdentifier("PARENt")); DataStore fklist = fkHandler.getReferencedBy(parent); assertNotNull(fklist); assertEquals(3, fklist.getRowCount()); fklist.sortByColumn(0, true); // DataStorePrinter printer = new DataStorePrinter(fklist); // printer.printTo(System.out); String deferrable = fklist.getValueAsString(0, "DEFERRABLE"); assertEquals("INITIALLY DEFERRED", deferrable); deferrable = fklist.getValueAsString(1, "DEFERRABLE"); assertEquals("INITIALLY IMMEDIATE", deferrable); deferrable = fklist.getValueAsString(2, "DEFERRABLE"); assertEquals("NOT DEFERRABLE", deferrable); OracleTestUtil.cleanUpTestCase(); }
@AfterClass public static void tearDown() throws Exception { OracleTestUtil.cleanUpTestCase(); }