Inheritance: System.Data.ProviderBase.DbConvert
Example #1
0
        protected sealed override object ConvertValue(object value)
        {
            // can not convert null or DbNull to other types
            if (value == null || value == DBNull.Value)
            {
                return(value);
            }

            // TBD : some other way to do this?
//			if (OracleType == OracleType.Binary) {
//				return value;
//			}
            // .NET throws an exception to the user.
            object convertedValue = value;

            // note : if we set user parameter jdbc type inside prepare interbal, the db type is not set
            if (value is IConvertible && (IsDbTypeSet || IsJdbcTypeSet))
            {
                OracleType oleDbType = (IsDbTypeSet) ? OracleType : OracleConvert.JdbcTypeToOracleType((int)JdbcType);
                Type       to        = OracleConvert.OracleTypeToValueType(oleDbType);
                if (!(value is DateTime && to == OracleConvert.TypeOfTimespan))                 //anyway will go by jdbc type
                {
                    convertedValue = Convert.ChangeType(value, to);
                }
            }
            return(convertedValue);
        }
Example #2
0
        public override String GetDataTypeName(int columnIndex)
        {
            try {
                string jdbcTypeName = Results.getMetaData().getColumnTypeName(columnIndex + 1);

                return(OracleConvert.JdbcTypeNameToDbTypeName(jdbcTypeName));
            }
            catch (SQLException e) {
                throw CreateException(e);
            }
        }
Example #3
0
        protected sealed override void SetParameterDbType(ResultSet res)
        {
            int jdbcType = res.getInt("DATA_TYPE");

            // FIXME : is that correct?
            if (jdbcType == Types.OTHER)
            {
                string typeName = res.getString("TYPE_NAME");
                if (String.Compare("REF CURSOR", typeName, true, CultureInfo.InvariantCulture) == 0)
                {
                    jdbcType = (int)JavaSqlTypes.CURSOR;
                }
                else if (String.Compare("BLOB", typeName, true, CultureInfo.InvariantCulture) == 0)
                {
                    jdbcType = (int)JavaSqlTypes.BLOB;
                }
                else if (String.Compare("CLOB", typeName, true, CultureInfo.InvariantCulture) == 0)
                {
                    jdbcType = (int)JavaSqlTypes.CLOB;
                }
                else if (String.Compare("FLOAT", typeName, true, CultureInfo.InvariantCulture) == 0)
                {
                    jdbcType = (int)JavaSqlTypes.FLOAT;
                }
                else if (String.Compare("NVARCHAR2", typeName, true, CultureInfo.InvariantCulture) == 0)
                {
                    jdbcType = (int)JavaSqlTypes.VARCHAR;
                }
                else if (String.Compare("NCHAR", typeName, true, CultureInfo.InvariantCulture) == 0)
                {
                    jdbcType = (int)JavaSqlTypes.VARCHAR;
                }
            }
            OracleType = OracleConvert.JdbcTypeToOracleType(jdbcType);
            JdbcType   = jdbcType;
        }
 protected override int GetProviderType(int jdbcType)
 {
     return((int)OracleConvert.JdbcTypeToOracleType(jdbcType));
 }
Example #5
0
 protected sealed override int JdbcTypeFromProviderType()
 {
     return(OracleConvert.OracleTypeToJdbcType(OracleType));
 }