Skip to content
Advertisement

Oracle PL/SQL ORA-00904: invalid identifier

I’m trying to declare a string and use it in a select statement but it’s throwing ORA-00904: invalid identifier.

However, if I just try to display the variable itself, it works fine.

Result:

I’m missing something here but I can’t figure out what is it.

Advertisement

Answer

Dynamic SQL is evil if you misuse it. Rule of thumb: never execute it if you didn’t check what you’re executing! How? Display the statement. Here’s how:

The result (formatted):

See the comment? where laufi = JEIV is invalid, should have been enclosed into single quotes.

Also, is tdate really a string? You’re comparing it to sysdate represented as a string in specified format. If that’s so, bad, BAD idea to store DATE datatype values as strings.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement