1 | |
package liquibase.change.core; |
2 | |
|
3 | |
import liquibase.change.AbstractChange; |
4 | |
import liquibase.change.ChangeMetaData; |
5 | |
import liquibase.database.Database; |
6 | |
import liquibase.database.core.OracleDatabase; |
7 | |
import liquibase.database.core.DB2Database; |
8 | |
import liquibase.statement.SqlStatement; |
9 | |
import liquibase.statement.core.RawSqlStatement; |
10 | |
|
11 | |
public class CreateProcedureChange extends AbstractChange { |
12 | |
private String comments; |
13 | |
private String procedureBody; |
14 | |
|
15 | |
public CreateProcedureChange() { |
16 | 11 | super("createProcedure", "Create Procedure", ChangeMetaData.PRIORITY_DEFAULT); |
17 | 11 | } |
18 | |
|
19 | |
public String getProcedureBody() { |
20 | 0 | return procedureBody; |
21 | |
} |
22 | |
|
23 | |
public void setProcedureBody(String procedureBody) { |
24 | 1 | this.procedureBody = procedureBody; |
25 | 1 | } |
26 | |
|
27 | |
public String getComments() { |
28 | 0 | return comments; |
29 | |
} |
30 | |
|
31 | |
public void setComments(String comments) { |
32 | 1 | this.comments = comments; |
33 | 1 | } |
34 | |
|
35 | |
public SqlStatement[] generateStatements(Database database) { |
36 | 0 | String endDelimiter = ";"; |
37 | 0 | if (database instanceof OracleDatabase) { |
38 | 0 | endDelimiter = "\n/"; |
39 | 0 | } else if (database instanceof DB2Database) { |
40 | 0 | endDelimiter = ""; |
41 | |
} |
42 | |
|
43 | 0 | return new SqlStatement[] { new RawSqlStatement(getProcedureBody(), endDelimiter), }; |
44 | |
} |
45 | |
|
46 | |
public String getConfirmationMessage() { |
47 | 0 | return "Stored procedure created"; |
48 | |
} |
49 | |
} |