简体   繁体   中英

EF execution of Oracle stored procedure with DATE parameter loses hours/minutes

I have a simple stored procedure using DATE as an input:

CREATE OR REPLACE PROCEDURE delete_time(myTime DATE) IS
BEGIN
DELETE FROM mytable WHERE time = myTime;
END;
/

This has been added to my EDMX using a function import, and the types mapped are Date on the SSDL side and DateTime on the CSDL.

The problem is when I run the procedure from .NET using a DateTime the hours and minutes are lost somewhere along the way:

DateTime dt = new DateTime(2013, 4, 3, 12, 15, 00);
var timeParam = new ObjectParameter("myTime", dt) : 
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("DeleteTime", timeParam);

This runs the stored procedure but deletes the rows where TIME = 03-APR-2013 00:00:00 instead of 03-APR-2013 12:15:00

Is there some bug in the Oracle client (I'm using 11.2.0.3.20)? Or am I doing something wrong above?

I also tried using TIMESTAMP as the input type of my procedure, but then I get this error when calling the function: ORA-01830: date format picture ends before converting entire input string

Any ideas?

I had this problem trying to execute a Oracle procedure using entity framework. So I did like this to pass a Date parameter:

var objects = _dbContext.Database.SqlQuery<MyObject>("BEGIN My_procedure(to_date('01/01/2016', 'dd/mm/yyyy  hh24:mi:ss')); END;").ToList();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM