1
CREATE OR REPLACE procedure verify_employee
(emp_license IN trkdriver.L#%TYPE) 
IS
result VARCHAR2(10);

BEGIN
select e# INTO result
from trkdriver where l#='emp_license';
END;
/

以上是我的程序

SQL> desc trkdriver;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------

 E#                                        NOT NULL NUMBER(12)
 L#                                        NOT NULL NUMBER(8)
 STATUS                                    NOT NULL VARCHAR2(10)

我尝试过了

SQL> execute verify_employee('10001');
BEGIN verify_employee('10001'); END;

*
ERROR at line 1:
ORA-01722: invalid number
ORA-06512: at "USER1.VERIFY_EMPLOYEE", line 7
ORA-06512: at line 1

我做错了什么,我只想尝试一个简单的程序,该程序将根据我输入的员工许可证 ID 进行选择

4

2 回答 2

1

您必须删除''如下:

CREATE OR REPLACE procedure verify_employee
(emp_license IN trkdriver.L#%TYPE) 
IS
result VARCHAR2(10);

BEGIN
select e# INTO result
from trkdriver where l#=emp_license;
END;
/

结束运行它:

execute verify_employee(10001);
于 2012-11-25T18:48:48.183 回答
0

l#是数字,您将其与字符串进行比较: ... where l#='emp_license';

于 2012-11-25T18:47:12.180 回答