1
votes

I keep getting these problems when all I wanted was to display the maximum salary of an employee in a job id

ORA-06550: line 12, column 6:
PL/SQL: ORA-00933: SQL command not properly ended
ORA-06550: line 8, column 6:
PL/SQL: SQL Statement ignored

Here's my code:

DECLARE
    lvc_jb_id VARCHAR2;
    lvn_max_sal NUMBER;
BEGIN
    SELECT max(salary), job_id
    INTO lvn_max_sal, lvc_jb_id
    FROM EMPLOYEES 
    group by job_id
    DBMS_OUTPUT.PUT_LINE('MAX SALARY for job_id is'|| lvn_max_sal);
    DBMS_OUTPUT.PUT_LINE('job id '|| lvc_jb_id);
END;

Can anyone tell what I did wrong?

1
1)Semicolon after group by job_id is missing 2) Length for the varchar2 variable has to be specified lvc_jb_id VARCHAR2 -> lvc_jb_id VARCHAR2(<<length>>)Nick Krasnov
My new code generates a new problem, it says: ORA-01422: exact fetch returns more than requested number of rows. Here's my new code: DECLARE lvc_jb_id VARCHAR2(50); lvn_max_sal NUMBER; BEGIN SELECT max(salary), job_id INTO lvn_max_sal, lvc_jb_id FROM EMPLOYEES group by job_id; DBMS_OUTPUT.PUT_LINE('MAX SALARY for job_id is'|| lvn_max_sal); DBMS_OUTPUT.PUT_LINE('job id '|| lvc_jb_id); END;Dwayne Radar

1 Answers

2
votes

Specify the size of the string. eg: lvc_jb_id VARCHAR2(50);

End the select query with semicolon. Now it should work.