ORA-00936: Missing Expression error occurs when there is a syntax error in the SQL statement. In this case, the error is most likely caused by an extra comma (,) after the wrap_flag column in the SELECT clause of the SQL statement.

To fix the error, remove the extra comma (,) after the wrap_flag column in the SELECT clause. The corrected SQL statement should be as follows:

SELECT 
    r.ward_code,
    NVL(dd.dept_alias, dd.dept_code) ward_name,
    r.dispense_code,
    CASE WHEN r.wrap_flag = 1 THEN 1 ELSE 0 END wrap_flag,
    r.dispensing_date_time dispense_time,
    r.dispensary,
    1 dispense_type,
    sd.staff_name dispensing_emp_name 
FROM 
    drug_dispense_master r,
    dept_dict dd,
    staff_dict sd 
WHERE 
    sd.emp_id = r.dispensing_provider 
    AND dd.dept_code = r.ward_code 
    AND r.dispensing_date_time BETWEEN ? AND ? 
    AND r.dispensary = ? 
    AND NVL(r.SUPPLY_STATE, 1) = 1 
    AND NOT EXISTS (
        SELECT 1 
        FROM drug_dispense_delivery_detail a 
        WHERE a.dispense_code = r.dispense_code
    ) 
    AND ward_code IN (?) 
GROUP BY 
    r.dispensary,
    r.ward_code,
    r.dispense_code,
    r.wrap_flag,
    NVL(dd.dept_alias, dd.dept_code),
    sd.staff_name,
    r.dispensing_date_time
``

原文地址: http://www.cveoy.top/t/topic/iZPH 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录