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

  1. #NAME#
  2. DA_DB2udbTableColumnData
  3. #DESCRIPTION#
  4. The DB2 UDB table column data glossary query returns the names of DB2 UDB tables which contain a column which matches the data characteristics specified in the WHERE clause.
  5.  
  6. A column in a DB2 UDB 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 UDB 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:  DAQDB2csTable
  11.  
  12. Modifications:
  13. Change the search criteria of the data characteristic attributes in the SQL WHERE clause.  The view type contains two sets of attributes which describe the data characteristics of the column.  
  14. For example, either e.typeCode or c.localDataTypeCode will contain the data type code for the column depending upon whether the column uses a Shareable Data Element or is locally defined.  Each of the following attributes may be referenced either as shareable or local:
  15. --typeCode
  16.     Possible values are:
  17.        0  Fixed binary
  18.        1  Packed decimal
  19.        2  Zoned decimal
  20.        3  Binary floating point
  21.        4  Decimal (or external) floating point
  22.        5  Bit string
  23.        6  Character string
  24.        7  DBCS (or graphic) string
  25.        8  Mixed SBCS/DBCS string
  26.        9  Date
  27.       10  Time
  28.       11  Timestamp
  29.       12  Index
  30.       13  Undefined
  31.       14  Rowid (Oracle)
  32.       15  MLSLable (Oracle)
  33. --stringLength
  34.     The data length for string data types: bit string in bits, character 
  35.     string in bytes, DBCS or graphic string in double bytes, and mixed
  36.     SBCS/DBCS string in bytes.
  37. --numericPrecision
  38.     The data length for numeric data types: fixed binary in bits, packed
  39.     decimal in digits, zoned decimal in digits, binary floating point in
  40.     bits, and decimal floating point in digits of the mantissa.
  41. --scale
  42.     The position of the decimal point for numeric data types in digits.
  43. --asBitData
  44.     A boolean value indicating whether the character string is treated
  45.     as bit (binary) data.
  46. --stringVaryingCode
  47.     A value indicating whether the string is of fixed length (1) or
  48.     variable length (2).
  49. --isLOB
  50.     A boolean value indicating whether the character string is a large object.
  51. #MODIFIED#
  52.  
  53. #VERSION#
  54.  
  55. #SQL STATEMENT#
  56. --DA_DB2udbTableColumnData
  57. SELECT
  58. -- column uses Shareable Data Element
  59.   t.db2csTable,
  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.   DAQDB2csTable 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.db2csTable,
  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.   DAQDB2csTable 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.db2csTable,
  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.   DAQDB2csTable 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.db2csTable,
  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.   DAQDB2csTable 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.