Topic
Prev Next

DDL Function Macros

The DDL Function macros provide a convenient way of manipulating, retrieving or formatting element data relevant to DDL generation. These macros, along with the code function macros, are available to the DDL templates. Each Function macro returns a result string and is used in the same manner as a Code Template Function macro.

The available function macros are described here. All parameters have a type of String and are denoted by square brackets; that is: FUNCTION_NAME([param]).

DDL_DATATYPE_SIZE ([productName], [datatype])

Returns the fully formatted datatype of the current column in DDL syntax.

Parameters

  • productName - the current Table's assigned DBMS, such as SQL Server 2012, Oracle or PostgreSQL
  • datatype - the current column's datatype name, such as VARCHAR or INT

Remarks

Within an Enterprise Architect Table column, datatypes are defined with a Length Type (0, 1 or 2) property that influences the DDL syntax; this function macro takes the Length Type (and other factors) into consideration when building the return value.

DDL_GET_DEFINITION_PARAS ([definition])

Returns a string representation of the parameters from the supplied function/procedure definition.

Parameters

  • definition - the complete SQL definition of the procedure/function

Remarks

Some DBMSs (such as PostgreSQL) support multiple definitions of the same procedure/function name. The definitions differ only in their parameter list, therefore to manipulate such objects the DDL must specify the name and parameters. This function macro gives the DDL templates the ability to extract the parameters so that they can then be used to identify individual objects.

DDL_INCLUDE_SQLQUERY([objectName])

Returns the SQL statement defined in the SQLQuery object.

Parameters

  • objectName - the name of the SQL Query object defined in the current data model

Remarks

None.

DDL_INDEX_SORT([product],[columns])

Returns the sort order of a given index.

Parameters

  • product - the DBMS (currently, Firebird)
  • columns - a CSV of column names involved in the index

Remarks

This macro currently only applies to Firebird indexes.

DDL_RESOLVE_NAME ([productName], [name], [leftSurround], [rightSurround])

Returns the supplied name delimited (with the supplied left and right characters) if the name is a reserved word for the current DBMS.

Parameters

  • productName - the current Table's assigned DBMS, such as SQL Server 2012, Oracle or PostgreSQL
  • name - the object/column name
  • leftSurround - the left character of the pair used to surround the name; for example, single quote {'}
  • rightSurround - the right character of the pair used to surround the name; for example, single quote {'}

Remarks

The DDL syntax of some DBMSs requires names that are reserved words to be delimited in a different manner; this function macro can be used to safely format all names for DB2 and Firebird.

DDL_TABLE_TAGVALUE ([tagName])

Returns the value for the supplied tag name in the repository's version of the current Table.

Parameters

  • tagName - the tag item's name that is to be retrieved

Remarks

None.

EXECUTE_CURRENT ([objectName], [actionName], [priority])

Adds the return string from the current template to the Execution Engine's execution queue.

Parameters

  • objectName - the value that will be shown in the 'Object' column of the execution queue, which indicates the name of the object being updated
  • actionName - the value that will be shown in the 'Action' column of the execution queue, which indicates the action that resulted in the generation of this statement
  • priority - a numeric value that represents the priority of the statement; the higher the number, the lower in the queue the statement is placed

Remarks

This function macro can be called at any point throughout the template, but will not execute until the end. Once the template is complete, the DDL it has generated is sent to the execution queue.

This function macro has no effect if the user has elected to generate DDL to a file.

EXECUTE_STRING ([objectName], [actionName], [priority], [ddlStatement])

Adds the supplied DDL statement to the Execution Engine's execution queue.

Parameters

  • objectName - the value that will be shown in the 'Object' column of the execution queue, which indicates the name of the object being updated
  • actionName - the value that will be shown in the 'Action' column of the execution queue, which indicates the action that resulted in the generation of this statement
  • priority - a numeric value that represents the priority of the statement; the higher the number, the lower in the queue the statement is placed
  • ddlStatement - a single DDL statement that performs the required action

Remarks

This function macro has no effect if the user has elected to generate DDL to a file.

EXIST_STRING ([ddlStatement])

Searches the Execution Engine's execution queue for the supplied DDL Statement and returns 'T' if the statement is found.

Parameters

  • ddlStatement - a single DDL statement

Remarks

None.

GET_FIRST_SQL_KEYWORD([statement])

Returns the first keyword of the provided SQL statement.

Parameters

  • statement - the SQL statement

Remarks

None.

ODBC_TABLE_TAGVALUE ([tagName])

Returns the value for the supplied tag name in the live database's version of the current table.

Parameters

  • tagName - the tag item's name that is to be retrieved

Remarks

None.

PROCESS_DDL_SCRIPT ([type], [parameter2], [parameter3], [parameter4])

A generic function macro that returns a formatted string for a specific purpose.

Parameters

  • type - specifies the special action to be undertaken
  • parameter2 - generic parameter 2, will have a different purpose for each type
  • parameter3 - generic parameter 3, will have a different purpose for each type
  • parameter4 - generic parameter 4, will have a different purpose for each type

Remarks

For Oracle Synonyms use these parameters:

  • type = "SYNONYMS"
  • parameter2 = the table name; for example, TBL_EMPLOYEES
  • parameter3 = a delimited string of values, separated by semi-colons, specifying the synonym owner and name with full colon between; for example, OE:EMPLOYEES;PUBLIC:PUB_EMPLOYEES;
  • parameter4 = the statement terminator

Return Result

Of the format:

     CREATE SYNONYM OE.EMPLOYEES FOR TBL_EMPLOYEES;

     CREATE PUBLIC SYNONYM PUB_EMPLOYEES FOR TBL_EMPLOYEES;

REMOVE_LAST_SEPARATOR ([ddlStatement], [separator])

Returns the supplied DDL statement with the last separator removed (if it exists).

Parameters

  • ddlStatement - a partial DDL statement
  • separator - the separator character that should be removed

Remarks

When building a string that represents a DDL statement, it is common practice to append the separator character after each item; however, the separator is not required after the last item, so this function macro is provided to remove the trailing separator.

REMOVE_STRING ([ddlStatement])

Removes the supplied DDL statement from the Execution Engine's execution queue.

Parameters

  • ddlStatement - a single DDL statement

Remarks

None.

SUPPRESS_EXECUTE_CURRENT ([boolean])

A function macro to enable/disable subsequent calls to EXECUTE_CURRENT.

Parameters

  • boolean - True or False

Remarks

The default state for this flag is False; that is, calls to EXECUTE_CURRENT are not ignored.