orcale 动态执行语句
create or replace function fn_test2(tablename in varchar2) return number is
rtn number;
begin
--通用的获取表的数据长度的函数
--执行的语句不是固定的,通过参数组合成的
--解决如何执行动态语句
execute immediate ' select count(1) from ' ||tablename into rtn; ---拼接语句时 from后面要记得加空格
return(rtn);
--捕获异常
exception when others then
--处理异常
dbms_output.put_line('付士亮,发生异常');
return(-1);
end fn_test2;


浙公网安备 33010602011771号