Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

"Value does not fall within the expected range" when passing UDT to the stored procedure

JWuFeb 2 2020

Here's my class mapping to the UDT (really simple):

[OracleCustomTypeMapping("PORTAL_OPS.SHAPEUDT")]

public class Shape : IOracleCustomType, IOracleCustomTypeFactory

{

     [OracleObjectMapping("SIDES")]

     public Int32 Sides { get; set; }

     public string UdtTypeName

     {

          get

          {

               Attribute attr = Attribute.GetCustomAttribute(this.GetType()

                                        , typeof(OracleCustomTypeMappingAttribute));

               return (attr != null) ?

               ((OracleCustomTypeMappingAttribute)attr).UdtTypeName

                :

               String.Empty;

          }

     }

     public void FromCustomObject(OracleConnection con, IntPtr pUdt)

     {

          OracleUdt.SetValue(con, pUdt, "SIDES", Sides);

     }

     public void ToCustomObject(OracleConnection con, IntPtr pUdt)

     {

          Sides = (int)OracleUdt.GetValue(con, pUdt,"SIDES");

     }

     public IOracleCustomType CreateObject()

     {

          return new Shape();

     }

}

To call the stored procedure:

     if (Command.Connection.State == ConnectionState.Closed)

     {

          Command.Connection.Open();

     }

     // setting up the parameter

     OracleParameter param = new OracleParameter();

     param.Direction = ParameterDirection.Input;

     param.UdtTypeName = udt.UdtTypeName;

     param.DbType = DbType.Object;

     param.OracleDbType = OracleDbType.Object;

     param.Value = udt;

     Command.CommandText = "PORTAL_OPS.PROC_CREATE_SHAPE";

     Command.CommandType = CommandType.StoredProcedure;

     Command.Parameters.Add(param);

     Command.ExecuteNonQuery();

A couple of points:

  • Oracle's documentation says to use  OracleCustomTypeMappingAttribute, but I notice a lot of people use OracleCustomTypeMapping.  Which one is the correct one to use?
  • While I was troubleshooting, I purposely misspelled the the value inside the OracleObjectMapping...and it didn't seem to affect anything...still getting the "Value does not fail within the expected range"?

The stacktrace stopps at

OracleCustomTypeMappingAttribute.ctor(String udtTypeName)   (I am sure the UDT type name is correct)

Help!  Thanks!

Comments
Post Details
Added on Feb 2 2020
0 comments
2,749 views