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

576 views Asked by At

Here's my class mapping to an UDT in Oracle (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();

Instantiation:

Shape shape = new Shape();
shape.sides = 4;
//invoking the stored procedure call (see code above)

I couldn't figure out why I keep getting the "Value does not fall within the expected range". Have been looking at this the whole weekend...no luck. Any help is greatly appreciated.

0

There are 0 answers