SQL - 此过程执行有什么问题

时间:2012-11-25 18:43:58

标签: sql oracle

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进行选择

2 个答案:

答案 0 :(得分: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);

答案 1 :(得分:0)

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