Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Placement and Precedence

The metadata-variables.properties file applies to all files and subdirectories in the directory where it is found, including the root directory for SQL scripts.   Additional metadata-variables.properties files can be used in the subdirectories. A property set in a subdirectory overrides the same property set in a parent directory. 

Place variables in the metadata-variables.properties file, one per line. The notation for a variable depends on whether the script you are packaging is a DDL script or a native script, as described in Using Variables

Variable Processing

Variables are interpreted as positional variables. The first value in the metadata-variables.properties file replaces the first occurrence of a variable in the script, and so on. 

Info
titleImportant

No space trimming or interpretation is performed during processing. The metadata-variables.properties file is taken as-is.

Example

Variables and changelog properties may be used together to express variable values per context (database target). For example, you may want to express a different TABLESPACE value depending on the context (database) where you are deploying changes. 

Changelog properties are interpreted before processing for variables. See Setting Properties in the Project Changelog

The following example is based on scripts intended for Oracle SQL*Plus. Variables use the form &var.

  • Properties in changelog

    Code Block
    <property context="REF" name="CLPROP_TBL" value="TBLVAR">
    <property context="REF" name="CLPROP_TBLSPC" value="TBLSPC">


  • metadata-variables.properties variables (standard SQL script in DDL folder)

    Code Block
    &1=${CLPROP_TBL}
    &2=${CLPROP_TBLSPC}


  • Script

    Code Block
    CREATE TABLE MYTABLE_&1
    (c1 varchar2(20))
    TABLESPACE "&2"; 


  • Processed Script with changelog properties and variables interpreted

    Code Block
    CREATE TABLE MYTABLE_TBLVAR
    (c1 varchar2(20))
    TABLESPACE "TBLSPC"; 


...

Variable representation in scripts is done as SQL-style variables (SET @varnam = "value"). DDL scripts are one of the following: 

  • Scripts in the ddl fixed the ddl fixed folder.
  • Scripts in a flexible folder with packageMethod=CONVERT. 

...

Variable representation in scripts depends on the client-command syntax for the database. Native scripts are one of the following: 

  • Scripts in the sql_direct or ddl_direct fixed folders.
  • Scripts in a flexible folder with packageMethod=DIRECT or packageMethod=DDL_DIRECT. 

Oracle

SQL*PLUS is the native command facility for Oracle databases. Variables are represented as follows:

...