"Value does not fall within the expected range" when passing UDT to the stored procedure — oracle-tech

    Forum Stats

  • 3,716,133 Users
  • 2,242,960 Discussions
  • 7,845,840 Comments

Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

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

JWu
JWu Member Posts: 8 Red Ribbon

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!

Sign In or Register to comment.