createProcedure
he createProcedure Change Type defines the definition for a stored procedure. This Change Type is better to use for creating procedures than the raw SQL command because it will not attempt to strip comments or break up lines.
Often, it is best to use the CREATE OR REPLACE syntax along with setting runOnChange to true on the enclosing changeset tag. That way if you need to make a change to your procedure, you can change your existing code rather than creating a new REPLACE PROCEDURE call. The advantage to this approach is that it keeps your changelog smaller and allows you to more easily see what has changed in your procedure code through your source control system's diff command.
Run createProcedure
To run this Change Type, follow these steps:
Add the Change Type to your changeset, as shown in the examples on this page.
Specify any required attributes. Use the table on this page to see which ones your database requires.
Deploy your changeset by running the
update
command:liquibase update
Available attributes
Name | Description | Required for | Supports |
| Name of the catalog | all | |
| Specifies which database type(s)a changeset is to be used for. See valid database type names on | all | |
| Encoding used in the file specified in the | all | |
| File containing the procedure text. Either this attribute or a nested procedure text is required. | all | all |
| The SQL creating the procedure. You need to define either this attribute or the | all | all |
| Name of the stored procedure. Required if
. | mssql | |
| Specifies whether the file path is relative to the changelog file rather than looked up in the search path. Default: | all | |
| Boolean. If the stored procedure defined by Available in Liquibase 3.3 and later | mssql | |
| Name of the schema | all |
Database support
Database | Notes | |
DB2/LUW | Supported | No |
DB2/z | Supported | No |
Derby | Supported | No |
Firebird | Supported | No |
Google BigQuery | Supported | No |
H2 | Not Supported | No |
HyperSQL | Supported | No |
INGRES | Supported | No |
Informix | Supported | No |
MariaDB | Supported | No |
MySQL | Supported | No |
Oracle | Supported | No |
PostgreSQL | Supported | No |
Snowflake | Supported | No |
SQL Server | Supported | No |
SQLite | Not Supported | No |
Sybase | Supported | No |
Sybase Anywhere | Supported | No |
createProcedure examples
databaseChangeLog:
- changeSet:
id: createProcedure-example
author: liquibase-docs
changes:
- createProcedure:
catalogName: cat
dbms: postgresql, !oracle, mysql
encoding: UTF-8
path: com/example/my-logic.sql
procedureBody: |-
CREATE OR REPLACE PROCEDURE testHello
IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Hello From The Database!');
END;
procedureName: new_customer
relativeToChangelogFile: true
replaceIfExists: false
schemaName: public