diff --git a/core/src/test/java/com/alibaba/druid/bvt/sql/oracle/create/OracleCreateProcedureTest1.java b/core/src/test/java/com/alibaba/druid/bvt/sql/oracle/create/OracleCreateProcedureTest1.java index 11dac24455..4456bc8c46 100644 --- a/core/src/test/java/com/alibaba/druid/bvt/sql/oracle/create/OracleCreateProcedureTest1.java +++ b/core/src/test/java/com/alibaba/druid/bvt/sql/oracle/create/OracleCreateProcedureTest1.java @@ -64,14 +64,60 @@ public void test_0() throws Exception { System.out.println("orderBy : " + visitor.getOrderByColumns()); Assert.assertEquals(1, visitor.getTables().size()); + Assert.assertEquals(1, visitor.getColumns().size()); + Assert.assertEquals(1, visitor.getConditions().size()); + Assert.assertEquals(0, visitor.getRelationships().size()); + Assert.assertEquals(1, visitor.getTables().size()); Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("dept_temp"))); + Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("dept_temp", "department_id"))); + } + + public void test_1() throws Exception { + String sql = "CREATE OR REPLACE PROCEDURE p (" + + " dept_no NUMBER" + + ") AS " + + "BEGIN" + + " DELETE FROM dept_temp" + + " WHERE department_id = dept_no;" + + " " + + " IF SQL%NOTFOUND THEN" + + " DBMS_OUTPUT.PUT_LINE (" + + " 'No department number');" + + " ELSE" + + " DBMS_OUTPUT.PUT_LINE ('Delete succeeded for department number');" + + " END IF;" + + "END;" + + "/" + + "BEGIN" + + " p(270);" + + " p(400);" + + "END;"; // + + OracleStatementParser parser = new OracleStatementParser(sql); + List statementList = parser.parseStatementList(); + print(statementList); + + Assert.assertEquals(3, statementList.size()); + + OracleSchemaStatVisitor visitor = new OracleSchemaStatVisitor(); + for (SQLStatement statement : statementList) { + statement.accept(visitor); + } + + System.out.println("Tables : " + visitor.getTables()); + System.out.println("fields : " + visitor.getColumns()); + System.out.println("coditions : " + visitor.getConditions()); + System.out.println("relationships : " + visitor.getRelationships()); + System.out.println("orderBy : " + visitor.getOrderByColumns()); Assert.assertEquals(1, visitor.getTables().size()); Assert.assertEquals(1, visitor.getColumns().size()); Assert.assertEquals(1, visitor.getConditions().size()); Assert.assertEquals(0, visitor.getRelationships().size()); - // Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("employees", "salary"))); + Assert.assertEquals(1, visitor.getTables().size()); + Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("dept_temp"))); + Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("dept_temp", "department_id"))); } }