2

我收到无效号码错误时

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;
4

2 回答 2

4

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

于 2011-03-05T05:52:00.623 回答
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* 或类似名称。

于 2011-03-05T09:53:25.457 回答