oracle-databasestored-procedurespls-00103

Error on creating stored procedure under Oracle - PLS-00103


Im trying to create a stored procedure that calls another a number of times. This is done so by using a for each loop. All the development is under oracle sql developer Version 3.0.04.

    CREATE OR REPLACE PROCEDURE Z_INBILLABILITYSERV
    IS BEGIN
      DECLARE
        ano VARCHAR2(4); 
      BEGIN
        select EXTRACT(YEAR FROM sysdate) into ano from dual;
        FOR dat IN (SELECT * FROM Z_FECHOMES WHERE MES <= 
                   (select EXTRACT(MONTH FROM sysdate) from dual )and ANO = ano)
        LOOP
          call z_insertbillability(dat.periodo_inicio,dat.periodo_fim,
                                                                dat.ano,dat.mes);
        END LOOP;
      END;
    END;

Im having the following error:

Error(9,12): PLS-00103: Encountered the symbol "Z_INSERTBILLABILITY" when expecting one of the following: := . ( @ % ; The symbol ":=" was substituted for "Z_INSERTBILLABILITY" to continue.

If anyone have an idea or a tip i would be glad to now and would appreciate a lot.


Solution

  • You do not need the word call; just do:

        LOOP
          z_insertbillability(dat.periodo_inicio,dat.periodo_fim,
                                                                dat.ano,dat.mes);
        END LOOP;
    

    The error message is perhaps a bit unhelpful, but it's to be trying to show all the ways it could try to interpret the word call, since it doesn't recognise it as a keyword. And showing what it would expect to see next for each: as a variable name (which would be followed by := for assignment; or a schema name (which would be followed by .); or a function/procedure name (which would be followed by ( for the parameter list), etc.