Trying to follow examples I've seen online to call a simple stored procedure. Converting from (working) data readers to stored procs to get SQL code out of .NET project. Error is on execute ("ORA-00900: invalid SQL statement"). I've used other SQL examples and get the same problem. Not sure if it's in my parameter adding.
Code:
public string DGetEmailAddress(string emplid)
{
string returnValue = string.Empty;
string sql = "SP_GET_EMAIL_ADDRESS";
OracleConnection sqlConnection = new OracleConnection(GetConnectionString(connectionADP));
OracleCommand sqlCommand = new OracleCommand(sql, sqlConnection);
sqlCommand.Parameters.Add("MyEmplid", OracleDbType.Varchar2).Value = emplid;
sqlCommand.Parameters.Add("Email", OracleDbType.Varchar2).Direction = ParameterDirection.Output;
try
{
sqlConnection.Open();
sqlCommand.ExecuteNonQuery();
returnValue = (string)sqlCommand.Parameters["Email"].Value;
}
catch (Exception ex)
{
returnValue = string.Empty;
}
finally
{
if ((sqlCommand != null))
{
sqlCommand.Dispose();
}
if ((sqlConnection != null))
{
sqlConnection.Close();
}
}
return returnValue;
}
Code:
CREATE OR REPLACE PROCEDURE SP_GET_EMAIL_ADDRESS (MYEMPLID IN VARCHAR2, EMAIL OUT VARCHAR2) IS BEGIN SELECT EMAIL_ADDRESS INTO EMAIL FROM PS_PERSONAL_DATA WHERE EMPLID = MYEMPLID; END SP_GET_EMAIL_ADDRESS;
Comment