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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.