Oracle error – "Pending": invalid identifier

i’m creating a query with typeorm with oracle.

I’m using this in a select, because the status can be null.

'NVL(Details.status, "Pending") AS "PostulationDetail_status"'

I have used this before but using 0, because i was working with numbers. I decided to test with strings and i got surprised. i get this error on console

[Nest] 620  - 18-11-2021 12:20:29   ERROR [ExceptionsHandler] ORA-00904: "Pending": invalid identifier
QueryFailedError: ORA-00904: "Pending": invalid identifier

I don’t know how to write the query so it is valid. Does anyone had an experience like this ?

>Solution :

You want to use single quotes around string literals and either no quotes (the preferable, case-insensitive option) or double quotes (case-sensitive) around identifiers:

NVL(Details.status, 'Pending') AS "PostulationDetail_status"

If you use double quotes:

NVL(Details.status, "Pending") AS "PostulationDetail_status"

Then you are saying to return the DETAILS.STATUS value (this identifier is case-insensitive) or, if that is NULL then, use the value of the Pending column (this identifier is case-sensitive) and alias the value as PostulationDetail_status (again, case-sensitive).

Leave a Reply