Connecting Tech Pros Worldwide Help | Site Map

Oracle error returning value from database

  #1  
Old June 3rd, 2009, 04:48 PM
Member
 
Join Date: Feb 2009
Location: Jersey
Posts: 35
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.         }
  #2  
Old June 4th, 2009, 12:26 PM
debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,485
Provided Answers: 1

re: Oracle error returning value from database


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convertion of Unicode to ASCII NIGHTMARE ChaosKCW answers 24 April 11th, 2006 05:35 AM
UDB 8.1.4 & VB6/ADO Remove the obvious for replies answers 9 November 12th, 2005 06:31 AM
Javascript, ODBC, and Oracle functions returning cursors Roger Redford answers 4 July 23rd, 2005 04:28 PM
Use of uninitialized value in concatenation (.) at register.pl line 38, <STDIN> line 10. G Kannan answers 1 July 19th, 2005 05:45 AM