use of org.flywaydb.core.internal.dbsupport.SqlStatement in project flyway by flyway.
the class OracleSqlScriptSmallTest 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 OracleDbSupport(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 OracleSqlScriptSmallTest method parseMergeInsert.
@Test
public void parseMergeInsert() throws Exception {
String source = "INSERT INTO ss.CODETBL(FIELDNAME,FIELDVALUE,IDS)\n" + "SELECT FIELDNAME,FIELDVALUE,IDS FROM\n" + "(\n" + "SELECT 'ACCT_TYPE_CD' FIELDNAME, '$' FIELDVALUE,'SAMP' IDS FROM DUAL UNION ALL\n" + "SELECT 'ACCT_TYPE_CD', 'L','SAMP' FROM DUAL UNION ALL\n" + "SELECT 'ACCT_TYPE_CD', 'C','SAMP' FROM DUAL \n" + ")\n" + "D\n" + "WHERE NOT EXISTS\n" + "(\n" + "SELECT 1 FROM SS.CODETBL \n" + "WHERE D.FIELDNAME = FIELDNAME \n" + "AND D.FIELDVALUE = FIELDVALUE\n" + "AND D.IDS = IDS\n" + ");";
SqlScript sqlScript = new SqlScript(source, new OracleDbSupport(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 parsePackages.
@Test
public void parsePackages() throws Exception {
String source = new ClassPathResource("migration/dbsupport/oracle/sql/package/V1__Package.sql", Thread.currentThread().getContextClassLoader()).loadAsString("UTF-8");
SqlScript sqlScript = new SqlScript(source, new OracleDbSupport(null));
List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
assertEquals(2, sqlStatements.size());
assertEquals(17, sqlStatements.get(0).getLineNumber());
assertEquals(33, sqlStatements.get(1).getLineNumber());
}
use of org.flywaydb.core.internal.dbsupport.SqlStatement in project flyway by flyway.
the class MySQLSqlScriptSmallTest method multiLineCommentDirective.
@Test
public void multiLineCommentDirective() throws Exception {
String source = "/*!50001 CREATE ALGORITHM=UNDEFINED */\n" + "/*!50013 DEFINER=`user`@`%` SQL SECURITY DEFINER */\n" + "/*!50001 VIEW `viewname` AS select `t`.`id` AS `someId`,`t`.`name` AS `someName` from `someTable` `t` where `t`.`state` = 0 */;\n";
SqlScript sqlScript = new SqlScript(source, new MySQLDbSupport(null));
List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
assertEquals(1, sqlStatements.size());
assertEquals(1, sqlStatements.get(0).getLineNumber());
}
use of org.flywaydb.core.internal.dbsupport.SqlStatement in project flyway by flyway.
the class EnterpriseDBSqlScriptSmallTest method parseMergeInsert.
@Test
public void parseMergeInsert() throws Exception {
String source = "INSERT INTO ss.CODETBL(FIELDNAME,FIELDVALUE,IDS)\n" + "SELECT FIELDNAME,FIELDVALUE,IDS FROM\n" + "(\n" + "SELECT 'ACCT_TYPE_CD' FIELDNAME, '$' FIELDVALUE,'SAMP' IDS FROM DUAL UNION ALL\n" + "SELECT 'ACCT_TYPE_CD', 'L','SAMP' FROM DUAL UNION ALL\n" + "SELECT 'ACCT_TYPE_CD', 'C','SAMP' FROM DUAL \n" + ")\n" + "D\n" + "WHERE NOT EXISTS\n" + "(\n" + "SELECT 1 FROM SS.CODETBL \n" + "WHERE D.FIELDNAME = FIELDNAME \n" + "AND D.FIELDVALUE = FIELDVALUE\n" + "AND D.IDS = IDS\n" + ");";
SqlScript sqlScript = new SqlScript(source, new EnterpriseDBDbSupport(null));
List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
assertEquals(1, sqlStatements.size());
}
Aggregations