Skip to content

ObjectComponent Element

Attribute Description
Schema Specifies the default schema to use, this is optional.
Category The is the name under which you wish to group this type of component.
Name The name is what will be used to display the component name with DATASTAR and will be also used as the file name (with a .sql suffix). Then name can be a static value, however it is more likely that you will want to derive this value dynamically based on the data that is in your database. Therefore you can also specify a variable name that is resolved against the data returned in the dynamic query element. If using variables try and use something unique like ${filename}
IncludeHash Optional and defaulted to "false", this flag will generate a "PRINT" statement at the end of the script with a SHA256 calculated hash value. This can be used to verify the version of the script, it can also be used to force a manual merge for conflicts when merging files, avoiding automatic merge conflict resolution.

Option Element

The Option element is optional and can be specified zero or more times. It is used to configure SQL options and is included in the generated script.

{Height=10px, Width=10px}

The valid options are used to control features that are included in the generated script. Not all options are applicable to schema object types:

Option Description
<Option Name="Permissions" Value="True"/> Use this option to include permissions in the script. For example a function or procedure may have execute privileges granted to a certain database users. Including this option will ensure that these grants are included in the generated script.
<Option Name="Indexes" Value="True"/> Use this option to include indexes in the generated script.
<Option Name="AnsiPadding" Value="True"/> Applies to SQL Server, use this option to turn ANSI_PADDING on or off.
<Option Name="NoCollation" Value="True"/> Sets the Boolean property value that specifies whether to include the collation clause in the generated script.
<Option Name="LineFormatting" Value="RemoveEmptyEntries"/> When generating the scripts empty lines will be removed, this can be useful when if comparing scripts.
<Option Name="LineFormatting" Value="Unformatted"/> When generating the scripts they will be generated from the database as they have been registered without removing blank lines.
<Option Name="IncludeDatabaseContext" Value="true"/> When generating the scripts they will be generated with the database context in the script.
<Option Name="ServerVersion" Value="11.0"/> Forces DataStar to generate scripts compatible with the specified target database version (11.0 = SqlServer 2012, 12.0 = SqlServer 2014, 13.0 = SqlServer 2016, 14.0 = SqlServer 2017, 15.0 = SqlServer 2019) - if not specified it will generate the scripts using the same version as the database from where the script is being extracted.
<Option Name="CreateOrAlter" Value="true"/> Will generate scrips as a Create Or Alter in SqlServer provided it is supported by the SqlServer version. This will only generate a drop if it is a delete script.

SchemaObject Element

The schema object element is required to specify the type and the name of the component you wish to define.

Attributes

Attribute Description
Name The name of the component in the database, excluding the schema name.
Type The type of the database component to extract, valid values include:
  • DdlTrigger
  • Function
  • Procedure
  • Table
  • Trigger
  • View

** DDL triggers fire in response to a variety of Data Definition Language (DDL) events. These events primarily correspond to Transact-SQL statements that start with the keywords CREATE, ALTER, DROP, GRANT, DENY, REVOKE or UPDATE STATISTICS. Certain system stored procedures that perform DDL-like operations can also fire DDL triggers.

DynamicQuery Element

The dynamic query allows the Object Component definition to be used as a template. If being used to generate multiple scripts the DynamicQuery should contain a CDATA section with a query that returns a row per script. The columns that are returned should be given a variable name such as ${name} and then your template can contain these variables.

For example in my template I could have a Data Component defined <ObjectComponent Category="table-views" Name="${filename}"> and in my DynamicQuery I would provide a CDATA section with a column that returned the file name and any other variables that I needed to use. It is also a good idea to escape the data returned if you know it might contain characters that would not be valid.

<DynamicQuery>
    <![CDATA[
        SELECT TABLE_SCHEMA AS '${schema}', '[' + TABLE_SCHEMA + '].[' + TABLE_NAME + ']' as '${filename}', TABLE_NAME AS '${name}'
        FROM INFORMATION_SCHEMA.VIEWS
    ]]>
</DynamicQuery>

Deployment Element

The Deployment element is used when you package up scripts to be deployed within a release. A component within a package may be order sensitive for example you may need to deploy component A before component B. DATASTAR will sequence the items contained in your deployment using the Weight. In some cases it is necessary to run a script before the components are deployed and another script afterwards, for example a script to disable constraints and then a script to enable them afterwards. This is handled via the Script element as shown in the example.

Example:

<Deployment Weight="1000">
    <Script Path="templates/scripts/table-constraints-disable.sql" Weight="-1"/>
    <Script Path="templates/scripts/table-constraints-enable.sql" Weight="+1"/>
</Deployment>

The path is relative from your workspace and should be under source control as during deployment DATASTAR will identify the version from your source control system. Not you can give a + or - value which effectively gives it a weight relative to the Deployment element Weight.