如何修复 plsql 中的 'Encountered the symbol "=" when expecting one of the following:' 错误
How to fix 'Encountered the symbol "=" when expecting one of the following:' error in plsql
我正在尝试使用 PL/SQL 过程从 table 获取结果
这是程序
CREATE OR REPLACE PROCEDURE getEmpById(
e_id IN employee.empid%TYPE,
emp_name OUT employee.empname%TYPE,
emp_desig OUT employee.designation%TYPE)
IS
BEGIN
SELECT empname,designation INTO emp_name, emp_desig FROM employee WHERE empid = e_id;
END;
/
这是调用块
DECLARE
e_id:=&e_id;
emp_name employee.empname%TYPE;
emp_desig employee.designation%TYPE;
BEGIN
getEmpById(e_id,emp_name,emp_desig);
DBMS_OUTPUT.PUT_LINE('Name : ' || emp_name);
DBMS_OUTPUT.PUT_LINE('Designation : ' || emp_desig);
END;
/
这是我遇到的错误
Enter value for e_id: 'AIT005'
old 2: e_id:=&e_id;
new 2: e_id:='AIT005';
e_id:='AIT005';
*
ERROR at line 2:
ORA-06550: line 2, column 8:
PLS-00103: Encountered the symbol "=" when expecting one of the following:
constant exception <an identifier>
<a double-quoted delimited-identifier> table LONG_ double ref
char time timestamp interval date binary national character
nchar
The symbol "<an identifier>" was substituted for "=" to continue.
您缺少 E_ID 的数据类型(在 DECLARE
部分)。
这是一个例子:
SQL> create table employee (empid number, empname varchar2(10), designation varchar2(10));
Table created.
SQL> insert into employee values (1, 'Little', 'Foot');
1 row created.
SQL> create or replace procedure getempbyid(
2 e_id in employee.empid%type,
3 emp_name out employee.empname%type,
4 emp_desig out employee.designation%type)
5 is
6 begin
7 select empname,designation into emp_name, emp_desig from employee where empid = e_id;
8 end;
9 /
Procedure created.
测试:
SQL> set serveroutput on
SQL> set ver off
SQL> declare
2 e_id employee.empid%type := &e_id; --> you're missing E_ID datatype here
3 emp_name employee.empname%type;
4 emp_desig employee.designation%type;
5 begin
6 getempbyid(e_id,emp_name,emp_desig);
7 dbms_output.put_line('Name : ' || emp_name);
8 dbms_output.put_line('Designation : ' || emp_desig);
9 end;
10 /
Enter value for e_id: 1
Name : Little
Designation : Foot
PL/SQL procedure successfully completed.
SQL>
我正在尝试使用 PL/SQL 过程从 table 获取结果
这是程序
CREATE OR REPLACE PROCEDURE getEmpById(
e_id IN employee.empid%TYPE,
emp_name OUT employee.empname%TYPE,
emp_desig OUT employee.designation%TYPE)
IS
BEGIN
SELECT empname,designation INTO emp_name, emp_desig FROM employee WHERE empid = e_id;
END;
/
这是调用块
DECLARE
e_id:=&e_id;
emp_name employee.empname%TYPE;
emp_desig employee.designation%TYPE;
BEGIN
getEmpById(e_id,emp_name,emp_desig);
DBMS_OUTPUT.PUT_LINE('Name : ' || emp_name);
DBMS_OUTPUT.PUT_LINE('Designation : ' || emp_desig);
END;
/
这是我遇到的错误
Enter value for e_id: 'AIT005'
old 2: e_id:=&e_id;
new 2: e_id:='AIT005';
e_id:='AIT005';
*
ERROR at line 2:
ORA-06550: line 2, column 8:
PLS-00103: Encountered the symbol "=" when expecting one of the following:
constant exception <an identifier>
<a double-quoted delimited-identifier> table LONG_ double ref
char time timestamp interval date binary national character
nchar
The symbol "<an identifier>" was substituted for "=" to continue.
您缺少 E_ID 的数据类型(在 DECLARE
部分)。
这是一个例子:
SQL> create table employee (empid number, empname varchar2(10), designation varchar2(10));
Table created.
SQL> insert into employee values (1, 'Little', 'Foot');
1 row created.
SQL> create or replace procedure getempbyid(
2 e_id in employee.empid%type,
3 emp_name out employee.empname%type,
4 emp_desig out employee.designation%type)
5 is
6 begin
7 select empname,designation into emp_name, emp_desig from employee where empid = e_id;
8 end;
9 /
Procedure created.
测试:
SQL> set serveroutput on
SQL> set ver off
SQL> declare
2 e_id employee.empid%type := &e_id; --> you're missing E_ID datatype here
3 emp_name employee.empname%type;
4 emp_desig employee.designation%type;
5 begin
6 getempbyid(e_id,emp_name,emp_desig);
7 dbms_output.put_line('Name : ' || emp_name);
8 dbms_output.put_line('Designation : ' || emp_desig);
9 end;
10 /
Enter value for e_id: 1
Name : Little
Designation : Foot
PL/SQL procedure successfully completed.
SQL>