How can I call Oracle stored procedure object parameter with c#? [duplicate]

This question is an exact duplicate of:

I have this stored procedure into the Oracle 11g:

create or replace
PROCEDURE LOG_IN(P_USERNAME IN VARCHAR2,
                 P_PASSWORD IN VARCHAR2,
                 P_LOGIN_RESULT OUT LOGINRESULT) IS
  LV_LOGIN_RESULT LOGINRESULT;
BEGIN
  LOG_WRITER_BILL(NULL, 'LOGIN', 'MODULE START', 'START');
  LV_LOGIN_RESULT := LOGINRESULT(NULL,
                                 NULL);
  LV_LOGIN_RESULT.SESSIONID := WEBSERVICE_API_PKG.LOGIN(P_USERNAME,
                                                        P_PASSWORD);
  IF LV_LOGIN_RESULT.SESSIONID IS NULL THEN
    LV_LOGIN_RESULT.RESULT:= 1;
  ELSE
    LV_LOGIN_RESULT.RESULT := 0;
  END IF;
  LOG_WRITER_BILL(NULL, 'LOGIN', 'MODULE END', 'END');
  P_LOGIN_RESULT := LV_LOGIN_RESULT;
END;

and up stored procedure have a simple object this:

create or replace
TYPE LOGINRESULT AS OBJECT 
( 
  Result NUMBER,
  SessionID NUMBER
);

How can I call this stored procedure with C# and get data from it?

I wrote this code for rad data from up stored procedure with C#:

OracleConnection conn = new OracleConnection("User Id=WEBSERVICE_ACCESS;Password=DAMAVAND;Server=ORA11;");
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "LOG_IN";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("P_USERNAME", "guest").Direction = ParameterDirection.Input;
cmd.Parameters.Add("P_PASSWORD", "guest").Direction = ParameterDirection.Input;


cmd.Parameters.Add("SessionID", OracleType.Number, 20).Direction = ParameterDirection.Output;
cmd.Connection.Open();
cmd.ExecuteNonQuery();

but get error and I question in this link:

MY QUESTION IN STACKOVERFLOW

but nobody answers me, please help me how can I call that stored procedure?

THANKS.


Source: oracle

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.