Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Pl/sql to check if the record exits already in the table , if yes then find the max salary ?

AS08Aug 2 2022

What is wrong with this -
set serveroutput on
Declare
app number;
BEGIN
If EXISTS(SELECT * employee_id from employees where manager_id=100) THEN
Select max(salary)into app from employees;
dbms_output.put_line(app);
End IF;
end;

Error Output -
Declare
app number;
BEGIN
If EXISTS(SELECT * employee_id from employees where manager_id=100) THEN
Select max(salary)into app from employees;
dbms_output.put_line(app);
End IF;
end;
Error report -
ORA-06550: line 4, column 21:
PLS-00103: Encountered the symbol "EMPLOYEE_ID" when expecting one of the following:

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

* & - + ; / at for mod remainder rem <an exponent (**)> and
or group having intersect minus order start union where
connect || multiset
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:

Please advise - How to check if the record exists or not whose manager id = 100 , if yes then it should select the max salary from the records whose manager id = 100 and store it into a variable?

This post has been answered by Frank Kulash on Aug 2 2022
Jump to Answer
Comments
Post Details
Added on Aug 2 2022
5 comments
620 views