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

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;

执行结果: 通过函数查询表记录 Oracle

 

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