use of com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser in project druid by alibaba.
the class OracleAlterTriggerTest2 method test_0.
public void test_0() throws Exception {
//
String sql = "alter TRIGGER RETL.TRG_COMPANY_SYNC compile";
OracleStatementParser parser = new OracleStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement statemen = statementList.get(0);
print(statementList);
Assert.assertEquals(1, statementList.size());
OracleSchemaStatVisitor visitor = new OracleSchemaStatVisitor();
statemen.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(0, visitor.getTables().size());
// Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("cdc.en_complaint_ipr_stat_fdt0")));
Assert.assertEquals(0, visitor.getColumns().size());
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("pivot_table", "*")));
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("pivot_table", "YEAR")));
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("pivot_table", "order_mode")));
}
use of com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser in project druid by alibaba.
the class OracleAlterViewTest method test_0.
public void test_0() throws Exception {
//
String sql = "alter VIEW ALIBABA1949.COMPANY_VIEW_2 compile";
OracleStatementParser parser = new OracleStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement statemen = statementList.get(0);
print(statementList);
Assert.assertEquals(1, statementList.size());
OracleSchemaStatVisitor visitor = new OracleSchemaStatVisitor();
statemen.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(0, visitor.getTables().size());
// Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("cdc.en_complaint_ipr_stat_fdt0")));
Assert.assertEquals(0, visitor.getColumns().size());
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("pivot_table", "*")));
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("pivot_table", "YEAR")));
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("pivot_table", "order_mode")));
}
use of com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser in project druid by alibaba.
the class OracleBlockTest method test_0.
public void test_0() throws Exception {
String sql = "BEGIN :RESULT := \"SYS\".\"DBMS_AQ_IMPORT_INTERNAL\".\"AQ_EXPORT_CHECK\"(:arg); END;";
OracleStatementParser parser = new OracleStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement statemen = statementList.get(0);
print(statementList);
Assert.assertEquals(1, statementList.size());
OracleSchemaStatVisitor visitor = new OracleSchemaStatVisitor();
statemen.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(0, visitor.getTables().size());
// Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("departments")));
Assert.assertEquals(0, visitor.getColumns().size());
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("departments", "department_id")));
}
use of com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser in project druid by alibaba.
the class OracleBlockTest12 method test_0.
public void test_0() throws Exception {
String sql = "DECLARE" + " emp_id NUMBER(6);" + " emp_lastname VARCHAR2(25);" + " emp_salary NUMBER(8,2);" + " emp_jobid VARCHAR2(10);" + "BEGIN" + " SELECT employee_id, last_name, salary, job_id" + " INTO emp_id, emp_lastname, emp_salary, emp_jobid" + " FROM employees" + " WHERE employee_id = 120;" + "" + " INSERT INTO emp_name (employee_id, last_name)" + " VALUES (emp_id, emp_lastname); " + " INSERT INTO emp_sal (employee_id, salary) " + " VALUES (emp_id, emp_salary);" + "" + " INSERT INTO emp_job (employee_id, job_id)" + " VALUES (emp_id, emp_jobid);" + " " + "EXCEPTION" + " WHEN DUP_VAL_ON_INDEX THEN" + " ROLLBACK;" + " DBMS_OUTPUT.PUT_LINE('Inserts were rolled back');" + //
"END;";
OracleStatementParser parser = new OracleStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
print(statementList);
Assert.assertEquals(1, 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(4, visitor.getTables().size());
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("employees")));
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("emp_name")));
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("emp_sal")));
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("emp_job")));
Assert.assertEquals(11, visitor.getColumns().size());
Assert.assertEquals(1, visitor.getConditions().size());
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("employees", "salary")));
}
use of com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser in project druid by alibaba.
the class OracleBlockTest14 method test_0.
public void test_0() throws Exception {
String sql = //
"DECLARE" + //
" emp_id employees.employee_id%TYPE;" + //
" emp_lastname employees.last_name%TYPE;" + //
" emp_salary employees.salary%TYPE;" + //
"" + //
"BEGIN" + //
" SELECT employee_id, last_name, salary" + //
" INTO emp_id, emp_lastname, emp_salary" + //
" FROM employees" + //
" WHERE employee_id = 120;" + //
" SAVEPOINT my_savepoint;" + //
" " + //
" UPDATE emp_name" + //
" SET salary = salary * 1.1" + //
" WHERE employee_id = emp_id;" + //
" " + //
" DELETE FROM emp_name" + //
" WHERE employee_id = 130;" + //
" " + //
" SAVEPOINT my_savepoint;" + //
" " + //
" INSERT INTO emp_name (employee_id, last_name, salary)" + //
" VALUES (emp_id, emp_lastname, emp_salary);" + //
"" + //
"EXCEPTION" + //
" WHEN DUP_VAL_ON_INDEX THEN" + //
" ROLLBACK TO my_savepoint;" + //
" DBMS_OUTPUT.PUT_LINE('Transaction rolled back.');" + //
"END;";
OracleStatementParser parser = new OracleStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
print(statementList);
Assert.assertEquals(1, 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(2, visitor.getTables().size());
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("employees")));
Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("emp_name")));
Assert.assertEquals(7, visitor.getColumns().size());
Assert.assertEquals(3, visitor.getConditions().size());
Assert.assertEquals(1, visitor.getRelationships().size());
// Assert.assertTrue(visitor.getColumns().contains(new TableStat.Column("employees", "salary")));
}
Aggregations