locked
ODP.Net throwing error "Specified argument was out of the range of valid values.Parameter name: attrIndex " RRS feed

  • Question

  • User867348898 posted

    Hi All,

    I am using ODP.Net that supports UDT. I have defined userdefined types in my oracle database and I am trying to pass a couple of arrays to my Oracle stored procedure. for creating UDT arrays i created custom classes using .Net IDE.

    now the problem is all things works fine for 2 or 3 times then suddenly Oracle.Dataaccess throws an exception "Specified argument was out of the range of valid values.Parameter name: attrIndex".If i wait for a few min and try again the very same code work again.

    i am totally lost because of this strange behaviour.is this a memory management issue or am i missing something here??

    Please Help.[:'(]

    Thanks.

     

     

     

    Wednesday, June 10, 2009 2:32 AM

All replies

  • User364663285 posted

    Check your array index. It's out of range.

    Wednesday, June 10, 2009 4:57 AM
  • User867348898 posted

    Hi HuaMin Chen,


    Thanks for reply.Index out of range might be the issue. but my problem why my code is working for some time and then throw the exception and again after some time same code works. if array index is getting out of range then why not it is out of range at all the time?? 

    for further reference I am posting stack trace of my exception:

    Object reference not set to an instance of an object. at Oracle.DataAccess.Types.OracleUdt.SetValue(OracleConnection con, IntPtr pUdt, Int32 attrIndex, Object value, Object statusArray)

    at Oracle.DataAccess.Types.OracleUdt.SetValue(OracleConnection con, IntPtr pUdt, Int32 attrIndex, Object value)

    at Oracle.DataAccess.Client.OracleParameter.SetUDTFromArray(OracleConnection conn, Object array, Int32 i)

    at Oracle.DataAccess.Client.OracleParameter.PreBind_Collection(OracleConnection conn)

    at Oracle.DataAccess.Client.OracleParameter.PreBind(OracleConnection conn, IntPtr errCtx, Int32 arraySize)

    at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()

    at Microsoft.ApplicationBlocks.Data.OracleHelper.ExecuteNonQuery(OracleConnection connection, CommandType commandType, String commandText, OracleParameter[] commandParameters) in D:\Projects\ASDE\InvOptToolkit\Trunk\InvOptToolkit\Library\Misc\Data\OracleHelper.cs:line 297

    at Microsoft.ApplicationBlocks.Data.OracleHelper.ExecuteNonQuery(String connectionString, CommandType commandType, String commandText, OracleParameter[] commandParameters) in D:\Projects\ASDE\InvOptToolkit\Trunk\InvOptToolkit\Library\Misc\Data\OracleHelper.cs:line 218

    at Microsoft.ApplicationBlocks.Data.OracleHelper.ExecuteNonQuery(String connectionString, String spName, OracleParameter[] parameterValues) in D:\Projects\ASDE\InvOptToolkit\Trunk\InvOptToolkit\Library\Misc\Data\OracleHelper.cs:line 249

    at Activant.IOT.Criteria.CriteriaManager.setCriteria(List`1 domainlist, Model Model, Int32 locationgroupid) in d:\projects\asde\invopttoolkit\trunk\invopttoolkit\activant.iot\criteria\criteriamanager.cs:line 207

    as described in stack trace method setValue() throwing exception from Oracle.DataAccess.Types.OracleUdt class at runtime. 

    Heres the code that is generated by IDE for custom class.

    public class IOT_NUM_ARRAY : INullable, IOracleCustomType, IXmlSerializable {

     

    private bool m_IsNull;

     

    private decimal[] m_IOT_NUM_ARRAY;

     

    private OracleUdtStatus[] m_statusArray;

     

    public IOT_NUM_ARRAY() {

    // TODO : Add code to initialise the object

    }

     

    public IOT_NUM_ARRAY(string str) {

    // TODO : Add code to initialise the object based on the given string

    }

     

    public virtual bool IsNull {

    get {

    return this.m_IsNull;

    }

    }

     

    public static IOT_NUM_ARRAY Null {

    get {

    IOT_NUM_ARRAY obj = new IOT_NUM_ARRAY();

    obj.m_IsNull = true;

    return obj;

    }

    }

     

    [
    OracleArrayMappingAttribute()]

    public virtual decimal[] Value {

    get {return this.m_IOT_NUM_ARRAY;

    }

    set {

    this.m_IOT_NUM_ARRAY = value;

    }

    }

     

    public virtual OracleUdtStatus[] StatusArray {

    get {

    return this.m_statusArray;

    }

    set {this.m_statusArray = value;

    }

    }

     

    public virtual void FromCustomObject(Oracle.DataAccess.Client.OracleConnection con, System.IntPtr pUdt) {

    object objectStatusArray = ((object)(m_statusArray));

    OracleUdt.SetValue(con, pUdt, 0, this.m_IOT_NUM_ARRAY, objectStatusArray);

    }

     

    public virtual void ToCustomObject(Oracle.DataAccess.Client.OracleConnection con, System.IntPtr pUdt) {

    object objectStatusArray = null;

    this.m_IOT_NUM_ARRAY = ((decimal[])(OracleUdt.GetValue(con, pUdt, 0, out objectStatusArray)));this.m_statusArray = ((OracleUdtStatus[])(objectStatusArray));

    }

     

    public virtual void ReadXml(System.Xml.XmlReader reader) {

    // TODO : Read Serialized Xml Data

    }

     

    public virtual void WriteXml(System.Xml.XmlWriter writer) {

    // TODO : Serialize object to xml data

    }

     

    public virtual XmlSchema GetSchema() {

    // TODO : Implement GetSchema

    return null;

    }

     

    public override string ToString() {

    // TODO : Return a string that represents the current object

    return "";

    }

     

    public static IOT_NUM_ARRAY Parse(string str) {

    // TODO : Add code needed to parse the string and get the object represented by the string

    return new IOT_NUM_ARRAY();

    }

    #region IOracleCustomType Membersvoid IOracleCustomType.FromCustomObject(OracleConnection con, IntPtr pUdt)

    {

    throw new NotImplementedException();

    }

    void IOracleCustomType.ToCustomObject(OracleConnection con, IntPtr pUdt)

    {

    throw new NotImplementedException();

    }

    #endregion

    }

     

    // Factory to create an object for the above class

    [OracleCustomTypeMappingAttribute("IOTUSR.IOT_NUM_ARRAY")]public class IOT_NUM_ARRAYFactory : IOracleCustomTypeFactory, IOracleArrayTypeFactory {

     

    public virtual IOracleCustomType CreateObject() {

    IOT_NUM_ARRAY obj = new IOT_NUM_ARRAY();return obj;

    }

     

    public virtual System.Array CreateArray(int length) {

    Decimal[] collElem = new Decimal[length];

    return collElem;

    }

     

    public virtual System.Array CreateStatusArray(int length) {

    OracleUdtStatus[] udtStatus = new OracleUdtStatus[length];

    return udtStatus;

    }

    #region IOracleCustomTypeFactory MembersIOracleCustomType IOracleCustomTypeFactory.CreateObject()

    {

    throw new NotImplementedException();

    }

    #endregion

    #region
    IOracleArrayTypeFactory MembersArray IOracleArrayTypeFactory.CreateArray(int numElems)

    {

    Decimal[] collElem = new Decimal[numElems];

    return collElem;

    }

    Array IOracleArrayTypeFactory.CreateStatusArray(int numElems)

    {

    throw new NotImplementedException();

    }

    #endregion

    }

     

    Please let me know if any further information needed.

    Thanks n Regards

    Akhilesh

     

    Wednesday, June 10, 2009 6:01 AM