Home > Back-end >  Invalid identifier in PLSQL
Invalid identifier in PLSQL

Time:11-07

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

Here is my code
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);

CodePudding user response:

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; 
/
  • Related