I'm trying to call a procedure and use the value which i get after executing in my code.
I have created a procedure Getdata
and I'm calling it from ASP.NET MVC and try to use it.
Oracle procedure:
CREATE OR REPLACE PROCEDURE Getdata(v_hr_stk_out out number,v_cr_stk_out out number) Is
r_stk number;
vr_stk number;
BEGIN
select round(sum(a.batch_wt)) into r_stk from dbprod.sm_data a where a.iss_date is null and a.cw_coil_no is not null and a.prod_cd = '37' and a.from_plant != a.hsource;
select round(sum(a.batch_wt)) into vr_stk from dbprod.psm_data a where a.iss_date is null and a.cw_coil_no is not null and a.prod_cd = 'C9' and a.from_plant != a.hr_source;
v_hr_stk_out:=v_hr_stk;
v_cr_stk_out :=v_cr_stk;
END;
ASP.NET MVC side:
OracleConnection conn = new OracleConnection(ConfigurationManager.ConnectionStrings["Mycon"].ToString());
conn.Open();
OracleCommand command = new OracleCommand();
command.Connection = conn;
command.CommandText = "Getdata";
command.CommandType = CommandType.StoredProcedure;
OracleDataAdapter adapter = new OracleDataAdapter(command);
DataSet dataSet = new DataSet();
adapter.Fill(dataSet);
conn.Close();
return View("Home",dataSet);
Binding value in view
@using System.Data;
@model DataSet
<table cellpadding="0" cellspacing="0">
<tr>
<th>A</th>
<th>B/th>
<th>C</th>
</tr>
@foreach (DataRow row in Model.Tables[0].Rows)
{
<tr>
<td>F</td>
<td>Dataset.Tables[0]</td>
<td>Dataset.Tables[1]</td>
</tr>
}
</table>
Value from procedure should come and bind in respective column in view.
Currently, no value is stored in the dataset after calling adapter.Fill(dataSet);
.
I am new to ASP.NET MVC and Oracle. Any idea would be appreciated