2014-08-27 72 views
1

這是代碼:的Oracle PL/SQL錯誤PLS-00103

set serveroutput ON; 
DECLARE 
    id_emp  NUMBER := '&EmpleadoNumero'; 
    n_commission DOUBLE; 
BEGIN 
    SELECT i.id, 
      Decode(i.commission_pct, SUM(i.commission_pct) > 100000, 
      i.commission_pct + (i.commission_pct * .10), 
            SUM(i.commission_pct) > 100000 
            AND SUM(i.commission_pct) < 1000000, 
      i.commission_pct + (i.commission_pct * .15), 
            SUM(i.commission_pct) > 1000000, 
      i.commission_pct + (i.commission_pct * .20), 
            0) N_Commission 

    FROM s_emp i 
      inner join s_ord S 
        ON (i.id = S.sales_rep_id); 
    INTO id_emp, n_commission; 

    dbms_output.Put_line('El empleado numero: ' 
         || idemp 
         || ' tiene una nueva comisión de: ' 
         || n_comision); 
END; 

,當我嘗試它,我得到:ORA-06550 PLS-00103錯誤

+0

你SE選擇權聲明沒有意義。你想在這裏計算什麼? – Noel 2014-08-27 07:58:27

+0

給定員工的佣金百分比 – Ilemar 2014-08-27 09:00:12

回答

0

你選擇的語法是錯誤的,它應該

SELECT i.id, 
     Decode(i.commission_pct, SUM(i.commission_pct) > 100000, 
     i.commission_pct + (i.commission_pct * .10), 
           SUM(i.commission_pct) > 100000 
           AND SUM(i.commission_pct) < 1000000, 
     i.commission_pct + (i.commission_pct * .15), 
           SUM(i.commission_pct) > 1000000, 
     i.commission_pct + (i.commission_pct * .20), 
           0) N_Commission 
INTO id_emp, n_commission 
FROM s_emp i 
     inner join s_ord S 
       ON (i.id = S.sales_rep_id); 

注意,到子句FROM子句來之前,你要終止與分號的語句在FROM子句本身