MINI MINI MANI MO
<?xml version="1.0"?>
<!--
Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
NAME
kustable.xsl
DESCRIPTION
Convert mdapi TABLE_T document to TABLE document (SXML)
MODIFIED MM/DD/YY
jjanosik 12/21/16 - Bug 25260248: Add supplemental logging to object
tables
tbhukya 01/11/16 - Bug 25335663 - Don't generate row archival hidden col
tbhukya 10/18/16 - Bug 24822718 - Sort with INTCOL_NUM when col list
has invisible column
rapayne 09/21/16 - bug 23203578: global temp tabs need to support
parallel attributes.
jjanosik 09/12/16 - Bug 24387072: unconditionally add collation to SXML
jjanosik 07/22/16 - Bug 23708351: Fix clustered object table
tbhukya 05/13/16 - Bug 23248862: Generate result cache
irrespective of segment creation
tbhukya 08/24/15 - Bug 21179353: Don't generate oidindex and table
column properties for binary xmltype table
tbhukya 08/14/15 - Bug 21276592: Partitioned cluster table
tbhukya 07/14/15 - Bug 21438396: Def collation is invalid for
object, xml type table
rapayne 06/06/15 - bug 21205467: fix virtual and hidden col attributes
tbhukya 05/23/15 - Bug 21118665: DBC support for object, xml type table
tbhukya 02/25/15 - Proj 47173: Data bound collation
rapayne 11/07/14 - bug 19976325 - deferred segment support for [P]IOTs,
xmltype and object tables.
lbarton 09/24/14 - row archival and SXML
abodge 06/10/14 - CM MODIFIED: Remove generation of COL_NUM
lbarton 06/04/14 - bug 18750140: valid-time temporal
lbarton 04/24/14 - bug 18556940: don't emit certain hidden columns
bwright 10/18/13 - Bug 17627666: Add COL_SORTKEY for consistent
column ordering with stream and exttbl metadata
bwright 08/21/13 - Bug 17312600: Remove hard tabs from DP src code
lbarton 04/24/13 - bug 16716831: functional index expression as varchar
or clob
lbarton 03/01/12 - 36954_dpump_tabcluster_zonemap
rapayne 11/30/11 - project 36780: Invisible Column support.
ebatbout 10/24/11 - 12781157: Unpacked opaque column support
rapayne 06/15/11 - lrg 5665517: fix xmlns violation.
ebatbout 03/28/10 - Refine prior edit to take into account stream meta-
data version when add suffix, '.NESTED_TABLE_SETID$'
ebatbout 01/25/10 - bug 8465341: When HIDDEN_COLUMNS param set(by Data
Pump data layer (prvtbpd.sql):
In template,CreObjTable, create unique name for
nested table setid col(instead of system generated
generated name)
Add the elements, stream_major_version & stream_
minor_version, to the sxml document.
lbarton 11/04/09 - deferred segment creation for partitions
abodge 09/21/09 - CONSOLIDATE STYLESHEETS: MAKE_DIFF_READY -> CM_MODE
ebatbout 12/16/08 - bug 6075698: add support for hidden_columns param
and recognize STRMTABLE_T keyword
rapayne 12/24/08 - bug 759589: add $STATISTICS support from CM code
stream.
lbarton 08/28/08 - xmltype virtual columns
lbarton 02/14/08 - flashback archive
lbarton 03/19/08 - deferred segment creation
abodge 01/22/07 - add COL_NUM attribute when MAKE_DIFF_READY is set.
rapayne 11/27/06 - Integrate EM specific changes
rapayne 07/14/06 - Sort by column name
lbarton 06/23/06 - PARSE_EXPRESSIONS param
htseng 05/24/06 - virtual hidden support
lbarton 03/27/06 - bug 5118027: CONSTRAINTS and REF_CONSTRAINTS params
for SXML
htseng 12/16/05 - add transform param
lbarton 11/08/05 - bug 4724986: fix handling of xmlns
sdavidso 11/02/05 - fix inconsistent stylesheet format
lbarton 09/14/05 - SXML syntax changes required by XML schema
lbarton 08/10/05 - lbarton_mddiff
htseng 05/27/05 - pass PROPERTY to TablePhysicalProperties
lbarton 11/01/04 - Initial version
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://xmlns.oracle.com/ku">
<!-- Top level imports -->
<xsl:import href="kuscomm.xsl"/>
<xsl:import href="kuscnstr.xsl"/>
<xsl:import href="kustbphy.xsl"/>
<xsl:import href="kuspar.xsl"/>
<xsl:import href="kusclzm.xsl"/>
<!-- Top-level parameters -->
<xsl:param name="PHYSICAL_PROPERTIES">1</xsl:param>
<xsl:param name="SEGMENT_ATTRIBUTES">1</xsl:param>
<xsl:param name="STORAGE">1</xsl:param>
<xsl:param name="TABLESPACE">1</xsl:param>
<xsl:param name="CONSTRAINTS">1</xsl:param>
<xsl:param name="REF_CONSTRAINTS">1</xsl:param>
<xsl:param name="PARTITIONING">1</xsl:param>
<xsl:param name="OID">1</xsl:param>
<xsl:param name="PARSE_EXPRESSIONS">0</xsl:param>
<xsl:param name="STATISTICS">0</xsl:param>
<xsl:param name="HIDDEN_COLUMNS">0</xsl:param>
<xsl:param name="STREAMD_VERSION">2</xsl:param>
<xsl:param name="DATA_LAYER_NOT_NETWORK">0</xsl:param>
<!-- Templates -->
<xsl:template match="TABLE_T | STRMTABLE_T">
<!-- *******************************************************************
Template: TABLE_T - top-level template for tables.
This template puts out
- the opening TABLE element (with xmlns and version attributes)
- SCHEMA and NAME elements
then calls one of
- CreObjTable - for object tables and XMLType tables
- CreRelTable - for relational tables
******************************************************************** -->
<xsl:element name="TABLE" namespace="http://xmlns.oracle.com/ku">
<xsl:attribute name="version">1.0</xsl:attribute>
<xsl:if test="(PROPERTY mod 8388608)>=4194304">
<xsl:element name="GLOBAL_TEMPORARY"/>
</xsl:if>
<xsl:apply-templates select="SCHEMA_OBJ"/>
<!-- The DATA_LAYER_NOT_NETWORK parameter signifies that we are converting an
STRMTABLE doc. In these cases we need to set the appropriate
STREAM VERSIONs. This is only set by datapump data layer when
evaluating col_list differences between source and target during imports.
-->
<xsl:if test="$DATA_LAYER_NOT_NETWORK=1">
<xsl:choose>
<!-- For sxml document of the current table, set stream metadata version
to 1.2 (first valid version that supports field, base_col_name) -->
<xsl:when test="local-name(.)='TABLE_T'">
<xsl:element name="STREAM_MAJOR_VERSION">
<xsl:text>1</xsl:text>
</xsl:element>
<xsl:element name="STREAM_MINOR_VERSION">
<xsl:text>2</xsl:text>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<!-- Extract the stream version from the stream metadata document -->
<xsl:element name="STREAM_MAJOR_VERSION">
<xsl:value-of select="VERS_MAJOR"/>
</xsl:element>
<xsl:element name="STREAM_MINOR_VERSION">
<xsl:value-of select="VERS_MINOR"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:choose>
<xsl:when test="(PROPERTY mod 2)=1">
<!-- object or XMLType table -->
<xsl:choose>
<xsl:when test="COL_LIST/COL_LIST_ITEM[NAME='SYS_NC_ROWINFO$']/TYPEMD/SCHEMA_OBJ/NAME='XMLTYPE'
or
COL_LIST/COL_LIST_ITEM[NAME='SYS_NC_ROWINFO$']/TYPEMD/NAME='XMLTYPE'">
<xsl:element name="XMLTYPE_TABLE">
<xsl:call-template name="CreObjTable"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="OBJECT_TABLE">
<xsl:call-template name="CreObjTable"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:element name="RELATIONAL_TABLE">
<xsl:call-template name="CreRelTable"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="(string(ROWCNT) and not ($STATISTICS=0))">
<xsl:element name="STATISTICS">
<xsl:call-template name="CreTblStats"/>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:template>
<xsl:template name="CreTblStats">
<!-- *******************************************************************
Template: CreTblStats - processing table stats
Current node: TABLE_T
Emit the following:
ROWCNT
BLKCNT
EMPCNT
AVGSPC
CHNCNT
AVGRLN
AVGSPC_FLB
FLBCNT
ANALYZETIME
SAMPLESIZE
INTCOLS
KERNELCOLS
PROPERTY
PROPERTY2
XMLSCHEMACOLS
TRIGFLAG
SPARE1
SPARE6
******************************************************************** -->
<xsl:element name="ROWCNT">
<xsl:value-of select="ROWCNT"/>
</xsl:element>
<xsl:element name="BLKCNT">
<xsl:value-of select="BLKCNT"/>
</xsl:element>
<xsl:element name="EMPCNT">
<xsl:value-of select="EMPCNT"/>
</xsl:element>
<xsl:element name="AVGSPC">
<xsl:value-of select="AVGSPC"/>
</xsl:element>
<xsl:element name="CHNCNT">
<xsl:value-of select="CHNCNT"/>
</xsl:element>
<xsl:element name="AVGRLN">
<xsl:value-of select="AVGRLN"/>
</xsl:element>
<xsl:element name="AVGSPC_FLB">
<xsl:value-of select="AVGSPC_FLB"/>
</xsl:element>
<xsl:element name="FLBCNT">
<xsl:value-of select="FLBCNT"/>
</xsl:element>
<xsl:element name="ANALYZETIME">
<xsl:value-of select="ANALYZETIME"/>
</xsl:element>
<xsl:element name="SAMPLESIZE">
<xsl:value-of select="SAMPLESIZE"/>
</xsl:element>
</xsl:template>
<xsl:template name="CreRelTable">
<!-- *******************************************************************
Template: CreRelTable - processing for relational tables
Current node: TABLE_T
Emit the following:
- column list
- constraints
- supplemental logging
- on commit
- physical properties (non-partitioned tables only)
- table properties
- column properties
- table partitioning
- CACHE
- parallel clause
- row dependencies
- row movement
******************************************************************** -->
<!-- List of top level (segcol=0) Unpacked Opaque columns -->
<xsl:variable name="Unpacked_Opaques" select="COL_LIST/COL_LIST_ITEM[
TYPEMD/ANYDATA_LIST/ANYDATA_LIST_ITEM]"/>
<!-- column list -->
<xsl:element name="COL_LIST">
<!-- If the differ specific CM_MODE parameter is set then make
a pass thru and sort all of the columns by name)
-->
<xsl:choose>
<xsl:when test="$CM_MODE=1">
<xsl:for-each select="COL_LIST/COL_LIST_ITEM[(PROPERTY mod 64)<32
or ((PROPERTY mod 512)<256 and (PROPERTY mod 131072)>= 65536)
or (PROPERTY mod 2097152)>=1048576
or ((PROPERTY mod 8388608)>=4194304 and
(PROPERTY2 mod 1024)<512)]">
<xsl:sort select="NAME" data-type="text" lang="en"/>
<xsl:element name="COL_LIST_ITEM">
<!-- Include column name as an attribute for diffing -->
<xsl:attribute name="NAME"><xsl:value-of select="NAME"/></xsl:attribute>
<!-- CM-specific COL_NUM element now added in kuscomm.xsl -->
<xsl:call-template name="ColumnDefinition"/>
</xsl:element>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<!--
bug 18556940: model this code after kucolumn.xsl
always exclude unused columns - prop bit 0x008000 32768
also exclude hidden columns - prop bit 0x000020 00032
(but do include RLS hidden column - prop bit 0x800000)
If it is not a row archival hidden column - prop2 bit 0x000200
and virtual columns that is not - prop bit 0x010000
system-generated column - prop bit 0x000100)
include user specified invisible cols - prop2 bit 0x000004)
-->
<xsl:variable name="ColSelList" select="COL_LIST/COL_LIST_ITEM[
(((PROPERTY mod 65536)<32768) and
((PROPERTY mod 64)<32 or not($HIDDEN_COLUMNS=0) or
(PROPERTY2 mod 8) =4 or
(PROPERTY mod 2097152) >= 1048576 or
((PROPERTY mod 8388608) >= 4194304 and
(PROPERTY2 mod 1024)<512) ))]"/>
<xsl:choose>
<!-- Bug 24822718: Sort with INTCOL_NUM when col list has invisible and
hidden column. Invisible column has zero value for
COL_NUM and to generate correct column order,
sort with INTCOL_NUM is needed.
-->
<xsl:when test="($ColSelList/PROPERTY mod 64) >= 32 and
($ColSelList/PROPERTY2 mod 8) >= 4">
<xsl:for-each select="$ColSelList">
<xsl:sort select="INTCOL_NUM" data-type="number"/>
<!-- Is this column part of an unpacked Opaque column? If so, then
a prefix of user column name is passed to the ColumnDefinition
routine -->
<xsl:variable name="Defining_col" select="COL_NUM"/>
<xsl:variable name="Base_name">
<xsl:choose>
<xsl:when test="BASE_COL_TYPE=5">
<xsl:for-each select="$Unpacked_Opaques[COL_NUM=$Defining_col]">
<xsl:value-of select="BASE_COL_NAME"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>""</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- If DATA_LAYER_NOT_NETWORK is set then datapump is transforming a STRMTABLE
doc and will result in an external table ready doc for datapump.
-->
<xsl:element name="COL_LIST_ITEM">
<xsl:call-template name="ColumnDefinition">
<xsl:with-param name="ExternalTable" select="$DATA_LAYER_NOT_NETWORK"/>
<xsl:with-param name="Prefix" select="$Base_name"/>
</xsl:call-template>
</xsl:element>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$ColSelList">
<!-- Is this column part of an unpacked Opaque column? If so, then
a prefix of user column name is passed to the ColumnDefinition
routine -->
<xsl:variable name="Defining_col" select="COL_NUM"/>
<xsl:variable name="Base_name">
<xsl:choose>
<xsl:when test="BASE_COL_TYPE=5">
<xsl:for-each select="$Unpacked_Opaques[COL_NUM=$Defining_col]">
<xsl:value-of select="BASE_COL_NAME"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>""</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- If DATA_LAYER_NOT_NETWORK is set then datapump is transforming a STRMTABLE
doc and will result in an external table ready doc for datapump.
-->
<xsl:element name="COL_LIST_ITEM">
<xsl:call-template name="ColumnDefinition">
<xsl:with-param name="ExternalTable" select="$DATA_LAYER_NOT_NETWORK"/>
<xsl:with-param name="Prefix" select="$Base_name"/>
</xsl:call-template>
</xsl:element>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<!-- constraints -->
<xsl:call-template name="TableConstraints"/>
<!-- Generate default collation name :
when version 12.2, higher and dflcollname exists -->
<xsl:if test="$VERSION>=1202000000 and SCHEMA_OBJ and
SCHEMA_OBJ/DFLCOLLNAME">
<xsl:element name="DEFAULT_COLLATION">
<xsl:value-of select="SCHEMA_OBJ/DFLCOLLNAME"/>
</xsl:element>
</xsl:if>
<!-- supplemental logging -->
<xsl:call-template name="SupplementalLogging"/>
<!-- valid-time temporal -->
<xsl:apply-templates select="FBA_PERIODS">
<xsl:with-param name="ColList" select="COL_LIST"/>
</xsl:apply-templates>
<xsl:choose>
<xsl:when test="(PROPERTY mod 8388608)>=4194304">
<!-- temporary table -->
<!-- on commit -->
<xsl:call-template name="OnCommit">
<xsl:with-param name="Property" select="PROPERTY"/>
</xsl:call-template>
<!-- table properties -->
<xsl:call-template name="TableProperties"/>
</xsl:when>
<xsl:otherwise>
<!-- physical properties (non-partitioned tables only or
clustered partition tables) -->
<xsl:if test="(PROPERTY mod 64)<32 or (PROPERTY mod 2048)>=1024">
<xsl:call-template name="TablePhysicalProperties">
<xsl:with-param name="PROPERTY" select="PROPERTY"/>
<xsl:with-param name="PROPERTY2" select="PROPERTY2"/>
</xsl:call-template>
</xsl:if>
<!-- table properties -->
<xsl:call-template name="TableProperties"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="OnCommit">
<xsl:param name="Property">0</xsl:param>
<!-- *******************************************************************
Template: OnCommit
Parameters:
Property - value of table PROPERTY
******************************************************************** -->
<xsl:if test="($Property mod 8388608)>=4194304">
<!-- temporary table -->
<xsl:element name="ON_COMMIT">
<xsl:choose>
<xsl:when test="($Property mod 16777216)>=8388608">
<xsl:text>PRESERVE</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>DELETE</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:if>
</xsl:template>
<xsl:template name="TableProperties">
<!-- *******************************************************************
Template: TableProperties
Current node: TABLE_T
Emit the following:
- column properties
- XMLType virtual columns
- clustering
- table partitioning
- CACHE
- parallel clause
- row dependencies
- row movement
******************************************************************** -->
<!-- See if TABLE_PROPERTIES can be skipped altogether.
The first 7 tests are reproduced from kustbphy.xsl.
and 32>(PROPERTY mod 64)]/OPQMD)
-->
<!-- object column [NOT] SUBSTITUTABLE AT ALL LEVELS or IS OF TYPE -->
<xsl:variable name="ObjCols" select="COL_LIST/COL_LIST_ITEM[
(TYPE_NUM=121)
and not (NAME='SYS_NC_ROWINFO$')
and (32768>(PROPERTY mod 65536))
and ((TYPEMD/FLAGS mod 4096)>= 2048 or
(TYPEMD/FLAGS mod 2048)>= 1024 or
(TYPEMD/SUBTYPE_LIST/SUBTYPE_LIST_ITEM/FLAGS mod 4)=3)]"/>
<xsl:variable name="NestedTableCols" select="COL_LIST/COL_LIST_ITEM[
(TYPE_NUM=122) and (32768>(PROPERTY mod 65536))]"/>
<!-- varray columns not system-generated but with collection storage -->
<xsl:variable name="VarrayCols" select="COL_LIST/COL_LIST_ITEM[(TYPE_NUM=123)
and (256>(PROPERTY mod 512))
and (32768>(PROPERTY mod 65536))
and (((TYPEMD/FLAGS mod 128)>=64) or
((TYPEMD/FLAGS mod 8)>=4))]"/>
<!-- lob columns that are not system-generated (PROPERTY bit 0x100 256) -->
<xsl:variable name="LobCols" select="COL_LIST/COL_LIST_ITEM[
(TYPE_NUM=112 or TYPE_NUM=113)
and (32768>(PROPERTY mod 65536))
and (256>(PROPERTY mod 512))]
and not ($SEGMENT_ATTRIBUTES=0)
and not ($PHYSICAL_PROPERTIES=0)
and not ($TABLESPACE=0)"/>
<!-- opaque columns stored as LOB -->
<xsl:variable name="OpaqueCols" select="COL_LIST/COL_LIST_ITEM[
(TYPE_NUM=58)
and (32768>(PROPERTY mod 65536))
and (256>(PROPERTY mod 512))
and not ((OPQMD/FLAGS mod 4)>=2)]/LOBMD"/>
<!-- schema-based XMLTYPE columns -->
<xsl:variable name="SBXmlTypeCols" select="COL_LIST/COL_LIST_ITEM[
(TYPE_NUM=58)
and not (NAME='SYS_NC_ROWINFO$')
and (32768>(PROPERTY mod 65536))
and (TYPEMD/SCHEMA_OBJ/OWNER_NAME='SYS')
and (TYPEMD/SCHEMA_OBJ/NAME='XMLTYPE')
and (OPQMD/SCHEMA_ELMT)]"/>
<xsl:variable name="Cache" select="(FLAGS mod 16)>=8"/>
<xsl:variable name="RowDependencies" select="(FLAGS mod 16777216)>=8388608"/>
<xsl:variable name="MovePartitionedRows" select="(FLAGS mod 262144)>=131072"/>
<xsl:variable name="RowArchival" select="(PROPERTY2 mod 65536) >= 32768"/>
<xsl:variable name="ResultCache" select="(PROPERTY2 mod 1024)>=512 or
(PROPERTY2 mod 2048)>=1024"/>
<xsl:if test="$ObjCols or
$NestedTableCols or
$VarrayCols or
$LobCols or
$OpaqueCols or
$SBXmlTypeCols or
$Cache or
$RowDependencies or
$MovePartitionedRows or
PART_OBJ or
DEGREE or
CLST or
FBA or
$RowArchival or
$ResultCache">
<!-- There are some table properties -->
<xsl:element name="TABLE_PROPERTIES">
<!-- Column properties -->
<xsl:call-template name="TableColumnProperties">
<xsl:with-param name="ColListParent" select="."/>
<xsl:with-param name="NTNode" select="NT"/>
<xsl:with-param name="TabBlocksize" select="BLOCKSIZE"/>
</xsl:call-template>
<!-- clustering -->
<xsl:apply-templates select="CLST"/>
<!-- table partitioning -->
<xsl:if test="PART_OBJ">
<xsl:call-template name="TablePartitioning">
<xsl:with-param name="PartobjNode" select="PART_OBJ"/>
<xsl:with-param name="PropertyNode" select="PROPERTY"/>
<xsl:with-param name="ColListNode" select="COL_LIST"/>
<xsl:with-param name="TabBlocksize" select="BLOCKSIZE"/>
<xsl:with-param name="TableNode" select="."/>
</xsl:call-template>
</xsl:if>
<!-- CACHE -->
<xsl:if test="(FLAGS mod 16)>=8">
<xsl:element name="CACHE"/>
</xsl:if>
<!-- Result_cache -->
<xsl:choose>
<xsl:when test="(PROPERTY2 mod 1024)>=512">
<xsl:element name="RESULT_CACHE">FORCE</xsl:element>
</xsl:when>
<xsl:when test="(PROPERTY2 mod 2048)>=1024">
<xsl:element name="RESULT_CACHE">MANUAL</xsl:element>
</xsl:when>
</xsl:choose>
<!-- Generate PARALLEL clause if not a clustered table -->
<xsl:if test="not((PROPERTY mod 2048)>=1024)">
<!-- parallel clause -->
<xsl:call-template name="ParallelClause">
<xsl:with-param name="ParentNode" select="."/>
</xsl:call-template>
<!-- row dependencies -->
<xsl:if test="(FLAGS mod 16777216)>=8388608">
<xsl:element name="ROW_DEPENDENCIES"/>
</xsl:if>
</xsl:if>
<!-- row movement -->
<xsl:if test="(FLAGS mod 262144)>=131072">
<xsl:element name="ROW_MOVEMENT"/>
</xsl:if>
<!-- flashback archive -->
<xsl:apply-templates select="FBA"/>
<!-- ROW ARCHIVAL -->
<xsl:call-template name="DoILMClause"/>
</xsl:element>
</xsl:if>
</xsl:template>
<xsl:template match="FBA">
<!-- *******************************************************************
Template: FBA - for flashback archive enabled tables
******************************************************************** -->
<xsl:element name="FLASHBACK_ARCHIVE">
<xsl:value-of select="FA_NAME"/>
</xsl:element>
</xsl:template>
<xsl:template name="CreObjTable">
<!-- *******************************************************************
Template: CreObjTable - processing for object and XMLType tables
Current node: TABLE_T
Emit the following:
- OF_TYPE
- object table substitution (object tables only)
- column defaults
- constraints
- supplemental logging
- XMLType storage (XMLType tables only)
- XMLSchema spec (XMLType tables only)
- on commit
- OID clause
- OID index clause
- physical properties
- table properties
******************************************************************** -->
<!-- there is only one column named SYS_NC_ROWINFO$
and it contains the type metadata -->
<xsl:for-each select="COL_LIST/COL_LIST_ITEM[NAME='SYS_NC_ROWINFO$']/TYPEMD">
<!-- OF_TYPE -->
<xsl:element name="OF_TYPE">
<xsl:choose>
<xsl:when test="SYN_NAME">
<xsl:if test="SYN_OWNER">
<xsl:element name="SCHEMA">
<xsl:value-of select="SYN_OWNER"/>
</xsl:element>
</xsl:if>
<xsl:element name="NAME">
<xsl:value-of select="SYN_NAME"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="SCHEMA_OBJ"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<!-- object table substitution -->
<xsl:choose>
<!-- 0x800 - SUBSTITUTABLE specified explicitly -->
<xsl:when test="(FLAGS mod 4096)>= 2048">
<xsl:element name="SUBSTITUTABLE">Y</xsl:element>
</xsl:when>
<!-- 0x400 - NOT SUBSTITUTABLE specified explicitly -->
<xsl:when test="(FLAGS mod 2048)>=1024">
<xsl:element name="SUBSTITUTABLE">N</xsl:element>
</xsl:when>
</xsl:choose>
</xsl:for-each>
<!-- column defaults -->
<xsl:if test="(COL_LIST/COL_LIST_ITEM[(DEFLENGTH!=0 or ($HIDDEN_COLUMNS=1))
and (($HIDDEN_COLUMNS=1) or (32 > (PROPERTY mod 64)))
and (1024 > (PROPERTY mod 1024))]) or
(COL_LIST/COL_LIST_ITEM[CON/CONTYPE='7' or CON/CONTYPE='11'])">
<xsl:element name="OBJECT_COLUMN_PROPERTIES">
<xsl:element name="COL_LIST">
<xsl:for-each select="(COL_LIST/COL_LIST_ITEM[(
(DEFLENGTH != 0 or ($HIDDEN_COLUMNS=1)) and
(($HIDDEN_COLUMNS=1) or (32 > (PROPERTY mod 64)))
and (1024 > (PROPERTY mod 1024))) or
(CON/CONTYPE='7' or CON/CONTYPE='11')])">
<xsl:element name="COL_LIST_ITEM">
<xsl:element name="NAME">
<xsl:choose>
<xsl:when test="$HIDDEN_COLUMNS=0">
<xsl:value-of select="NAME"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<!-- Append suffix,'.NESTED_TABLE_SETID$'. The purpose is to create
a unique name for this column in case the document will be diff'ed
-->
<xsl:when test="((PROPERTY mod 2048)>=1024) and BASE_COL_NAME and
($STREAMD_VERSION >= 2)">
<xsl:value-of select="concat(BASE_COL_NAME,'.NESTED_TABLE_SETID$')"/>
</xsl:when>
<xsl:when test="((PROPERTY mod 2048)>=1024) and ATTRNAME and
($STREAMD_VERSION >= 2)">
<xsl:value-of select="concat(ATTRNAME,'.NESTED_TABLE_SETID$')"/>
</xsl:when>
<xsl:when test="ATTRNAME">
<xsl:value-of select="ATTRNAME"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="NAME"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<xsl:if test="DEFAULT_VAL or DEFAULT_VALC">
<xsl:element name="DEFAULT">
<!--either DEFAULT_VAL or DEFAULT_VALC will be present but not both-->
<xsl:apply-templates select="DEFAULT_VAL"/>
<xsl:apply-templates select="DEFAULT_VALC"/>
</xsl:element>
</xsl:if>
<xsl:if test="TYPE_NUM and (not($HIDDEN_COLUMNS=0))">
<xsl:apply-templates select="TYPE_NUM">
<xsl:with-param name="ParentNode" select="."/>
</xsl:apply-templates>
</xsl:if>
<xsl:if test="CON/CONTYPE='7' or CON/CONTYPE='11'">
<xsl:element name="NOT_NULL">
<xsl:if test="(CON/FLAGS mod 16)<8">
<NAME>
<xsl:value-of select="CON/NAME"/>
</NAME>
</xsl:if>
<xsl:call-template name="EnableDisable">
<xsl:with-param name="ConNode" select="CON"/>
</xsl:call-template>
</xsl:element>
</xsl:if>
<!--STRMTABLE transforms requested via datapump require additional
external table related information.
-->
<xsl:if test="$DATA_LAYER_NOT_NETWORK=1">
<xsl:if test="SEGCOL_NUM">
<xsl:element name="SEGCOL_NUM">
<xsl:value-of select="SEGCOL_NUM"/>
</xsl:element>
</xsl:if>
<xsl:if test="INTCOL_NUM">
<xsl:element name="INTCOL_NUM">
<xsl:value-of select="INTCOL_NUM"/>
</xsl:element>
<xsl:if test="(PROPERTY mod 131072)>=65536">
<xsl:element name="VIRTUAL"/>
</xsl:if>
</xsl:if>
<xsl:choose>
<xsl:when test="COL_SORTKEY">
<xsl:element name="COL_SORTKEY">
<xsl:value-of select="COL_SORTKEY"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="COL_SORTKEY">
<xsl:value-of select="SEGCOL_NUM"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="ATTRNAME or (PROPERTY mod 2048)>=1024">
<xsl:element name="INTERNAL_NAME">
<xsl:value-of select="NAME"/>
</xsl:element>
<xsl:if test="((PROPERTY mod 2048)>=1024)">
<xsl:element name="NESTED_TABLE_SETID"/>
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:if>
<!-- constraints -->
<xsl:call-template name="TableConstraints"/>
<!-- supplemental logging -->
<xsl:call-template name="SupplementalLogging"/>
<!-- Generate XMLType storage for schema/non-schema based binary xml -->
<xsl:if test="COL_LIST/COL_LIST_ITEM[NAME='SYS_NC_ROWINFO$']/OPQMD/SCHEMA_ELMT or
(COL_LIST/COL_LIST_ITEM[NAME='SYS_NC_ROWINFO$']/OPQMD/TYPE=1 and
COL_LIST/COL_LIST_ITEM[NAME='SYS_NC_ROWINFO$']/OPQMD/FLAGS mod 128 >=64)">
<!-- XMLType storage (XMLType tables only) -->
<!-- XML structure is
COL_LIST
COL_LIST_ITEM (ku$_column_t)
LOBMD (ku$_lob_t - null if not lob)
OPQMD (ku$_opqtype_t - null if not opaque)
SCHEMA_ELMT (ku$_xmlschema_elmt_t)
-->
<xsl:call-template name="XMLTypeStorage">
<xsl:with-param name="ColNode" select="COL_LIST/COL_LIST_ITEM[NAME='SYS_NC_ROWINFO$']"/>
<xsl:with-param name="TabBlocksize" select="BLOCKSIZE"/>
</xsl:call-template>
<!-- XMLSchema spec (Schema base XMLType tables only) -->
<xsl:choose>
<xsl:when test="COL_LIST/COL_LIST_ITEM[NAME='SYS_NC_ROWINFO$']/OPQMD/SCHEMA_ELMT">
<xsl:call-template name="XMLSchemaSpec">
<xsl:with-param name="ColNode" select="COL_LIST/COL_LIST_ITEM[NAME='SYS_NC_ROWINFO$']"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="XMLTypeAllowDisallow">
<xsl:with-param name="ColNode" select="COL_LIST/COL_LIST_ITEM[NAME='SYS_NC_ROWINFO$']"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="XMLTypeVirtualColumns">
<xsl:with-param name="VirtualCols" select="COL_LIST/COL_LIST_ITEM[(PROPERTY mod 16 >= 8) and
(PROPERTY mod 64 >= 32) and
(PROPERTY mod 131052 >= 65536) and
(256 > (PROPERTY mod 512)) and
(512 > (PROPERTY mod 1024)) and
(16384 > (PROPERTY mod 32768))]"/>
</xsl:call-template>
</xsl:if>
<!-- on commit -->
<xsl:if test="(PROPERTY mod 8388608)>=4194304">
<!-- temporary table -->
<xsl:call-template name="OnCommit">
<xsl:with-param name="Property" select="PROPERTY"/>
</xsl:call-template>
</xsl:if>
<!-- OID clause -->
<xsl:choose>
<!-- User requested -->
<xsl:when test="$OID!=1">
<xsl:element name="OID">
<xsl:value-of select="SCHEMA_OBJ/OID"/>
</xsl:element>
</xsl:when>
<xsl:when test="CON1_LIST/CON1_LIST_ITEM[CONTYPE='2']">
<xsl:element name="OID">
<xsl:choose>
<!-- has primary-key OID -->
<xsl:when test="(PROPERTY mod 8192)>=4096">PRIMARY_KEY</xsl:when>
<!-- ???? can we do this along with OID index ??? -->
<xsl:otherwise>SYSTEM_GENERATED</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:when>
</xsl:choose>
<!--xsl:if test="$VERSION>=1202000000 and DEFERRED_STG">
<xsl:call-template name="DeferredSegmentCreationClause">
<xsl:with-param name="TableNode" select="."/>
</xsl:call-template>
</xsl:if-->
<!-- OID index clause (not for [non] schema-based XMLType tables -->
<xsl:if test="COL_LIST/COL_LIST_ITEM/OIDINDEX
and not
((COL_LIST/COL_LIST_ITEM[NAME='SYS_NC_ROWINFO$']/OPQMD and
COL_LIST/COL_LIST_ITEM[NAME='SYS_NC_ROWINFO$']/OPQMD/SCHEMA_ELMT) or
(COL_LIST/COL_LIST_ITEM[NAME='SYS_NC_ROWINFO$']/OPQMD/TYPE=1 and
COL_LIST/COL_LIST_ITEM[NAME='SYS_NC_ROWINFO$']/OPQMD/FLAGS mod 128 >=64))">
<xsl:call-template name="OidIndex">
<xsl:with-param name="ColNode" select="COL_LIST/COL_LIST_ITEM[OIDINDEX]"/>
<xsl:with-param name="TabProperty" select="PROPERTY"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="4194304>(PROPERTY mod 8388608)">
<!-- not temporary table -->
<!-- physical properties (non-partitioned or clustered tables)-->
<xsl:if test="(PROPERTY mod 64)<32 or (PROPERTY mod 2048)>=1024">
<xsl:call-template name="TablePhysicalProperties">
<xsl:with-param name="PROPERTY" select="PROPERTY"/>
</xsl:call-template>
</xsl:if>
</xsl:if>
<!-- table properties -->
<xsl:call-template name="TableProperties"/>
</xsl:template>
<xsl:template name="OidIndex">
<xsl:param name="ColNode" select="''"/>
<xsl:param name="TabProperty">0</xsl:param>
<!-- *******************************************************************
Template: OidIndex
Parameters:
ColNode - COL_LIST_ITEM node with OIDINDEX child
TabProperty - value of TABLE_T/PROPERTY
******************************************************************** -->
<xsl:if test="not ($SEGMENT_ATTRIBUTES=0) and not ($PHYSICAL_PROPERTIES=0)">
<!-- emit OIDINDEX if either (1) not a temporary table or
(2) name not system-generated -->
<xsl:if test="4194304>(PROPERTY mod 8388608) or
(($ColNode/OIDINDEX/FLAGS mod 16) < 8)">
<xsl:element name="OIDINDEX">
<!-- put out name if not system-generated -->
<xsl:if test="($ColNode/OIDINDEX/FLAGS mod 16) < 8">
<xsl:call-template name="ColName">
<xsl:with-param name="ColNode" select="$ColNode/OIDINDEX"/>
</xsl:call-template>
</xsl:if>
<!-- put out physical attributes and tablespace if not temporary table -->
<xsl:if test="($TabProperty mod 8388608) < 4194304">
<xsl:call-template name="PhysicalAttributes">
<xsl:with-param name="ParentNode" select="$ColNode/OIDINDEX"/>
<xsl:with-param name="Partitioned" select="0"/>
<xsl:with-param name="ObjType">TABLE</xsl:with-param>
<xsl:with-param name="TableNode" select="."/>
<xsl:with-param name="OIDIndex">1</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="Tablespace">
<xsl:with-param name="ParentNode" select="$ColNode/OIDINDEX"/>
</xsl:call-template>
</xsl:if>
</xsl:element>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template match="FBA_PERIODS">
<xsl:param name="ColList" select="''"/>
<!-- *******************************************************************
Template: FBA_PERIODS
******************************************************************** -->
<xsl:if test="FBA_PERIODS_ITEM">
<xsl:element name="PERIOD_LIST">
<xsl:for-each select="FBA_PERIODS_ITEM">
<xsl:element name="PERIOD_LIST_ITEM">
<xsl:element name="VALID_TIME_COLUMN">
<xsl:value-of select="PERIODNAME"/>
</xsl:element>
<!-- do not emit column names if hidden -->
<xsl:variable name="PeriodStartName" select="PERIODSTART"/>
<xsl:if test="string-length($ColList)!=0 and ($ColList/COL_LIST_ITEM[NAME=$PeriodStartName]/PROPERTY mod 64) < 32">
<xsl:element name="START_TIME_COLUMN">
<xsl:value-of select="PERIODSTART"/>
</xsl:element>
<xsl:element name="END_TIME_COLUMN">
<xsl:value-of select="PERIODEND"/>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
OHA YOOOO