Search code examples
sqloracleora-00923

error ORA-00923


I am getting the following error "ORA-00923: FROM keyword not found where expected" while executing the query, NOTE: already am using this query with different tables and its working ,so please i need your help :)


LOAD * ,
date(POST_DATE,'MM/DD/YYYY') as VOU_POST_DATE,
date(CREATED_DATE,'MM/DD/YYYY') as VOU_CREATED_DATE,
year (POST_DATE) as VOU_POST_YEAR ,
month (POST_DATE) as VOU_POST_MONTH,
day (POST_DATE) as VOU_POST_DAY, 
year (CREATED_DATE) as VOU_CREATED_YEAR ,
month (CREATED_DATE) as VOU_CREATED_MONTH,
day (CREATED_DATE) as VOU_CREATED_DAY;

Select 
t.QTY as VOU_QTY,
t.COST as VOU_COST,
t.PRICE as VOU_PRICE,
t.QTY*t.COST as VOU_EXT_COST,
t.QTY*t.PRICE as VOU_EXT_PRICE,
t.ITEM_SID,
o.STORE_NO as VOU_STORE_NO,
o.VOU_NO,
o.VOU_TYPE, 
o.VOU_CLASS,
o.VEND_CODE as VOU_VEND_CODE,
o.SLIP_FLAG,
o.TO_NO,
o.REF_VOU_SID,
o.CREATED_DATE,
o.POST_DATE,
o.SLIP_FLAG as SLIP_FLAGS,
o.VERIFIED,
st.QTY as TRANS_OUT_QTY
s.OUT_STORE_NO as SLIP_OUT_STORE,
s.IN_STORE_NO as SLIP_IN_STORE,


CASE
when o.VEND_CODE is not NULL
and o.TO_NO is NULL 
then t.QTY
else 0
end CMP_RCVD_QTY,


CASE
when o.VEND_CODE is NULL 
and o.TO_NO is not NULL 
then t.QTY
else 0
end FST_RCVD_QTY,


CASE
when o.VEND_CODE is NULL 
and o.TO_NO is NULL 
then t.QTY
else 0
end TRANS_IN_QTY,

CASE
when o.VOU_CLASS=2 
then t.QTY
else 0
end ASN_QTY,

from VOUCHER o
join VOU_ITEM t
on o.VOU_SID = t.VOU_SID 

Join SLIP s
on s.VOU_SID = o.VOU_SID 

join  SLIP_ITEM st
on st.ITEM_SID = t.ITEM_SID
where 
o.HELD=0 and o.REF_VOU_SID is NULL;

Solution

  • Add , after TRANS_OUT_QTY

    o.VERIFIED,
    st.QTY as TRANS_OUT_QTY
    s.OUT_STORE_NO as SLIP_OUT_STORE,
    

    and remove , before from clause.

    CASE
    when o.VOU_CLASS=2 
    then t.QTY
    else 0
    end ASN_QTY,
    
    from VOUCHER o
    join VOU_ITEM t
    on o.VOU_SID = t.VOU_SID
    

    Oracle expects FROM keyword where we end our comma separated column-list. As you can see, you have forgotten to type , after st.QTY as TRANS_OUT_QTY it expects FROM clause right after it hence the error ORA-00923: FROM keyword not found where expected.

    Once you fix the first syntax error you will be hit by another error called ORA-00936: missing expression as you have provided extra , after end ASN_QTY, which indicates there are more expressions after the , but there are not.