I created the following procedure:
create or replace procedure ps_medical (
v_id in number,
v_name out varchar2,
v_description out varchar2
) is
begin
select name, description
into v_name, v_description
from medical_img
where id = v_id;
end;
It rises Oracle ORA-06502 numeric or value error. I want to display v_name and v_description.
My table structure:
ID NOT NULL NUMBER
NAME VARCHAR2(255)
DESCRIPTION VARCHAR2(255)
In Sql Developer it works fine. I'm trying to use it in a c# form and there the error rises:
try
{
con.Open();
}
catch (OracleException ex)
{
MessageBox.Show(ex.Message);
}
OracleCommand cmd = new OracleCommand("ps_medical", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("v_id", OracleDbType.Int32);
cmd.Parameters.Add("v_name", OracleDbType.Varchar2);
cmd.Parameters.Add("v_description", OracleDbType.Varchar2);
cmd.Parameters[0].Direction = ParameterDirection.Input;
cmd.Parameters[1].Direction = ParameterDirection.Output;
cmd.Parameters[2].Direction = ParameterDirection.Output;
cmd.Parameters[0].Value = Convert.ToInt32(tb_id.Text);
try
{
cmd.ExecuteScalar();
lb_med.Text = Convert.ToString(cmd.Parameters[1].Value);
tb_desc.Text = Convert.ToString(cmd.Parameters[2].Value);
}
catch (OracleException ex)
{
MessageBox.Show(ex.Message);
}
con.Close();