Esempio n. 1
0
 protected override void VisitType(ITyped typedToken)
 {
     if (typedToken.DbType.HasValue)
     {
         State.Write(DbTypeStrings[(int)typedToken.DbType]);
     }
 }
Esempio n. 2
0
 internal static string BuildAggregateType(ITyped type)
 {
     if (type.CharLength.HasValue && type.CharLength.Value != 0)
     {
         return(type.DataType + "(" + type.CharLength + ")");   // VARCHAR2, CHAR2, etc.
     }
     else if (type.DataPrecision.HasValue)
     {
         if (type.DataType.StartsWith(Orcl.TIMESTAMP))    // TIMESTAMP, TIMESTAMP TZ, TIMESTAMP LTZ
         {
             return(type.DataType.Insert(9, "(" + type.DataPrecision + ")"));
         }
         else
         {
             return(type.DataType + "(" + type.DataPrecision + (type.DataScale > 0 ? "," + type.DataScale : "") + ")"); // a number
         }
     }
     else if (type.DataType == Orcl.RECORD || type.DataType == Orcl.ROWTYPE)
     {
         return(type.OrclType.BuildDataTypeFullName(type));
     }
     else
     {
         return(type.DataType);
     }
 }
        internal static ITranslaterType GetTranslater(ITyped dataType)
        {
            string dataTypeFull = String.Empty;

            if (OracleTypeTranslaters.Any(t => t.IsValid(dataType)))
            {
                dataTypeFull = OracleTypeTranslaters.First(t => t.IsValid(dataType)).DataTypeFull;
            }
            else
            {
                dataTypeFull = dataType.OrclType.BuildDataTypeFullName(dataType);
                switch (OrclUtil.NormalizeDataType(dataType))   // dynamically create custom type translaters for complex types
                {
                case Orcl.ASSOCIATITVE_ARRAY:
                    OracleTypeTranslaters.Add(new TranslaterAssociativeArray(dataTypeFull, TypeTargetForOracleAssociativeArray, dataType));
                    break;

                case Orcl.REF_CURSOR:
                    if (dataType.SubType == null)
                    {
                        OracleTypeTranslaters.Add(new TranslaterRefCursorUntyped(dataTypeFull, TypeTargetForOracleRefCursor, dataType));
                    }
                    else
                    {
                        OracleTypeTranslaters.Add(new TranslaterRefCursorTyped(dataTypeFull, TypeTargetForOracleRefCursor, dataType));
                    }
                    break;

                case Orcl.OBJECT:
                    OracleTypeTranslaters.Add(new TranslaterObjectType(dataTypeFull));
                    break;

                case Orcl.RECORD:
                    OracleTypeTranslaters.Add(new TranslaterRecordType(dataTypeFull));
                    break;

                case Orcl.ROWTYPE:
                    OracleTypeTranslaters.Add(new TranslaterRowtype(dataTypeFull));
                    break;

                case Orcl.NESTED_TABLE:
                    OracleTypeTranslaters.Add(new TranslaterNestedTable(dataTypeFull, TypeTargetForOracleAssociativeArray, dataType));
                    break;

                case Orcl.VARRAY:
                    OracleTypeTranslaters.Add(new TranslaterVarray(dataTypeFull, TypeTargetForOracleAssociativeArray, dataType));
                    break;

                default:
                    OracleTypeTranslaters.Add(new TranslaterNoneType(dataTypeFull));
                    break;
                }
            }

            return(OracleTypeTranslaters.First(t => t.DataTypeFull.Equals(dataTypeFull)));
        }
 public void NormalizePrecisionScale(ITyped dbDataType, out int?precision, out int?scale)
 {
     scale = null;
     if (dbDataType.DataPrecision != null)
     {
         precision = dbDataType.DataPrecision;
     }
     else
     {
         precision = (dbDataType.DataScale == null || dbDataType.DataScale.Equals(0)) ? 6 : dbDataType.DataScale; // attr/col views store precision in "scale" column
     }
 }
Esempio n. 5
0
        internal static string NormalizeDataType(ITyped type)
        {
            string dataType = type.DataType;

            dataType = OU.NormalizeDataTypeProcedureReturn(dataType);
            dataType = OU.NormalizeDataTypeTimestamp(dataType);
            dataType = OU.NormalizeDataTypeAggregated(dataType);
            dataType = OU.NormalizeDataTypeUndefined(dataType, type);
            dataType = OU.NormalizeDataTypeRowtype(dataType, type);
            dataType = OU.NormalizeDataTypeFromTypeCode(dataType, type);
            return(dataType);
        }
 public void NormalizePrecisionScale(ITyped dbDataType, out int?precision, out int?scale)
 {
     if (dbDataType.DataPrecision != null || dbDataType.DataScale == 0)
     {
         precision = dbDataType.DataPrecision ?? 38;
         scale     = dbDataType.DataScale ?? 0;
     }
     else
     {
         precision = null;
         scale     = null;
     }
 }
Esempio n. 7
0
        internal static void Normalize(ITyped type)
        {
            type.PreNormalizedValues = String.Format("DataType: {0}, DataPrecison: {1}, DataScale: {2}, CharLength: {3}",
                                                     type.DataType, type.DataPrecision.HasValue ? type.DataPrecision.ToString() : "null", type.DataScale.HasValue ? type.DataScale.ToString() : "null", type.CharLength.HasValue ? type.CharLength.ToString() : "null");
            var dataTypeNormalized = NormalizeDataType(type);

            type.OrclType = OrclUtil.GetType(dataTypeNormalized);

            type.OrclType.NormalizePrecisionScale(type, out int?precision, out int?scale);
            type.DataPrecision = precision;
            type.DataScale     = scale;
            type.CharLength    = type.OrclType.NormalizeCharLength(type);
        }
