home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / datatl25.zip / DCTDSGN.Z / EWSQTDCD.QRY < prev    next >
Text File  |  1997-09-11  |  5KB  |  145 lines

  1. #NAME#
  2. DA_TableDefinitionColumnData
  3. #DESCRIPTION#
  4. The table definition column data glossary query returns the names of Shareable Table Definitions which contain a column which matches the data characteristics specified in the WHERE clause.
  5.  
  6. A column in a Shareable Table Definitions may use a Shareable Data Element to specify its data characteristics, the characteristics may be specified locally, or it may inherit the data characteristics of the matching column in a parent table if the column participates in a foreign key.
  7.  
  8. In order to locate all Shareable Table Definitions which contain a column with certain characteristics, the query must include the attributes which define the column using a Shareable Data Element, defined locally  or via the parent table.
  9.  
  10. View type:  DAQTableDefinition
  11.  
  12. Modifications:
  13. The query uses a SQL UNION clause to provide a more compact result table.  
  14.  
  15. Change the search criteria of the data characteristic attributes in the SQL WHERE clause for each subselect.
  16.  
  17. Each of the following attributes may be referenced either as shareable or local:
  18. --typeCode
  19.     Possible values are:
  20.        0  Fixed binary
  21.        1  Packed decimal
  22.        2  Zoned decimal
  23.        3  Binary floating point
  24.        4  Decimal (or external) floating point
  25.        5  Bit string
  26.        6  Character string
  27.        7  DBCS (or graphic) string
  28.        8  Mixed SBCS/DBCS string
  29.        9  Date
  30.       10  Time
  31.       11  Timestamp
  32.       12  Index
  33.       13  Undefined
  34.       14  Rowid (Oracle)
  35.       15  MLSLable (Oracle)
  36. --stringLength
  37.     The data length for string data types: Bit string in bits, Character 
  38.     string in bytes, DBCS or graphic string in double bytes, and mixed
  39.     SBCS/DBCS string in bytes.
  40. --numericPrecision
  41.     The data length for numeric data types: Fixed binary in bits, Packed
  42.     decimal in digits, zoned decimal in digits, binary floating point in
  43.     bits, and decimal floating point in digits of the mantissa.
  44. --scale
  45.     The position of the decimal point for numeric data types in digits.
  46. --asBitData
  47.     A boolean value indicating whether the character string is treated
  48.     as bit (binary) data.
  49. --stringVaryingCode
  50.     A value indicating whether the string is of fixed length (1) or
  51.     variable length (2).
  52. #MODIFIED#
  53.  
  54. #VERSION#
  55.  
  56. #SQL STATEMENT#
  57. SELECT
  58. -- column uses Shareable Data Element
  59.   t.tableDefinition,
  60.   t.columnName,
  61.   'Data Element' as sourceType,
  62.   e.dataElement as dataSource,
  63.   e.typeCode as typeCode,
  64.   e.stringLength as stringLength,
  65.   e.stringVaryingCode as stringVaryingCode,
  66.   e.asBitData as asBitData,
  67.   e.isLOB as isLOB,
  68.   e.numericPrecision as numericPrecision,
  69.   e.scale as numericScale
  70. FROM
  71.   DAQTableDefinition t,
  72.   (t.usesDataElement) e
  73. WHERE
  74.   e.typeCode=6 AND
  75.   e.stringLength<20 AND
  76.   t.columnName <> ''
  77. UNION
  78. SELECT
  79. -- column is defined by primary table column
  80. -- primary table column uses a Shareable Data Element
  81.   t.tableDefinition,
  82.   t.columnName,
  83.   'Primary Table Data Element' as sourceType,
  84.   e.dataElement as dataSource,
  85.   e.typeCode as typeCode,
  86.   e.stringLength as stringLength,
  87.   e.stringVaryingCode as stringVaryingCode,
  88.   e.asBitData as asBitData,
  89.   e.isLOB as isLOB,
  90.   e.numericPrecision as numericPrecision,
  91.   e.scale as numericScale
  92. FROM
  93.   DAQTableDefinition t,
  94.   (t.inSourceTableDefinition) pt,
  95.   (pt.usesDataElement) e  
  96. WHERE
  97.   (e.typeCode=6 AND
  98.    e.stringLength<20) AND
  99.   (t.definedByColumnName=pt.columnName)
  100. UNION
  101. SELECT
  102. -- column is defined by primary table column
  103. -- primary table column is locally defined
  104.   t.tableDefinition,
  105.   t.columnName,
  106.   'Primary Table: local' as sourceType,    
  107.   ' ' as dataSource,
  108.   pt.localDataTypeCode as typeCode,
  109.   pt.localStringLength as stringLength,
  110.   pt.localStringVaryingFlag as stringVaryingCode,
  111.   pt.localAsBitData as asBitData,
  112.   pt.localIsLOB as isLOB,
  113.   pt.localNumericPrecision as numericPrecision,
  114.   pt.localDecimalScale as numericScale
  115. FROM
  116.   DAQTableDefinition t,
  117.   (t.inSourceTableDefinition) pt
  118. WHERE
  119.   (pt.localDataTypeCode=6 AND
  120.   pt.localStringLength<20) AND
  121.   (t.definedByColumnName=pt.columnName)
  122. UNION
  123. SELECT
  124. -- column is locally defined
  125.   t.tableDefinition,
  126.   t.columnName,
  127.   'local' as sourceType,
  128.   '' as dataSource,
  129.   t.localDataTypeCode as typeCode,
  130.   t.localStringLength as stringLength,
  131.   t.localStringVaryingFlag as stringVaryingCode,
  132.   t.localAsBitData as asBitData,
  133.   t.localIsLOB as isLOB,
  134.   t.localNumericPrecision as numericPrecision,
  135.   t.localDecimalScale as numericScale
  136. FROM
  137.   DAQTableDefinition t  
  138. WHERE
  139.   t.localDataTypeCode=6 AND
  140.   t.localStringLength<20 AND
  141.   t.columnName <> ''
  142. ORDER BY
  143.   1 ASC,
  144.   2 ASC;
  145.