Home > Software engineering >  ORA 00936 Missing Expression sql statement
ORA 00936 Missing Expression sql statement

Time:10-01

I am trying to get a response from a Oracle client and getting a ORA 00936 Missing Expression Error.

This is the sql I am trying to send:

SELECT "Q_FISCAL_DTE",
    "Q_BL_ORG_ID",
    "Q_BP_ID",
    "Q_TPTY_ID",
    "Q_CP_CASH_SUMM_ID",
    "Q_PAYOR_CDE",
    "Q_MKT_SEG_CDE",
    "Q_BU_ID",
FROM "SYSADM"."PS_Q_CP_CASH_SUMM"
WHERE "Q_BU_ID" NOT IN (‘IP’,’ES’,’SJ’,’PR’) 
AND "Q_FISCAL_DTE" >6/1/2021’;

CodePudding user response:

Remove comma after last column in SELECT and change quotas ‘ to '.

CodePudding user response:

Try to rewrite the query following these advices

  • Don't use double quotes unless the metadata ( tables, columns ) is stored in lowercase. Oracle always stored all metadata in uppercase.
  • I believe you have a copy & paste error, because the quotation should be '
  • Last comma is wrong, thus the error you are getting as Oracle is waiting for an additional field.

So, it should be

SELECT Q_FISCAL_DTE,
    Q_BL_ORG_ID,
    Q_BP_ID,
    Q_TPTY_ID,
    Q_CP_CASH_SUMM_ID,
    Q_PAYOR_CDE,
    Q_MKT_SEG_CDE,
    Q_BU_ID
FROM SYSADM.PS_Q_CP_CASH_SUMM
WHERE Q_BU_ID NOT IN ('IP','ES','SJ','PR') 
AND Q_FISCAL_DTE > '6/1/2021';

However, if Q_FISCAL_DTE is a date, then

SELECT Q_FISCAL_DTE,
    Q_BL_ORG_ID,
    Q_BP_ID,
    Q_TPTY_ID,
    Q_CP_CASH_SUMM_ID,
    Q_PAYOR_CDE,
    Q_MKT_SEG_CDE,
    Q_BU_ID
FROM SYSADM.PS_Q_CP_CASH_SUMM
WHERE Q_BU_ID NOT IN ('IP','ES','SJ','PR') 
AND Q_FISCAL_DTE >  to_date('6/1/2021','MM/DD/YYYY') ;

On the other hand, if the date 6/1/2021 represents day/month/year , then apply the other mask

SQL> select to_date('6/1/2021','DD/MM/YYYY') from dual ;

TO_DATE('
---------
06-JAN-21
  • Related