use of org.flywaydb.core.internal.dbsupport.SqlStatement in project flyway by flyway.
the class EnterpriseDBSqlScriptSmallTest method parseProcedure.
@Test
public void parseProcedure() throws Exception {
String source = "CREATE OR REPLACE PROCEDURE set_right_value_for_sequence(seq_name in VARCHAR2, table_name in VARCHAR2, column_id in VARCHAR2)\n" + "IS\n" + " seq_val NUMBER(6);\n" + " row_count NUMBER(6);\n" + "BEGIN\n" + " EXECUTE IMMEDIATE\n" + " 'select ' || seq_name || '.nextval from dual' INTO seq_val;\n" + "\n" + " EXECUTE IMMEDIATE\n" + " 'alter sequence ' || seq_name || ' increment by -' || seq_val || ' minvalue 0';\n" + "\n" + " EXECUTE IMMEDIATE\n" + " 'select ' || seq_name || '.nextval from dual' INTO seq_val;\n" + "\n" + " EXECUTE IMMEDIATE\n" + " 'select case when max(' || column_id || ') is null then 1 else max(' || column_id || ') end from ' || table_name INTO row_count;\n" + "\n" + " EXECUTE IMMEDIATE\n" + " 'alter sequence ' || seq_name || ' increment by ' || row_count || ' minvalue 0';\n" + "\n" + " EXECUTE IMMEDIATE\n" + " 'select ' || seq_name || '.nextval from dual' INTO seq_val;\n" + "\n" + " EXECUTE IMMEDIATE\n" + " 'alter sequence ' || seq_name || ' increment by 1 minvalue 1';\n" + "END;\n" + "/\n" + "\n" + "EXECUTE set_right_value_for_sequence('SEQ_ATR', 'TOTCATTRIB', 'ATTRIB_ID');";
SqlScript sqlScript = new SqlScript(source, new EnterpriseDBDbSupport(null));
List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
assertEquals(2, sqlStatements.size());
}
use of org.flywaydb.core.internal.dbsupport.SqlStatement in project flyway by flyway.
the class EnterpriseDBSqlScriptSmallTest method parseCompoundTrigger.
@Test
public void parseCompoundTrigger() throws Exception {
String source = "CREATE OR REPLACE TRIGGER triggername\n" + " FOR insert ON tablename\n" + " COMPOUND TRIGGER\n" + "\n" + " -- Global declaration.\n" + " g_global_variable VARCHAR2(10);\n" + "\n" + " BEFORE STATEMENT IS\n" + " BEGIN\n" + " NULL; -- Do something here.\n" + " END BEFORE STATEMENT;\n" + "\n" + " BEFORE EACH ROW IS\n" + " BEGIN\n" + " NULL; -- Do something here.\n" + " END BEFORE EACH ROW;\n" + "\n" + " AFTER EACH ROW IS\n" + " BEGIN\n" + " NULL; -- Do something here.\n" + " END AFTER EACH ROW;\n" + "\n" + " AFTER STATEMENT IS\n" + " BEGIN\n" + " NULL; -- Do something here.\n" + " END AFTER STATEMENT;\n" + "\n" + "END <trigger-name>;\n" + "/";
SqlScript sqlScript = new SqlScript(source, new EnterpriseDBDbSupport(null));
List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
assertEquals(1, sqlStatements.size());
}
use of org.flywaydb.core.internal.dbsupport.SqlStatement in project flyway by flyway.
the class OracleSqlScriptSmallTest method parseFunctionsAndProcedures.
@Test
public void parseFunctionsAndProcedures() throws Exception {
String source = new ClassPathResource("migration/dbsupport/oracle/sql/function/V1__Function.sql", Thread.currentThread().getContextClassLoader()).loadAsString("UTF-8");
SqlScript sqlScript = new SqlScript(source, new OracleDbSupport(null));
List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
assertEquals(5, sqlStatements.size());
assertEquals(17, sqlStatements.get(0).getLineNumber());
assertEquals(26, sqlStatements.get(1).getLineNumber());
assertEquals(34, sqlStatements.get(2).getLineNumber());
assertEquals(36, sqlStatements.get(3).getLineNumber());
assertEquals(44, sqlStatements.get(4).getLineNumber());
assertEquals("COMMIT", sqlStatements.get(4).getSql());
}
use of org.flywaydb.core.internal.dbsupport.SqlStatement in project flyway by flyway.
the class OracleSqlScriptSmallTest method parseQQuotes.
@Test
public void parseQQuotes() throws Exception {
String source = new ClassPathResource("migration/dbsupport/oracle/sql/qquote/V1__Q_Quote.sql", Thread.currentThread().getContextClassLoader()).loadAsString("UTF-8");
SqlScript sqlScript = new SqlScript(source, new OracleDbSupport(null));
List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
assertEquals(12, sqlStatements.size());
}
use of org.flywaydb.core.internal.dbsupport.SqlStatement in project flyway by flyway.
the class OracleSqlScriptSmallTest method parseCompoundTrigger.
@Test
public void parseCompoundTrigger() throws Exception {
String source = "CREATE OR REPLACE TRIGGER triggername\n" + " FOR insert ON tablename\n" + " COMPOUND TRIGGER\n" + "\n" + " -- Global declaration.\n" + " g_global_variable VARCHAR2(10);\n" + "\n" + " BEFORE STATEMENT IS\n" + " BEGIN\n" + " NULL; -- Do something here.\n" + " END BEFORE STATEMENT;\n" + "\n" + " BEFORE EACH ROW IS\n" + " BEGIN\n" + " NULL; -- Do something here.\n" + " END BEFORE EACH ROW;\n" + "\n" + " AFTER EACH ROW IS\n" + " BEGIN\n" + " NULL; -- Do something here.\n" + " END AFTER EACH ROW;\n" + "\n" + " AFTER STATEMENT IS\n" + " BEGIN\n" + " NULL; -- Do something here.\n" + " END AFTER STATEMENT;\n" + "\n" + "END <trigger-name>;\n" + "/";
SqlScript sqlScript = new SqlScript(source, new OracleDbSupport(null));
List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
assertEquals(1, sqlStatements.size());
}
Aggregations