c# - Getting a Date value from Oracle Stored Procedure using ODP.NET -


i hoping simple one, first wpf oracle 11g (version 11.2). application.

i able call oracle stored procedures wpf application code , retrieve output (int , string) parameters, when try retrieve date value, following value 01/01/0001 00:00:00 suggests date not being returned?

the stored procedure works fine in oracle, i.e. returns date.

here's code:

string sql = "pkge_intautotest.schedulenextrun"; oraclecommand cmd = new oraclecommand(sql, conn); cmd.bindbyname = true; cmd.commandtype = system.data.commandtype.storedprocedure;  datetime outscheddatetime; cmd.parameters.add("outscheddatetime", oracledbtype.date, parameterdirection.output);  cmd.executenonquery();  //get values output stored procedure outscheddatetime = (datetime)cmd.parameters["outscheddatetime"].value;  conn.close(); conn.dispose(); 

and here's (simplified) stored procedure:

procedure schedulenextrun (inintno number, outcaseno out number, outscheddatetime out date ) begin     declare         sched_datetime date;         init_diary_id diary.id%type;         v_proceed pls_integer;      begin         -- schedule time 4 minutes         select to_date(sysdate + 4/(24*60)) sched_datetime dual;         outscheddatetime := sched_datetime;      end; end schedulenextrun; 

i continue looking @ this, ideas doing wrong?

this working.

in stored procedure, had change, following line:

select to_date(sysdate + 4/(24*60)) sched_datetime dual; 

to following:

select sysdate + 4/(24*60) sched_datetime dual; 

then suggested jmk, in .net code had change:

cmd.parameters.add("outscheddatetime", oracledbtype.date, parameterdirection.output); 

to following:

cmd.parameters.add("outscheddatetime", oracledbtype.timestamp, parameterdirection.output); 

so in wpf application, can see date , time portion. hope helps.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -