0

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.

Abdelhak
  • 176
  • 2
  • 12

1 Answers1

0

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.

cableload
  • 4,215
  • 5
  • 36
  • 62