Skyhawk Systems - Simplify data transformations
Products | Download | Buy | About Us
 
Table of Contents Connect XML-2-DB User's Guide dateTimeFormats.htmTable of ContentsmapParameterConstant.htm

5(g). Map Constant Rule - <map-const>


Connect XML-2-DB supports storing a constant value into a database table's column. Instead of mapping an XML element's pcdata or an attribute's value into a database column, we can specify a constant value in a rule in the mapping file, and for all inserts into that table corresponding to this map rule, that constant value will be stored in the database column.

Similarly, Connect XML-2-DB supports passing a constant value as the value for a parameter of a procedure. The format of the mapping rule, <map-const> that lets you do this is as follows:

       <!ELEMENT map-const       EMPTY>
       <!ATTLIST map-const
          element-name           CDATA #REQUIRED
          table-reference        CDATA #IMPLIED
          proc-reference         CDATA #IMPLIED
          column-name            CDATA #IMPLIED
          param-name             CDATA #IMPLIED
          constant-value         CDATA #REQUIRED
          source-datetime-format CDATA #IMPLIED>
	

In the map-const rule, both table-reference and column-name must be provided or both proc-reference and param-name must be provided.

  • element-name is the name of an xml element in the data file.
  • table-reference refers to the table into which the constant value has to be inserted. The table reference must have been previosuly defined in the mapping file.
  • proc-reference refers to the procedure that has to be invoked, with this constant value being passed in as the value for the parameter specified in param-name. Procedure reference must have been previosuly defined.
  • column-name is the column of the table referenced by table-reference, into which the constant value has to be inserted.
  • source-datetime-format is optional. If the column-name/param-name are date types, then this attribute indicates the format of the constant-value provdied. Please refer to the section on Date and Time Formats for more information about the source-datetime-format attribute.

5(gi). Inserting a constant value into a column of a database table

  • In this case the following attributes of map-const must be provided - element-name, table-reference, column-name and constant-value.
  • For Oracle databases, the value of column-name must be in uppercase, unless the column was created with quotes around it, in which case, the value of column name must be in lower case.
  • The constant-value attribute has the constant value that has to be mapped.
  • If the target database column, specified by table-reference and column-name is a date type column, then source-datetime-format must be provided.

Examples of mapping a constant value to a database table's column are as follows:

       <!-- "MID-WEST" will be inserted into the REGION column of the 
             table referenced by SoftwareSales -->
      <map-const
          element-name="software-sale"
          table-reference="SoftwareSales"
          column-name="REGION"
          constant-value="MID-WEST">
      </map-const>

      <!-- "Mar 10, 2001" will be inserted into the DATE_CREATED column of the 
           table referenced by SoftwareSales -->
      <map-const
          element-name="software-sale"
          table-reference="SoftwareSales"
          column-name="DATE_CREATED"
          constant-value="Mar 10, 2001"
          source-datetime-format="MMM dd, yyyy">
      </map-const>
	 

5(gii). Passing a constant as the value of a parameter to a procedure

  • In this case the following attributes of map-const must be provided - element-name, proc-reference, param-name and constant-value.
  • For Oracle databases, the value of param-name must be in uppercase.
  • For SQL Server databases, the value of param-name must be prefixed by a &
  • The constant-value attribute has the constant value that has to be mapped.
  • If the target procedure parameter, specified by proc-reference and param-name is a date type column, then source-datetime-format must be provided.

Examples of mapping a constant value to a parameter of a procedure call are as follows:

      <!-- SQL Server example -->
      <map-const
          element-name="software-sale"
          proc-reference="AddSoftwareSale"
          param-name="@i_date_created"
          constant-value="Mar 10, 2001"
          source-datetime-format="MMM dd, yyyy">
      </map-const>

      <!-- Oracle example -->
      <map-const
          element-name="software-sale"
          proc-reference="AddSoftwareSale"
          param-name="I_DATE_CREATED"
          constant-value="Mar 10, 2001"
          source-datetime-format="MMM dd, yyyy">
      </map-const>
	 
Copyright Skyhawk Systems. All Rights Reserved.
Send comments and questions to support@skyhawksystems.com.
dateTimeFormats.htmTable of ContentsmapParameterConstant.htm