Kode berikut berfungsi untuk saya.
NB:Kode pl/sql Anda memanggil fungsi KRIST.f_Login, tetapi c# Anda menyebutnya krist.p_login
NB2:Kode pl/sql Anda menggunakan Varchar2, tetapi c# Anda varchar bekas
NB3:Saya menggunakan Oracle.DataAccess.dll
NB4:Saya berasumsi ukuran buffer nilai kembalian Anda bisa 1, tetapi coba ukuran yang berbeda.
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
int RETURN_VALUE_BUFFER_SIZE = 32767;
OracleCommand cmd = new OracleCommand();
try {
cmd.Connection = conn;
cmd.CommandText = "KRIST.f_Login";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("returnVal", OracleDbType.Varchar2, RETURN_VALUE_BUFFER_SIZE);
cmd.Parameters["returnVal"].Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add("userName", OracleDbType.Varchar2);
cmd.Parameters["userName"].Value = "kristian";
cmd.Parameters.Add("password", OracleDbType.Varchar2);
cmd.Parameters["password"].Value = "kristian";
cmd.ExecuteNonQuery();
string bval = cmd.Parameters["returnVal"].Value.ToString();
return bval;
} catch (Exception e) {
// deal with exception
} finally {
command.Dispose();
connection.Close();
connection.Dispose();
}