plsql错误无效的数字

时间:2011-03-05 05:39:51

标签: sql oracle plsql ora-01722

时出现无效的数字错误
procedure Afficher(opt int,id int) is
type emp is record(fn employees.first_name%type,
                   lname employees.last_name%type,
                   job jobs.job_title%type,
                   dep departments.department_id%type);
emp1 emp;
begin
select e1.first_name,e1.last_name,j.job_title,d.department_name into emp1
from employees e1 ,jobs j,departments d where e1.employee_id= 'id' and 
e1.job_id=j.job_id and e1.department_id =d.department_id ;

      dbms_output.put_line('Name      Job       Department');
      dbms_output.put_line(emp1.fn||''|| emp1.lname||'     '
            ||emp1.job||'   '||emp1.dep);

end Afficher;

2 个答案:

答案 0 :(得分:4)

您正在寻找e1.employee_id='id';它实际上是一个字符串,还是一个数字?

答案 1 :(得分:3)

你可能想要:

procedure Afficher(opt int,id int) is
type emp is record(fn employees.first_name%type,
                   lname employees.last_name%type,
                   job jobs.job_title%type,
                   dep departments.department_id%type);
emp1 emp;
begin
select e1.first_name,e1.last_name,j.job_title,d.department_name into emp1
from employees e1 ,jobs j,departments d where e1.employee_id= id and 
e1.job_id=j.job_id and e1.department_id =d.department_id ;

      dbms_output.put_line('Name      Job       Department');
      dbms_output.put_line(emp1.fn||''|| emp1.lname||'     '
            ||emp1.job||'   '||emp1.dep);

end Afficher;

即。 id 变量周围没有引号。

将变量重命名为* emp_id *或类似的东西可能更好。