Connecting Tech Pros Worldwide Help | Site Map

Oracle error returning value from database

Member
 
Join Date: Feb 2009
Location: Jersey
Posts: 35
#1: Jun 3 '09
I get an ORA-00936: missing expression error when using the following code to return a single date from an Oracle table.

I've used an example snippet of code to help me put this method together and I want to assign the date to a text box in an ASP.NET page, but can't understand what to try next and how the error is being thrown.

I've debugged the application and the 'file' parameter always has a value when I do so. The error is thrown at the return statement.

Any guidance appreciated!

Expand|Select|Wrap|Line Numbers
  1. public DateTime GetEffectiveDate(string file) 
  2.         {
  3.             string fileNo = string.Format("'{0}'", file);
  4.             getDBConnection();
  5.  
  6.             OracleCommand command = conn.CreateCommand();
  7.             command.CommandType = CommandType.Text;
  8.             command.CommandText = @"SELECT effectivedate 
  9.                 FROM tblcorporateactions WHERE corporateactionnumber = @fileNo";
  10.  
  11.             // Input parameter
  12.             OracleParameter prm1 = new OracleParameter("@fileNo", OracleDbType.Varchar2);
  13.             prm1.Direction = ParameterDirection.Input;
  14.             prm1.Value = file;
  15.             // return parameter
  16.             OracleParameter ret =
  17.                 new OracleParameter("@effectiveDate", OracleDbType.Varchar2);
  18.             ret.Direction = ParameterDirection.ReturnValue;
  19.  
  20.             command.Prepare();
  21.             return (DateTime) command.ExecuteScalar(); // throws error here
  22.         }
debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,497
#2: Jun 4 '09

re: Oracle error returning value from database


that simply mean there is some error in the SQL statement .
Reply