The parameter at index 0 in the parameters array is null.

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
uracs
Posts: 1
Joined: Sat 05 Nov 2011 16:10

The parameter at index 0 in the parameters array is null.

Post by uracs » Sat 05 Nov 2011 16:33

Hi,

I am using the dotnet connector (latest version) and Visual Studio 2010 SP1
.net framework 4.0.

I generated an edmx file form an oracle database using dotnet connector.

Everything is perfect and my application is working very well.

But I tried to use a simple stored procedure.

It has one input parameter and one output parameter.

I defined in the oracle database:

Code: Select all

create or replace
PROCEDURE getnextid
( P_NEXTID OUT INTEGER
, P_TABLENAME IN VARCHAR2
) AS

--
-- Purpose: Retrives the next value from a sequence which is named
--          after table name concatented with _seq.
--          To provide for .Net Entity Framework lack of sequences
--
-- MODIFICATION HISTORY
-- Person  Date      Comments
-- ---------------------------------------------------------
-- CS      16/12/10  Created
--

--local variables---------------------------------
   --return value for the next value of the sequence
   ld_next_id  integer;
   --local variable for the in parameter table name
   ld_tablename VARCHAR2(30) := upper(P_TABLENAME);
   -- holds the sql str to be dynamically run
   ld_sql_str VARCHAR2(2000);


BEGIN

    ld_sql_str := 'SELECT '||ld_tablename||'_seq.nextval from dual';

    --dbms_output.put_line(ld_sql_str);

    EXECUTE IMMEDIATE ld_sql_str
       INTO ld_next_id;

    P_NEXTID := ld_next_id;
    
    

EXCEPTION
   WHEN OTHERS THEN
       --raise_application_error(-20101, 'There is no such sequence for this table, Please contact System Support') ;
       P_NEXTID := -1;
    
END getnextid;
I imported this into the function Imports, but when I want to use I get an error message:

The parameter at index 0 in the parameters array is null.

Code: Select all

in this part of code:

/// 
        /// No Metadata Documentation available.
        /// 
        /// No Metadata Documentation available.
        /// No Metadata Documentation available.
        public int GETNEXTID(ObjectParameter p_NEXTID, global::System.String p_TABLENAME)
        {
            ObjectParameter p_TABLENAMEParameter;
            if (p_TABLENAME != null)
            {
                p_TABLENAMEParameter = new ObjectParameter("P_TABLENAME", p_TABLENAME);
            }
            else
            {
                p_TABLENAMEParameter = new ObjectParameter("P_TABLENAME", typeof(global::System.String));
            }
    
           return base.ExecuteFunction("GETNEXTID", p_NEXTID, p_TABLENAMEParameter);
        }

this function throws the exeption:

Code: Select all

return base.ExecuteFunction("GETNEXTID", p_NEXTID, p_TABLENAMEParameter);

I did not modify anything manually I used the ADO.NET Entity Framework wizard.

Anybody can help me to resolve this problem?

Thanks advanced u.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 07 Nov 2011 12:19

We do not have a technical possibility to change the EDM Wizard/Designer code generation in this case.

We recommend using Entity Developer (the Devart Entity Model template, *.edml). Drag&drop the procedure on designer surface from Tools > Entity Developer > Database Explorer or from the Store part of Model Explorer to add the corresponding method to CSDL. Here is a code that is generated for your procedure by Entity Developer:

Code: Select all

        public void GETNEXTID (ref global::System.Nullable P_NEXTID, string P_TABLENAME)
        {
            if (this.Connection.State != System.Data.ConnectionState.Open)
              this.Connection.Open();
            System.Data.EntityClient.EntityCommand command = new System.Data.EntityClient.EntityCommand();
            if(this.CommandTimeout.HasValue)
              command.CommandTimeout = this.CommandTimeout.Value;
            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.CommandText = @"SCOTTEntities.GETNEXTID";
            command.Connection = (System.Data.EntityClient.EntityConnection)this.Connection;
            EntityParameter P_NEXTIDParameter = new EntityParameter("P_NEXTID", System.Data.DbType.Decimal);
            if (P_NEXTID.HasValue)
                P_NEXTIDParameter.Value = P_NEXTID;
            command.Parameters.Add(P_NEXTIDParameter);
            EntityParameter P_TABLENAMEParameter = new EntityParameter("P_TABLENAME", System.Data.DbType.String);
            if (P_TABLENAME != null)
                P_TABLENAMEParameter.Value = P_TABLENAME;
            command.Parameters.Add(P_TABLENAMEParameter);
            command.ExecuteNonQuery();
            if (P_NEXTIDParameter.Value != null && !(P_NEXTIDParameter.Value is System.DBNull))
              P_NEXTID = (global::System.Nullable)P_NEXTIDParameter.Value;
            else
              P_NEXTID = default(global::System.Nullable);
        }

Post Reply