select user_profiles.user_ename  
into t_user_ename//必须有into,保存到变量中
from tbname
where user_profiles.user_id=tbname.sales_id

解决方案 »

  1.   

    into語句不是只允許一個值嗎?
      

  2.   

    CREATE OR REPLACE PACKAGE pkg_test
    AS
       TYPE myrctype IS REF CURSOR;
    END pkg_test;
    /create or replace function FNUSER_ENAME(tbname varchar2) 
    return pkg_test.myrctype is
     v_rc pkg_test.myrctype;
      Result varchar2(50);
    begin
    result:='select user_profiles.user_ename  
    from '||tbname||'
    where user_profiles.user_id='||tbname||'.sales_id';
    open v_rc for result;
    return(v_rc);
    end FNUSER_ENAME;
    /