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!

ODP.NET && Entity Framework 'Index was outside the bounds of the array' Exception

3401426Feb 20 2017 — edited Feb 21 2017

I'm using oracle 12 c with entity framework 6 depending on oracle data provider for .net (ODP.net).When I'm trying to add result binding for computed columns in insert procedure I'm getting 'Index was outside the bounds of the array' exception.

Here is scenario details: Using oracle 12 c I've created this table which contains 'commision' as computed column (virtual)

CREATE TABLE emp(

id NUMBER,

first_name VARCHAR2(10),

last_name VARCHAR2(10),

salary NUMBER(9,2),

commision NUMBER GENERATED ALWAYS AS (ROUND(salary*0.1,2)) VIRTUAL,

CONSTRAINT employees_pk PRIMARY KEY (id)

);

After that I've created an insert procedure which returns the inserted record at the end:

CREATE OR REPLACE PROCEDURE sprocEMP_INSERT

(

first\_name\_P    EMP.first\_name%TYPE     ,

last\_name\_P     EMP.last\_name%TYPE      ,

salary\_P        EMP.salary%TYPE         ,

curParam OUT SYS\_REFCURSOR

)

IS

RECORD_ID EMPLOYEES.EMPLOYEE_ID%TYPE;

BEGIN

RECORD\_ID := EMPLOYEES\_SEQ.NEXTVAL; 

INSERT INTO HR.EMPLOYEES

    (

      id          ,

      first\_name  ,

      last\_name   ,

      salary        

    )  

VALUES 

    (

      RECORD\_ID   ,

      first\_name\_P,

      last\_name\_P ,

      salary\_P

    );  

COMMIT;

OPEN curParam FOR 

    SELECT \* FROM EMP 

    WHERE ID = RECORD\_ID; 

END;

Then I've imported the table and the procedure into EF model and map the insert procedure to the table like in the linked image :

EF.JPG

And up to now every thing is Ok and the insert procedure works well and return the id value, but when I add any other computed columns (like in the linked image ) I get 'Index was outside the bounds of the array' exception

EFException.JPG

Exception Details:

StackTrace:

at Oracle.ManagedDataAccess.Client.OracleDataReader.GetValue(Int32 i)

at System.Data.Entity.Core.Mapping.Update.Internal.FunctionUpdateCommand.Execute(Dictionary`2 identifierValues, List`1 generatedValues)

at System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()

Source:

Oracle.ManagedDataAccess

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 21 2017
Added on Feb 20 2017
2 comments
4,596 views