anaska
anaska

Reputation: 3

oracle function error pls-00103

I receive the following error when I compile this function:

Error(19,8): PLS-00103: Encountered the symbol ";" when expecting one of the following: loop

CREATE OR replace FUNCTION EXP_NOW
RETURN NUMBER
IS
  cprod   NUMBER;
  dexp    DATE;
  prodexp NUMBER := 0;
  CURSOR prodsd IS
    SELECT cod_prod,
           dat_exp
    FROM   produse;
BEGIN
    OPEN prodsd;

    LOOP
        FETCH prodsd INTO cprod, dexp;

        EXIT WHEN prodsd%NOTFOUND;

        IF ( dexp <= SYSDATE ) THEN
          prodexp := cprod;
        END IF;
    EXIT LOOP;

    CLOSE prodsd;

    RETURN prodexp;
END; 

Can someone help me? This is so frustrating.

Upvotes: 0

Views: 496

Answers (1)

Emmanuel
Emmanuel

Reputation: 14209

Can you try to use END LOOP instead of EXIT LOOP ? Basically you use LOOP and END LOOP to open/close your loop structure; you can use EXIT WHEN inside it then.

Upvotes: 1

Related Questions