I'm new to PLSQL and can't figure out how to restive value from Oracle stored procedures. How can I solve this?
System.Exception: 'Parameter 'result': No size set for variable length data type: String.'
I'm using Iracle 10g
Procedure:
PROCEDURE LoginAuthentication(uid in users.userid%type,pass in users.password%type,result out users.role%type)
is
rl users.role%type;
c number;
begin
select role into rl from users where userid=uid and password=pass and status=1;
select count(*) into c from users where userid=uid and password=pass and status=1;
if(c=1) then
result:=rl;
else
result:='null';
end if;
exception
when no_data_found then
result:='null';
end LoginAuthentication;
Code:
public string Login(String id, string password)
{
using (OracleConnection oCon = new OracleConnection("DATA SOURCE = localhost:1521;USER ID = PROJECTDB;Password=pass"))
{
OracleCommand Cmd = new OracleCommand();
try
{
Cmd.Connection = oCon;
Cmd.CommandText = " user_package.LoginAuthentication";
Cmd.CommandType = CommandType.StoredProcedure;
Cmd.Parameters.Add("uid", OracleType.VarChar).Value = id;
Cmd.Parameters.Add("pass", OracleType.VarChar).Value = password;
Cmd.Parameters.Add("result", OracleType.VarChar).Direction = ParameterDirection.Output;
oCon.Open();
Cmd.ExecuteNonQuery();
string result = Cmd.Parameters["result"].Value.ToString();
return result;
}
catch (Exception ex)
{
throw ex;
}
finally
{
oCon.Close();
}
}
}
Error:
System.Exception: 'Parameter 'result': No size set for variable length data type: String.
nullisn't the same as the null value. Imagine what would happen if someone created a role namednull.var hash=k1.GetBytes(20);