PLS-00103: Encountered the symbol "BEGIN"

2.9k Views Asked by At

I want to create a function that return the power of a given number, the SQL developer keep giving me this error :

PLS-00103: Encountered the symbol "BEGIN"

Errors: check compiler log

Here's my code

CREATE OR REPLACE FUNCTION Power(x NUMBER,n NUMBER) return Number IS
    Pow number;
    i number;
    BEGIN
    Pow:=1;

    FOR i IN 1..n LOOP
    Pow:=Pow*x;
    END LOOP;
    return Pow;
    END Power;

    BEGIN
    DBMS_OUTPUT.PUT_LINE(Power(2,3));
    END;

Thank you for helping me I really appreciate it.

1

There are 1 best solutions below

0
On BEST ANSWER

Your pl/sql function compiles fine without error. Its probably complaining about the code where you are trying to call the above function.

 BEGIN
   DBMS_OUTPUT.PUT_LINE(Power(2,3));
 END;

First create your function and then call the function in a separate editor with the above code.