一句sql不好实现,用个脚本块,返回记录集,使用动态sql应该可以解决

解决方案 »

  1.   

    create or replace function get_value(theid in number) return varchar2
    is
     rtVal varchar2(4000):=null;
     tname varchar2(30):=null;
    begin
     select nexttablename into tname from a where id=theid;
     
     execute immediate 'select info from ' || tname || ' where id=' || theid into rtVal;
     
     return rtVal;
    exception
     when others then return null;
    end;
    /