Oracle ODBC SQL Command not properly ended - Visual Studio

I am trying to retrieve data from an Oracle 10g database into a simple Visual Studio project.  The sql statement (see below) is very simple and works fine when I run it in SQL Server Management Studio; however, when I try to execute the statement in Visual Studio I get the following error:
ERROR [HY000] [Oracle][ODBC][Ora]ORA-00933:  SQL command not properly ended

As I said, this same command executes with no errors in SQL Server Management Studio.

Any ideas???

select Case
      when UserName = '2085' then 'Hazel'
      when UserName = '2088' then 'Tracie'
      end
      as UserName,
mbrsep, name, transdate, cafield, oldval, newval
from openquery(SEDCCA, '

select anntrandetl.mbrsep, name, transdate, cafield, oldval, newval, oper as UserName
from anntrandetl inner join mbrsepmstr on anntrandetl.mbrsep = mbrsepmstr.mbrsep

')
where transdate >= '090719' and cafield = 'MAILCODE' AND (UserName = '2085' or UserName = '2088')



4countyAsked:
Who is Participating?
 
mustaccioCommented:
OPENQUERY() is a T-SQL function; it's not valid in Oracle. The error message indicates that you are trying to run the entire query against an Oracle database, while it appears that, when running it in Management Studio, it is executed against an MS SQL database that is linked to Oracle.
0
 
slightwv (䄆 Netminder) Commented:
Never tried to execute a select statement from Visual Studio using ODBC but...

Try removing all blank lines (might be a posting error) and/or try a semi colon at the end.  Some products like the ';', others do not.
0
 
4countyAuthor Commented:
I have removed the blank lines and tried the semi colon.  Neither worked.
I have used this same approach before in Visual Studio and have referred back to some of those previous queries but cannot figure out what the problem is.
0
 
slightwv (䄆 Netminder) Commented:
This will be my last guess since I don't have the setup to test anything.

Do any of the previous queries use CASE?  I wonder if the ODBC driver recognizes it.
0
 
4countyAuthor Commented:
I thought about that too.  I removed the CASE statement and the results were the same.  I made the statement as simple as I could make it and still get the error.  I'm sure it's a simple solution, but for the life of me I can't find it.

Thanks anyway.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.