--通过创建函数 查询一个表里面的记录

1
create or replace function fun(tablename in varchar2) 2 return number 3 as 4 t number; 5 tt varchar2(300); --用来拼sql语句用的 6 begin 7 tt:='select count(*) from '|| tablename; --from后面记得加空格 8 excute immediate tt into t ; 9 return t; 10 end11 -- 执行函数 (注意:要在对话款里面执行) 12 select fun('表名') from dual;

执行结果:

 

posted on 2018-06-14 22:43  博客园197  阅读(224)  评论(0)    收藏  举报