Search in sources :

Example 26 with SqlScript

use of org.flywaydb.core.internal.dbsupport.SqlScript 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());
}
Also used : SqlStatement(org.flywaydb.core.internal.dbsupport.SqlStatement) SqlScript(org.flywaydb.core.internal.dbsupport.SqlScript) Test(org.junit.Test)

Aggregations

SqlScript (org.flywaydb.core.internal.dbsupport.SqlScript)26 Test (org.junit.Test)21 SqlStatement (org.flywaydb.core.internal.dbsupport.SqlStatement)19 ClassPathResource (org.flywaydb.core.internal.util.scanner.classpath.ClassPathResource)17 SQLException (java.sql.SQLException)4 HashMap (java.util.HashMap)4 PlaceholderReplacer (org.flywaydb.core.internal.util.PlaceholderReplacer)4 FlywayException (org.flywaydb.core.api.FlywayException)3 FlywaySqlException (org.flywaydb.core.internal.dbsupport.FlywaySqlException)2 FlywaySqlScriptException (org.flywaydb.core.internal.dbsupport.FlywaySqlScriptException)2 Schema (org.flywaydb.core.internal.dbsupport.Schema)2 Callable (java.util.concurrent.Callable)1 MigrationVersion (org.flywaydb.core.api.MigrationVersion)1 JdbcTemplate (org.flywaydb.core.internal.dbsupport.JdbcTemplate)1 TransactionTemplate (org.flywaydb.core.internal.util.jdbc.TransactionTemplate)1