1

I am coding in SQL Developer for Oracle database and I have a simple query as follows:

select distinct location from Conference where name like '%SIGMOD%' and year >= 2003 and year <= 2008; 

When I run the query by itself, I get the expected correct result. But when I run it as part of a script I get this error:

Error starting at line : 1 in command -
select distinct location from Conference where name like ‘%SIGMOD%’ and year >= 2003 and year <= 2008
Error at Command Line : 1 Column : 58
Error report -
SQL Error: ORA-00911: invalid character
00911. 00000 -  "invalid character"
*Cause:    identifiers may not start with any ASCII character other than
           letters and numbers.  $#_ are also allowed after the first
           character.  Identifiers enclosed by doublequotes may contain
           any character other than a doublequote.  Alternative quotes
           (q'#...#') cannot use spaces, tabs, or carriage returns as
           delimiters.  For all other contexts, consult the SQL Language
           Reference Manual.

I'm not sure what is going on.

EDIT: Even if I change the part of the query to where name = 'SIGMOD', I still get the same error.

EDIT 2: Silly me, I ran that query incorrectly. where name = 'SIGMOD' does get rid of the error. However, I wonder why I can't use the like statement in the original question?

3
  • Something looks odd with that apostophe: like ‘%SIGMOD%’ -- should be a single quote. ' is different than . Commented Feb 19, 2016 at 1:40
  • Get rid of that portion of the where clause and see if it runs. I don't think it's the like vs =, but rather those apostrophes look off to me. If it runs without that part, you'll know that's the issue. Commented Feb 19, 2016 at 1:45
  • Yeah you're right. It was the apostrophes. Somehow they changed when copying and pasting from one editor to the other. Thanks. If you write that as answer I'll accept it as best. Commented Feb 19, 2016 at 1:51

1 Answer 1

1

You need to update the apostrophes to be single quotes. Change this:

select distinct location 
from Conference 
where name like ‘%SIGMOD%’ and year >= 2003 and year <= 2008

to:

select distinct location 
from Conference 
where name like '%SIGMOD%' and year >= 2003 and year <= 2008
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.