Link to home
Start Free TrialLog in
Avatar of P.J. Hughes
P.J. HughesFlag for United States of America

asked on

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



Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

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.
Avatar of P.J. Hughes

ASKER

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.
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.
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.
ASKER CERTIFIED SOLUTION
Avatar of mustaccio
mustaccio
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial