Unhandled execution error / ASP.Net — oracle-tech

    Forum Stats

  • 3,715,958 Users
  • 2,242,917 Discussions
  • 7,845,703 Comments

Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Unhandled execution error / ASP.Net

312797
312797 Member Posts: 2
Any ideas as to what's causing the following error:

---
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Oracle.DataAccess.Client.OraException:
/---

I'm simply calling an Oracle function which returns a date. Code snippet:

---
FUNCTION func_get_session_date(v_session_id VARCHAR2, v_session_key VARCHAR2) RETURN DATE IS
...etc
/---

...employing the OraDataReader to extract the value (unnecessary code extracted for clarity):

---
DateTime returnDateTime;

string commandText = "SELECT pkg_css_session_state.func_get_session_date(:v_session_id, :v_session_key) FROM dual";
//string commandText = "SELECT pkg_css_session_state.func_get_session_date('" + this.AspxSessionID + "', '" + sessionKey + "') FROM dual";

OraConnection oraConnection = new OraConnection(connectionString);
OraCommand oraCommand = new OraCommand();
oraCommand.Connection = oraConnection;
oraCommand.CommandText = commandText;

OraParameter oraParmSessionID = new OraParameter();
oraParmSessionID.ParameterName = "v_session_id";
oraParmSessionID.OraDbType = OraDbType.Varchar2;
oraParmSessionID.Value = this.AspxSessionID;
oraParmSessionID.Direction = ParameterDirection.Input;
oraCommand.Parameters.Add(oraParmSessionID);

OraParameter oraParmSessionKey = new OraParameter();
oraParmSessionKey.ParameterName = "v_session_key";
oraParmSessionKey.OraDbType = OraDbType.Varchar2;
oraParmSessionKey.Value = sessionKey;
oraParmSessionKey.Direction = ParameterDirection.Input;
oraCommand.Parameters.Add(oraParmSessionKey);

oraConnection.Open();
OraDataReader oraDataReader = oraCommand.ExecuteReader(CommandBehavior.CloseConnection);

if (oraDataReader.Read())
{
if (! oraDataReader.IsDBNull(0))
{
returnDateTime = oraDataReader.GetDateTime(0);
}
}

/--

Interestingly, it works fine when I don't use input parameters (see commented-out commandText string).

Thanks ahead o' time!

Comments

  • 285751
    285751 Member Posts: 8
    Try adding a parameter 0 before your oraParmSessionID parameter. That will give the function someplace to return its result.

    OraParameter oraReturn = new OraParameter();
    oraReturn.ParameterName = "justaboutanything";
    oraReturn.OraDbType = OraDbType.Date;
    oraReturn.Direction = ParameterDirection.ReturnValue;
    oraCommand.Parameters.Add(oraReturn );




    Any ideas as to what's causing the following error:
    ---
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: Oracle.DataAccess.Client.OraException:
    /---
    I'm simply calling an Oracle function which returns a date. Code snippet:
    ---
    FUNCTION func_get_session_date(v_session_id VARCHAR2, v_session_key VARCHAR2) RETURN DATE IS
    ...etc
    /---
    ...employing the OraDataReader to extract the value (unnecessary code extracted for clarity):
    ---
    DateTime returnDateTime;
    string commandText = "SELECT pkg_css_session_state.func_get_session_date(:v_session_id, :v_session_key) FROM dual";
    //string commandText = "SELECT pkg_css_session_state.func_get_session_date('" + this.AspxSessionID + "', '" + sessionKey + "') FROM dual";
    OraConnection oraConnection = new OraConnection(connectionString);
    OraCommand oraCommand = new OraCommand();
    oraCommand.Connection = oraConnection;
    oraCommand.CommandText = commandText;
    OraParameter oraParmSessionID = new OraParameter();
    oraParmSessionID.ParameterName = "v_session_id";
    oraParmSessionID.OraDbType = OraDbType.Varchar2;
    oraParmSessionID.Value = this.AspxSessionID;
    oraParmSessionID.Direction = ParameterDirection.Input;
    oraCommand.Parameters.Add(oraParmSessionID);
    OraParameter oraParmSessionKey = new OraParameter();
    oraParmSessionKey.ParameterName = "v_session_key";
    oraParmSessionKey.OraDbType = OraDbType.Varchar2;
    oraParmSessionKey.Value = sessionKey;
    oraParmSessionKey.Direction = ParameterDirection.Input;
    oraCommand.Parameters.Add(oraParmSessionKey);
    oraConnection.Open();
    OraDataReader oraDataReader = oraCommand.ExecuteReader(CommandBehavior.CloseConnection);
    if (oraDataReader.Read())
    {
    if (! oraDataReader.IsDBNull(0))
    {
    returnDateTime = oraDataReader.GetDateTime(0);
    }
    }
    /--
    Interestingly, it works fine when I don't use input parameters (see commented-out commandText string).
    Thanks ahead o' time!
This discussion has been closed.