1 | |
package liquibase.sqlgenerator.core; |
2 | |
|
3 | |
import liquibase.database.Database; |
4 | |
import liquibase.database.core.DB2Database; |
5 | |
import liquibase.exception.DatabaseException; |
6 | |
import liquibase.exception.UnexpectedLiquibaseException; |
7 | |
import liquibase.sql.Sql; |
8 | |
import liquibase.sql.UnparsedSql; |
9 | |
import liquibase.sqlgenerator.SqlGenerator; |
10 | |
import liquibase.sqlgenerator.SqlGeneratorChain; |
11 | |
import liquibase.statement.core.GetViewDefinitionStatement; |
12 | |
|
13 | 10 | public class GetViewDefinitionGeneratorDB2 extends GetViewDefinitionGenerator { |
14 | |
@Override |
15 | |
public int getPriority() { |
16 | 1 | return SqlGenerator.PRIORITY_DATABASE; |
17 | |
} |
18 | |
|
19 | |
@Override |
20 | |
public boolean supports(GetViewDefinitionStatement statement, Database database) { |
21 | 0 | return database instanceof DB2Database; |
22 | |
} |
23 | |
|
24 | |
@Override |
25 | |
public Sql[] generateSql(GetViewDefinitionStatement statement, Database database, |
26 | |
SqlGeneratorChain sqlGeneratorChain) { |
27 | |
try { |
28 | 0 | return new Sql[] { new UnparsedSql("select view_definition from SYSIBM.VIEWS where TABLE_NAME='" |
29 | |
+ statement.getViewName() + "' and TABLE_SCHEMA='" |
30 | |
+ database.convertRequestedSchemaToSchema(statement.getSchemaName()) + "'") }; |
31 | 0 | } catch (DatabaseException e) { |
32 | 0 | throw new UnexpectedLiquibaseException(e); |
33 | |
} |
34 | |
} |
35 | |
} |