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

  1. #NAME#
  2. DA_DB2390TableColumnData
  3. #DESCRIPTION#
  4. The DB2/390 table column data glossary query returns the names of DB2/390 tables which contain a column which matches the data characteristics specified in the WHERE clause.
  5.  
  6. A column in a DB2/390 table 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 DB2/390 tables 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:  DAQDB2390Table
  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.db2390Table,
  60.   td.tableDefinition,
  61.   td.columnName,
  62.   'Data Element' as sourceType,
  63.   e.dataElement as dataSource,
  64.   e.typeCode as typeCode,
  65.   e.stringLength as stringLength,
  66.   e.stringVaryingCode as stringVaryingCode,
  67.   e.asBitData as asBitData,
  68.   e.isLOB as isLOB,
  69.   e.numericPrecision as numericPrecision,
  70.   e.scale as numericScale
  71. FROM
  72.   DAQDB2390Table t,
  73.   (t.usesTableDefinition) td,
  74.   (td.usesDataElement) e
  75. WHERE
  76.   e.typeCode=6 AND
  77.   e.stringLength<20 AND
  78.   td.columnName <> ''
  79. UNION
  80. SELECT
  81. -- column is defined by primary table column
  82. -- primary table column uses a Shareable Data Element
  83.   t.db2390Table,
  84.   td.tableDefinition,
  85.   td.columnName,
  86.   'Primary Table: Data Element' as sourceType,
  87.   e.dataElement as dataSource,
  88.   e.typeCode as typeCode,
  89.   e.stringLength as stringLength,
  90.   e.stringVaryingCode as stringVaryingCode,
  91.   e.asBitData as asBitData,
  92.   e.isLOB as isLOB,
  93.   e.numericPrecision as numericPrecision,
  94.   e.scale as numericScale
  95. FROM
  96.   DAQDB2390Table t,
  97.   (t.usesTableDefinition) td,
  98.   (td.inSourceTableDefinition) pt,
  99.   (pt.usesDataElement) e  
  100. WHERE
  101.   (e.typeCode=6 AND
  102.    e.stringLength<20) AND
  103.   (td.definedByColumnName=pt.columnName)
  104. UNION
  105. SELECT
  106. -- column is defined by primary table column
  107. -- primary table column is locally defined
  108.   t.db2390Table,
  109.   td.tableDefinition,
  110.   td.columnName,
  111.   'Primary Table: local' as sourceType,    
  112.   ' ' as dataSource,
  113.   pt.localDataTypeCode as typeCode,
  114.   pt.localStringLength as stringLength,
  115.   pt.localStringVaryingFlag as stringVaryingCode,
  116.   pt.localAsBitData as asBitData,
  117.   pt.localIsLOB as isLOB,
  118.   pt.localNumericPrecision as numericPrecision,
  119.   pt.localDecimalScale as numericScale
  120. FROM
  121.   DAQDB2390Table t,
  122.   (t.usesTableDefinition) td,
  123.   (td.inSourceTableDefinition) pt
  124. WHERE
  125.   (pt.localDataTypeCode=6 AND
  126.   pt.localStringLength<20) AND
  127.   (td.definedByColumnName=pt.columnName)
  128. UNION
  129. SELECT
  130. -- column is locally defined
  131.   t.db2390Table,
  132.   td.tableDefinition,
  133.   td.columnName,
  134.   'local' as sourceType,
  135.   '' as dataSource,
  136.   td.localDataTypeCode as typeCode,
  137.   td.localStringLength as stringLength,
  138.   td.localStringVaryingFlag as stringVaryingCode,
  139.   td.localAsBitData as asBitData,
  140.   td.localIsLOB as isLOB,
  141.   td.localNumericPrecision as numericPrecision,
  142.   td.localDecimalScale as numericScale
  143. FROM
  144.   DAQDB2390Table t,
  145.   (t.usesTableDefinition) td
  146. WHERE
  147.   td.localDataTypeCode=6 AND
  148.   td.localStringLength<20 AND
  149.   td.columnName <> ''
  150. ORDER BY
  151.   1 ASC,
  152.   3 ASC;
  153.