写一个select dept_id from emp where emp_id='a001' 的函数不是很呆么??
我想如果有一个公共函数 
同一张表里的由一个字段得到另一个字段我想会不会有一个公共函数啊要不这样写函数岂不写到死???:(

解决方案 »

  1.   

    select c.name,c.modify_emp_id,d.name from client c,emp e,dept d
    where c.modify_emp_id=e.emp_id and e.dept_id=d.dept_id;不作表连接的根本取不到部门的信息。即使使用函数也是在函数内部使用表连接的
      

  2.   

    "同一张表里的由一个字段得到另一个字段我想会不会有一个公共函数啊"
    ——ORACLE没有这种函数。我想DEPT()不应该是你写的这样子的。
    create or replace function dept(empid in varchar2) return varchar2 
    is 
    deptid varchar2(200);
    begin
    select dept_id into deptid from emp where emp_id=empid;
    return deptid;
    end;上面做表连接也不错,为什么不想做表连接呢?
      

  3.   

    to :  nottinghill这个应该满足你的要求了吧,速度应该是最快的了哦 :)select name ,modify_emp_id,
           (select name from emp where emp_id = modify_emp_id) emp_name from client
      

  4.   

    hehe,好强啊,说说运行机制啊 ,我给你分
      

  5.   

    select name ,modify_emp_id,
           (select name from emp where emp_id = modify_emp_id) emp_name from client
    这不还是表连接吗,只是换个写法
      

  6.   

    hehe ,我也知道是朝三暮四,但我可以实现就可以了,这样写至少 from 后面是统一的,好操作!!谢谢各位大侠指点啊我还知道 这能实现是为什么啊??