Isha
Isha

Reputation: 45

PLS-00103: Encountered the symbol ")" when expecting one of the following: (

I am a beginner in oracle and following is my function definition and invocation part. I am unable to understand the error that I get when I call the function. Please help me rectify my code.

ORA-06550: line 4, column 56: PLS-00103: Encountered the symbol ")" when expecting one of the following: (

create or replace function totalcustomers
RETURN number
IS
total number:=0;
BEGIN
select count(*) into total from customers;
RETURN total;
END;
/

declare sum number;
BEGIN
sum := totalcustomers();
dbms_output.put_line('Total number of customers '||sum);
END;
/

Upvotes: 1

Views: 1649

Answers (3)

Isha
Isha

Reputation: 45

The function invocation part was throwing the mentioned error, because "sum" might be a pre-defined keyword in oracle. Changing the variable as follows helped.

declare x number;
BEGIN
x:=totalcustomers();
dbms_output.put_line(' Total number of customers: '||x);
END;
/

Output : Statement processed. Total number of customers: 6

Upvotes: 0

Gary_W
Gary_W

Reputation: 10360

Sum is a function, so it's expecting the open paren. Rename the variable.

Upvotes: 0

Barbaros Özhan
Barbaros Özhan

Reputation: 65393

Do not use sum as a variable which is a reserved keyword in Oracle.

Upvotes: 1

Related Questions