sqloracle-databasepls-00103

Oracle PL/SQL Error PLS-00103


This is the code:

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; 

And when I try it out I get: ORA-06550 PLS-00103 error


Solution

  • Your select syntax is wrong, it should be

    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 ); 
    

    note that the into clause comes before FROM clause and you're terminating the statement with a semicolon in the FROM clause itself