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

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