SQL> alter session set events='10053 trace name context forever,level 1';Session altered.SQL> explain plan for 2 SELECT COUNT (*) 3 FROM t_small, t_max, t_middle 4 WHERE t_small.object_id = t_middle.object_id 5 AND t_middle.object_id = t_max.object_id; Explained.
declare l_routin varchar2(100) := 'gen2161.get_rowcnt'; l_tblnam varchar2(20) := 'emp'; l_cnt number; l_status varchar2(200); begin execute immediate 'begin ' || l_routin || '(:2, :3, :4); end;' using in l_tblnam, out l_cnt, in out l_status;
if l_status != 'OK' then dbms_output.put_line('error'); end if; end;
5. 将返回值传递到PL/SQL记录类型;同样也可用%rowtype变量
declare type empdtlrec is record (empno number(4), ename varchar2(20), deptno number(2)); empdtl empdtlrec; begin execute immediate 'select empno, ename, deptno ' || 'from emp where empno = 7934' into empdtl; end;
6. 传递并检索值.INTO子句用在USING子句前
declare l_dept pls_integer := 20; l_nam varchar2(20); l_loc varchar2(20); begin execute immediate 'select dname, loc from dept where deptno = :1' into l_nam, l_loc using l_dept ; end;