Esempio n. 8
0
        protected override void VisitType(ITyped typedToken)
        {
            if (typedToken.DbType.HasValue)
            {
                if (
                    typedToken.DbType == CommonDbType.DateTime2 ||
                    typedToken.DbType == CommonDbType.DateTimeOffset ||
                    typedToken.DbType == CommonDbType.DateTime ||
                    typedToken.DbType == CommonDbType.Date ||
                    typedToken.DbType == CommonDbType.Time
                    )
                {
                    State.Write(DbTypeStrings[(int)CommonDbType.DateTime]);
                    return;
                }


                if (
                    (typedToken.DbType == CommonDbType.VarChar ||
                     typedToken.DbType == CommonDbType.NVarChar ||
                     typedToken.DbType == CommonDbType.Char ||
                     typedToken.DbType == CommonDbType.NChar) &&
                    typedToken.Length.HasValue &&
                    typedToken.Length.Value == -1
                    )
                {
                    // MySQL doesn't support VARCHAR(MAX)
                    State.Write(DbTypeStrings[(int)CommonDbType.Text]);
                    return;
                }

                State.Write(DbTypeStrings[(int)typedToken.DbType]);

                if (typedToken.Length.HasValue)
                {
                    State.Write(Symbols.OpenParenthesis);

                    var length = typedToken.Length.Value;



                    State.Write(length == -1
                        ? "65535" //max lengh for mySql
                        : length.ToString(CultureInfo.InvariantCulture));

                    State.Write(Symbols.CloseParenthesis);
                }
            }
        }
Esempio n. 9
0
        protected override void VisitType(ITyped typedToken)
        {
            if (typedToken.DbType.HasValue)
            {
                State.Write(DbTypeStrings[(int)typedToken.DbType]);
            }
            if (typedToken.Length.HasValue)
            {
                State.Write(Symbols.OpenParenthesis);
                State.Write(typedToken.Length.Value == -1
                        ? "65535"                                                           //max lengh for mySql
                        : typedToken.Length.Value.ToString(CultureInfo.InvariantCulture));

                State.Write(Symbols.CloseParenthesis);
            }
        }
Esempio n. 10
0
        private static string NormalizeDataTypeFromTypeCode(string dataType, ITyped type)
        {
            if (!(type is Argument) && !OrclUtil.IsExistsType(dataType))
            {
                switch (type.Typecode)     // Typecode only used for table, view, object attributes (not argument)
                {
                case Orcl.TYPECODE_NESTED_TABLE:
                    dataType = Orcl.NESTED_TABLE;
                    break;

                case Orcl.TYPECODE_OBJECT:
                    dataType = Orcl.OBJECT;
                    break;

                case Orcl.TYPECODE_ANYDATA:
                    dataType = Orcl.ANYDATA;
                    break;

                case Orcl.TYPECODE_ANYDATASET:
                    dataType = Orcl.ANYDATASET;
                    break;

                case Orcl.TYPECODE_ANYTYPE:
                    dataType = Orcl.ANYTYPE;
                    break;

                //case Orcl.TYPECODE_LCR_DDL_RECORD:
                //case Orcl.TYPECODE_LCR_PROCEDURE_RECORD:
                //case Orcl.TYPECODE_LCR_ROW_RECORD:
                case Orcl.TYPECODE_XMLTYPE:
                default:
                    dataType = Orcl.XMLTYPE;
                    break;
                    //default:
                    //    break;
                }
            }
            return(dataType);
        }
Esempio n. 11
0
 public void NormalizePrecisionScale(ITyped dbDataType, out int?precision, out int?scale)
 {
     _normalizer.NormalizePrecisionScale(dbDataType, out precision, out scale);
 }
 public int?NormalizeCharLength(ITyped dbDataType)
 {
     return(dbDataType.CharLength >= 1 ? dbDataType.CharLength : null);
 }
 public void NormalizePrecisionScale(ITyped dbDataType, out int?precision, out int?scale)
 {
     precision = null;
     scale     = null;
 }
 public int?NormalizeCharLength(ITyped dbDataType)
 {
     return(null);
 }
Esempio n. 15
0
 public int?NormalizeCharLength(ITyped dbDataType)
 {
     return(_normalizer.NormalizeCharLength(dbDataType));
 }
Esempio n. 16
0
 protected abstract void VisitType(ITyped typedToken);
Esempio n. 17
0
 internal static bool IsWholeNumberOfPrecision(ITyped dataType, int precision)
 {
     return(dataType.DataType == Orcl.NUMBER && dataType.DataPrecision == precision && (dataType.DataScale ?? 0) == 0);
 }
Esempio n. 18
0
 public virtual string BuildDataTypeFullName(ITyped dbDataType)
 {
     return(dbDataType.OrclType.DataType);
 }
Esempio n. 19
0
 /// <summary>
 /// Handle case when the DataType returned from Oracle view is "UNDEFINED"
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 private static string NormalizeDataTypeUndefined(string dataType, ITyped type) => dataType == Orcl.UNDEFINED ? type.DataTypeProperName : dataType;
Esempio n. 20
0
 private static string NormalizeDataTypeRowtype(string dataType, ITyped type) => dataType == Orcl.RECORD && type.DataTypeProperName == null ? Orcl.ROWTYPE : dataType;