|
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
using Harlinn.Oracle.DBTool.Types.Common;
using System.ComponentModel;
using Harlinn.Oracle.DBTool.Utils.DB;
namespace Harlinn.Oracle.DBTool.Types.Database
{
public class DBField : DBElement
{
private static readonly log4net.ILog sfLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private static void LogException(Exception exc, System.Reflection.MethodBase method)
{
Logger.LogException(sfLog, exc, method);
}
int ordinal;
long size;
short? numericPrecision;
short? numericScale;
bool isUnique;
bool isKey;
bool isRowID;
string baseColumnName;
string baseSchemaName;
string baseTableName;
Type dotNetdataType;
OracleDbType providerType;
bool allowDBNull;
bool isAliased;
bool isByteSemantic;
bool isExpression;
bool isHidden;
bool isReadOnly;
bool isLong;
string udtTypeName;
private string owner;
private string tableName;
private string columnName;
private string dataType;
private string dataTypeMod;
private string dataTypeOwner;
private decimal dataLength;
private decimal? dataPrecision;
private decimal? dataScale;
private string nullable;
private decimal? columnId;
private decimal? defaultLength;
private object dataDefault;
private decimal? numDistinct;
private object lowValue;
private object highValue;
private decimal? density;
private decimal? numNulls;
private decimal? numBuckets;
private DateTime? lastAnalyzed;
private decimal? sampleSize;
private string characterSetName;
private decimal? charColDeclLength;
private string globalStats;
private string userStats;
private decimal? avgColLen;
private decimal? charLength;
private string charUsed;
private string v80FmtImage;
private string dataUpgraded;
private string histogram;
private string comments;
public DBField()
{
}
public DBField(DBFields parent, DataRow fieldDefinition)
: base(parent, GetFieldName(fieldDefinition))
{
try
{
ordinal = Convert.ToInt32(fieldDefinition[1]);
size = Convert.ToInt64(fieldDefinition[2]);
if (fieldDefinition.IsNull(3) == false)
{
numericPrecision = Convert.ToInt16(fieldDefinition[3]);
}
if (fieldDefinition.IsNull(4) == false)
{
numericScale = Convert.ToInt16(fieldDefinition[4]);
}
isUnique = Convert.ToBoolean(fieldDefinition[5]);
isKey = Convert.ToBoolean(fieldDefinition[6]);
isRowID = Convert.ToBoolean(fieldDefinition[7]);
baseColumnName = fieldDefinition[8].ToString();
baseSchemaName = fieldDefinition[9].ToString();
baseTableName = fieldDefinition[10].ToString();
dotNetdataType = fieldDefinition[11] as Type;
providerType = (OracleDbType)Convert.ToInt32(fieldDefinition[12]);
allowDBNull = Convert.ToBoolean(fieldDefinition[13]);
isAliased = Convert.ToBoolean(fieldDefinition[14]);
if (fieldDefinition.IsNull(15) == false)
{
isByteSemantic = Convert.ToBoolean(fieldDefinition[15]);
}
isExpression = Convert.ToBoolean(fieldDefinition[16]);
isHidden = Convert.ToBoolean(fieldDefinition[17]);
isReadOnly = Convert.ToBoolean(fieldDefinition[18]);
isLong = Convert.ToBoolean(fieldDefinition[19]);
if (fieldDefinition.IsNull(20) == false)
{
udtTypeName = fieldDefinition[20].ToString();
}
ColumnReader columnReader = ColumnReader.CreateReader(baseSchemaName, baseTableName, baseColumnName);
using (columnReader)
{
if (columnReader.Read())
{
Owner = columnReader.Owner;
TableName = columnReader.TableName;
ColumnName = columnReader.ColumnName;
DataType = columnReader.DataType;
DataTypeMod = columnReader.DataTypeMod;
DataTypeOwner = columnReader.DataTypeOwner;
DataLength = columnReader.DataLength;
DataPrecision = columnReader.DataPrecision;
DataScale = columnReader.DataScale;
Nullable = columnReader.Nullable;
ColumnId = columnReader.ColumnId;
DefaultLength = columnReader.DefaultLength;
DataDefault = columnReader.DataDefault;
NumDistinct = columnReader.NumDistinct;
LowValue = columnReader.LowValue;
HighValue = columnReader.HighValue;
Density = columnReader.Density;
NumNulls = columnReader.NumNulls;
NumBuckets = columnReader.NumBuckets;
LastAnalyzed = columnReader.LastAnalyzed;
SampleSize = columnReader.SampleSize;
CharacterSetName = columnReader.CharacterSetName;
CharColDeclLength = columnReader.CharColDeclLength;
GlobalStats = columnReader.GlobalStats;
UserStats = columnReader.UserStats;
AvgColLen = columnReader.AvgColLen;
CharLength = columnReader.CharLength;
CharUsed = columnReader.CharUsed;
V80FmtImage = columnReader.V80FmtImage;
DataUpgraded = columnReader.DataUpgraded;
Histogram = columnReader.Histogram;
}
}
ColumnCommentReader columnCommentReader = ColumnCommentReader.CreateReader(baseSchemaName, baseTableName, baseColumnName);
using (columnCommentReader)
{
if (columnCommentReader.Read())
{
comments = columnCommentReader.Comments;
}
}
}
catch (Exception exc)
{
LogException(exc, System.Reflection.MethodBase.GetCurrentMethod());
}
}
[Browsable(false)]
public DBFields Fields
{
get
{
DBFields result = (DBFields)Parent;
return result;
}
}
private static string GetFieldName(DataRow fieldDefinition)
{
return fieldDefinition[0].ToString();
}
public override DBElementType ElementType
{
get
{
return DBElementType.Field;
}
}
[Category(".Net Driver")]
public int Ordinal
{
get
{
return ordinal;
}
set
{
if (ordinal == value)
return;
ordinal = value;
}
}
[Category(".Net Driver")]
public long Size
{
get
{
return size;
}
set
{
if (size == value)
return;
size = value;
}
}
[Category(".Net Driver")]
public short? NumericPrecision
{
get
{
return numericPrecision;
}
set
{
if (numericPrecision == value)
return;
numericPrecision = value;
}
}
[Category(".Net Driver")]
public short? NumericScale
{
get
{
return numericScale;
}
set
{
if (numericScale == value)
return;
numericScale = value;
}
}
[Category(".Net Driver")]
public bool IsUnique
{
get
{
return isUnique;
}
set
{
if (isUnique == value)
return;
isUnique = value;
}
}
[Category(".Net Driver")]
public bool IsKey
{
get
{
return isKey;
}
set
{
if (isKey == value)
return;
isKey = value;
}
}
[Category(".Net Driver")]
public bool IsRowID
{
get
{
return isRowID;
}
set
{
if (isRowID == value)
return;
isRowID = value;
}
}
[Category(".Net Driver")]
public string BaseColumnName
{
get
{
return baseColumnName;
}
set
{
if (baseColumnName == value)
return;
baseColumnName = value;
}
}
[Category(".Net Driver")]
public string BaseSchemaName
{
get
{
return baseSchemaName;
}
set
{
if (baseSchemaName == value)
return;
baseSchemaName = value;
}
}
[Category(".Net Driver")]
public string BaseTableName
{
get
{
return baseTableName;
}
set
{
if (baseTableName == value)
return;
baseTableName = value;
}
}
[Category(".Net Driver")]
public Type DotNetDataType
{
get
{
return dotNetdataType;
}
set
{
if (dotNetdataType == value)
return;
dotNetdataType = value;
}
}
[Category(".Net Driver")]
public OracleDbType ProviderType
{
get
{
return providerType;
}
set
{
if (providerType == value)
return;
providerType = value;
}
}
[Category(".Net Driver")]
public bool AllowDBNull
{
get
{
return allowDBNull;
}
set
{
if (allowDBNull == value)
return;
allowDBNull = value;
}
}
[Category(".Net Driver")]
public bool IsAliased
{
get
{
return isAliased;
}
set
{
if (isAliased == value)
return;
isAliased = value;
}
}
[Category(".Net Driver")]
public bool IsByteSemantic
{
get
{
return isByteSemantic;
}
set
{
if (isByteSemantic == value)
return;
isByteSemantic = value;
}
}
[Category(".Net Driver")]
public bool IsExpression
{
get
{
return isExpression;
}
set
{
if (isExpression == value)
return;
isExpression = value;
}
}
[Category(".Net Driver")]
public bool IsHidden
{
get
{
return isHidden;
}
set
{
if (isHidden == value)
return;
isHidden = value;
}
}
[Category(".Net Driver")]
public bool IsReadOnly
{
get
{
return isReadOnly;
}
set
{
if (isReadOnly == value)
return;
isReadOnly = value;
}
}
[Category(".Net Driver")]
public bool IsLong
{
get
{
return isLong;
}
set
{
if (isLong == value)
return;
isLong = value;
}
}
[Category(".Net Driver")]
public string UdtTypeName
{
get
{
return udtTypeName;
}
set
{
if (udtTypeName == value)
return;
udtTypeName = value;
}
}
public string Owner
{
get
{
return owner;
}
set
{
if (owner == value)
return;
owner = value;
}
}
public string TableName
{
get
{
return tableName;
}
set
{
if (tableName == value)
return;
tableName = value;
}
}
public string ColumnName
{
get
{
return columnName;
}
set
{
if (columnName == value)
return;
columnName = value;
}
}
public string DataType
{
get
{
return dataType;
}
set
{
if (dataType == value)
return;
dataType = value;
}
}
public string DataTypeMod
{
get
{
return dataTypeMod;
}
set
{
if (dataTypeMod == value)
return;
dataTypeMod = value;
}
}
public string DataTypeOwner
{
get
{
return dataTypeOwner;
}
set
{
if (dataTypeOwner == value)
return;
dataTypeOwner = value;
}
}
public decimal DataLength
{
get
{
return dataLength;
}
set
{
if (dataLength == value)
return;
dataLength = value;
}
}
public decimal? DataPrecision
{
get
{
return dataPrecision;
}
set
{
if (dataPrecision == value)
return;
dataPrecision = value;
}
}
public decimal? DataScale
{
get
{
return dataScale;
}
set
{
if (dataScale == value)
return;
dataScale = value;
}
}
public string Nullable
{
get
{
return nullable;
}
set
{
if (nullable == value)
return;
nullable = value;
}
}
public decimal? ColumnId
{
get
{
return columnId;
}
set
{
if (columnId == value)
return;
columnId = value;
}
}
public decimal? DefaultLength
{
get
{
return defaultLength;
}
set
{
if (defaultLength == value)
return;
defaultLength = value;
}
}
public object DataDefault
{
get
{
return dataDefault;
}
set
{
if (dataDefault == value)
return;
dataDefault = value;
}
}
public decimal? NumDistinct
{
get
{
return numDistinct;
}
set
{
if (numDistinct == value)
return;
numDistinct = value;
}
}
public object LowValue
{
get
{
return lowValue;
}
set
{
if (lowValue == value)
return;
lowValue = value;
}
}
public object HighValue
{
get
{
return highValue;
}
set
{
if (highValue == value)
return;
highValue = value;
}
}
public decimal? Density
{
get
{
return density;
}
set
{
if (density == value)
return;
density = value;
}
}
public decimal? NumNulls
{
get
{
return numNulls;
}
set
{
if (numNulls == value)
return;
numNulls = value;
}
}
public decimal? NumBuckets
{
get
{
return numBuckets;
}
set
{
if (numBuckets == value)
return;
numBuckets = value;
}
}
public DateTime? LastAnalyzed
{
get
{
return lastAnalyzed;
}
set
{
if (lastAnalyzed == value)
return;
lastAnalyzed = value;
}
}
public decimal? SampleSize
{
get
{
return sampleSize;
}
set
{
if (sampleSize == value)
return;
sampleSize = value;
}
}
public string CharacterSetName
{
get
{
return characterSetName;
}
set
{
if (characterSetName == value)
return;
characterSetName = value;
}
}
public decimal? CharColDeclLength
{
get
{
return charColDeclLength;
}
set
{
if (charColDeclLength == value)
return;
charColDeclLength = value;
}
}
public string GlobalStats
{
get
{
return globalStats;
}
set
{
if (globalStats == value)
return;
globalStats = value;
}
}
public string UserStats
{
get
{
return userStats;
}
set
{
if (userStats == value)
return;
userStats = value;
}
}
public decimal? AvgColLen
{
get
{
return avgColLen;
}
set
{
if (avgColLen == value)
return;
avgColLen = value;
}
}
public decimal? CharLength
{
get
{
return charLength;
}
set
{
if (charLength == value)
return;
charLength = value;
}
}
public string CharUsed
{
get
{
return charUsed;
}
set
{
if (charUsed == value)
return;
charUsed = value;
}
}
public string V80FmtImage
{
get
{
return v80FmtImage;
}
set
{
if (v80FmtImage == value)
return;
v80FmtImage = value;
}
}
public string DataUpgraded
{
get
{
return dataUpgraded;
}
set
{
if (dataUpgraded == value)
return;
dataUpgraded = value;
}
}
public string Histogram
{
get
{
return histogram;
}
set
{
if (histogram == value)
return;
histogram = value;
}
}
public string Comments
{
get
{
return comments;
}
set
{
if (comments == value)
return;
comments = value;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Chief Architect - Sea Surveillance AS.
Specializing in integrated operations and high performance computing solutions.
I’ve been fooling around with computers since the early eighties, I’ve even done work on CP/M and MP/M.
Wrote my first “real” program on a BBC micro model B based on a series in a magazine at that time. It was fun and I got hooked on this thing called programming ...
A few Highlights:
- High performance application server development
- Model Driven Architecture and Code generators
- Real-Time Distributed Solutions
- C, C++, C#, Java, TSQL, PL/SQL, Delphi, ActionScript, Perl, Rexx
- Microsoft SQL Server, Oracle RDBMS, IBM DB2, PostGreSQL
- AMQP, Apache qpid, RabbitMQ, Microsoft Message Queuing, IBM WebSphereMQ, Oracle TuxidoMQ
- Oracle WebLogic, IBM WebSphere
- Corba, COM, DCE, WCF
- AspenTech InfoPlus.21(IP21), OsiSoft PI
More information about what I do for a living can be found at:
harlinn.com or
LinkedIn
You can contact me at
espen@harlinn.no