Page 1 of 1

problem calling the Stored procedure using ExecuteStoreQuery

Posted: Wed 28 Mar 2012 10:09
by sivaprasad.bevara
Hi,

I am using EF 4.1 code first approach (Silver light 5).

I am facing the following issue while calling the stored procedure from the domain service.


ORA-00900: invalid SQL statement


Following the stored procedure:

Code: Select all

create or replace package types
as
    type cursorType is ref cursor;
end;
/ 

create or replace procedure GetLookupData( p_cursor in out types.cursorType )
as
begin
open p_cursor for SELECT 1 as Id, 'siva' as Name from tbl;
end;
/
Following is the code in the Domain service.

Code: Select all

public List GetMyclass()
        {
            	List result = null;         
                	string SQLQuery = "exec Schema.GetLookupData";
                	result = _context.ExecuteStoreQuery(SQLQuery).AsQueryable().ToList();               
            
            	return result;
        }
Please help.

Regards,
SivaPrasad.B[/code]

Posted: Mon 02 Apr 2012 13:32
by Shalex
Please try using this code:

Code: Select all

    class Program {
        static void Main(string[] args) {
            Devart.Data.Oracle.OracleMonitor monitor = new Devart.Data.Oracle.OracleMonitor() { IsActive = true };
            Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfig config =
                Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfig.Instance;
            config.Workarounds.IgnoreSchemaName = true;

            MyDbContext context = new MyDbContext();
            string SQLQuery = @"begin GetLookupData(:CUR); end;";
            Devart.Data.Oracle.OracleParameter param1 = new Devart.Data.Oracle.OracleParameter();
            param1.ParameterName = "CUR";
            param1.OracleDbType = Devart.Data.Oracle.OracleDbType.Cursor;
            param1.Direction = System.Data.ParameterDirection.Output;

            var result = (context as IObjectContextAdapter).ObjectContext.ExecuteStoreQuery(SQLQuery, param1).ToList();
        }
    }

    public class MyDbContext : DbContext {
        public MyDbContext()
            : base() {
        }
        public MyDbContext(DbConnection connection)
            : base(connection, true) {
        }
        protected override void OnModelCreating(DbModelBuilder modelBuilder) {
            modelBuilder.Conventions
              .Remove();
            modelBuilder.Conventions
              .Remove();
        }
        public DbSet MyClasses { get; set; }
    }

    public class MyClass {
        [Key]
        public long Id { get; set; }
        public string Name { get; set; }
    }