CREATE OR REPLACE TYPE record_AB AS OBJECT
(
AA VARCHAR2 (32767 BYTE),
BB VARCHAR2 (32767 BYTE)
);
/
CREATE OR REPLACE TYPE type_tab_AB IS TABLE OF record_AB;
/
SQL> VARIABLE curs1 REFCURSOR;
SQL>
SQL> DECLARE
2 tab_AB type_tab_AB;
3 begin
4 select system.record_AB(t.owner,t.table_name) bulk collect into tab_AB from dba_tables t where compression='ENABLED' and compress_for='OLTP';
5 open :curs1 for select * from table(tab_AB) ;
6 end;
7 /
PL/SQL procedure successfully completed.
SQL> select * from dba_segments where (owner,segment_name) in ( select :curs1 from dual);
select * from dba_segments where (owner,segment_name) in ( select :curs1 from dual)
ERROR at line 1:
ORA-00947: not enough values
我需要提供游标curs1的aa,bb列的值作为owner和segment_name的输入,有人可以告诉我们如何实现这个吗?
答案 0 :(得分:0)
您无法选择游标变量,只能打开,获取和关闭它。你想要实现什么目标?这里根本不需要使用引用光标:
select * from dba_segments
where (owner,segment_name) in
( select t.owner,t.table_name
from dba_tables t
where compression='ENABLED'
and compress_for='OLTP');
但是,如果您的代码的目的是使用ref游标,而不是查看分段数据,那么这个答案可能不是您想要的。
使用表格:
create table enabled_oltp_tables as
select t.owner,t.table_name
from dba_tables t
where compression='ENABLED'
and compress_for='OLTP';
select * from dba_segments
where (owner,segment_name) in
( select t.owner,t.table_name
from enabled_oltp_tables t
);
答案 1 :(得分:0)
您好。刚刚完成了这个问题。以为你可以尝试一下 这个。如果有帮助,请告诉我
--Create object type
CREATE OR REPLACE TYPE record_AB
AS
OBJECT
(
AA VARCHAR2 (32767 BYTE),
BB VARCHAR2 (32767 BYTE) );
--Create table type
CREATE OR REPLACE TYPE type_tab_AB
IS
TABLE OF record_AB;
--Plsql block to perform action
var ref_c refcursor;
DECLARE
tab_AB type_tab_AB;
BEGIN
SELECT record_AB(t.owner,t.table_name) bulk collect
INTO tab_AB
FROM all_tables t
WHERE compression='ENABLED';
OPEN :ref_c FOR SELECT * FROM dba_segments WHERE (owner,segment_name) IN
( SELECT t.aa,t.bb FROM TABLE(tab_AB) t
);
END;
Print ref_c;