Oracle PL / SQL错误PLS-00103

时间:2014-08-27 07:48:50

标签: sql oracle 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错误

1 个答案:

答案 0 :(得分: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 ); 

请注意,into子句出现在FROM子句之前,并且您在FROM子句本身中使用分号终止语句