Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Invalid identifier in PLSQL

I want to print employee information according to employee-id. But when I compile code I get this error

Here is my code

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

CREATE OR REPLACE PROCEDURE EmployeeInfo(empid  number)
IS
fname varchar(20);
lname varchar(40);
empemail   number(10);
ephone VARCHAR(10);
title varchar(20);
BEGIN 
     SELECT first_name,last_name,email,phone,job_title
     INTO fname,lname,empemail,ephone,title
     FROM employees
     WHERE employee_id=empid;
     DBMS_OUTPUT.PUT_LINE( 'First Name: '||first_name );
     DBMS_OUTPUT.PUT_LINE( 'Last Name: '||last_name );
     DBMS_OUTPUT.PUT_LINE( 'Email: '||email );
     DBMS_OUTPUT.PUT_LINE( 'Phone: '||phone );
     DBMS_OUTPUT.PUT_LINE( 'job_title: '||job_title );
END; 
/

EXECUTE employeeinfo(107);

>Solution :

You should display local variables’ values, not table columns.

CREATE OR REPLACE PROCEDURE EmployeeInfo(empid  number)
IS
fname varchar(20);
lname varchar(40);
empemail   number(10);
ephone VARCHAR(10);
title varchar(20);
BEGIN 
     SELECT first_name,last_name,email,phone,job_title
     INTO fname,lname,empemail,ephone,title
     FROM employees
     WHERE employee_id=empid;
     DBMS_OUTPUT.PUT_LINE( 'First Name: '||fname);
     DBMS_OUTPUT.PUT_LINE( 'Last Name: '||lname);
     DBMS_OUTPUT.PUT_LINE( 'Email: '||empemail);
     DBMS_OUTPUT.PUT_LINE( 'Phone: '||ephone );
     DBMS_OUTPUT.PUT_LINE( 'job_title: '||title);
END; 
/
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading