Change: ‘createProcedure’

Defines the definition for a stored procedure. This command 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 times it is best to use the CREATE OR REPLACE syntax along with setting runOnChange=’true’ on the enclosing changeSet tag. That way if you need to make a change to your procedure you can simply change your existing code rather than creating a new REPLACE PROCEDURE call. The advantage to this approach is that it keeps your change log smaller and allows you to more easily see what has changed in your procedure code through your source control system’s diff command.

Available Attributes

NameDescriptionRequired ForSupportsSince
catalogNameName of the catalogall
commentsall
dbmsall3.1
encodingall
pathFile containing the procedure text. Either this attribute or a nested procedure text is required.all
procedureNameall
procedureTextallall
relativeToChangelogFileall
schemaNameName of the schemaall
<changeSet author="liquibase-docs" id="createProcedure-example">
    <createProcedure catalogName="cat"
            comments="A String"
            dbms="h2, oracle"
            encoding="utf8"
            path="com/example/my-logic.sql"
            procedureName="A String"
            relativeToChangelogFile="true"
            schemaName="public">CREATE OR REPLACE PROCEDURE testHello
    IS
    BEGIN
      DBMS_OUTPUT.PUT_LINE('Hello From The Database!');
    END;</createProcedure>
</changeSet>
changeSet:
  id: createProcedure-example
  author: liquibase-docs
  changes:
  - createProcedure:
      catalogName: cat
      comments: A String
      dbms: h2, oracle
      encoding: utf8
      path: com/example/my-logic.sql
      procedureName: A String
      procedureText: |-
        CREATE OR REPLACE PROCEDURE testHello
            IS
            BEGIN
              DBMS_OUTPUT.PUT_LINE('Hello From The Database!');
            END;
      relativeToChangelogFile: true
      schemaName: public
{
  "changeSet": {
    "id": "createProcedure-example",
    "author": "liquibase-docs",
    "changes": [
      {
        "createProcedure": {
          "catalogName": "cat",
          "comments": "A String",
          "dbms": "h2, oracle",
          "encoding": "utf8",
          "path": "com/example/my-logic.sql",
          "procedureName": "A String",
          "procedureText": "CREATE OR REPLACE PROCEDURE testHello\n    IS\n    BEGIN\n\
            \      DBMS_OUTPUT.PUT_LINE('Hello From The Database!');\n    END;",
          "relativeToChangelogFile": true,
          "schemaName": "public"
        }
      }]
    
  }
}

Database Support

DatabaseNotesAuto Rollback
DB2SupportedNo
DerbySupportedNo
FirebirdSupportedNo
H2SupportedNo
HyperSQLSupportedNo
InformixSupportedNo
MySQLSupportedNo
OracleSupportedNo
PostgreSQLSupportedNo
SQL ServerSupportedNo
SQLiteSupportedNo
SybaseSupportedNo
Sybase AnywhereSupportedNo

Missing, incomplete or wrong information? Please send a pull request