我有一个包含 2 列的集合 创建或替换类型typ_tbl_column是typ_OBJ_column的表;
创建或替换类型 type_OBJ_column 为对象 (Col1 varchar2(4000), Col2 varchar2(4000);
创建或替换类型type_tbl_emo是数字表;
声明 lv_tbl_RU_record_listtyp_tbl_column; Lv_tbl_emo type_tbl_emo;
开始 从employee_details中选择typ_obj_column(emo_no, emo_name)批量收集到lv_tbl_RU_record_list中;
现在,当我这样做时
从表(lv_tbl_RU_record_list)中选择col1批量收集到lv_tbl_emo,其中col2在('Sam','prince');
它的计数为零..但是当我删除 where 子句时它返回 2 行..请让我知道 where 子句有什么问题
结束;
描述中提到
如果你:
然后你的代码就可以工作了:
CREATE TABLE employee_details(emo_no, emo_name) AS
SELECT 1, 'Alice' FROM DUAL UNION ALL
SELECT 2, 'Betty' FROM DUAL UNION ALL
SELECT 3, 'Carol' FROM DUAL UNION ALL
SELECT 4, 'Diana' FROM DUAL
/
Create type typ_OBJ_column is object (
Col1 varchar2(4000),
Col2 varchar2(4000)
)
/
Create type typ_tbl_emo is table of number
/
Create type typ_tbl_column is table of typ_OBJ_column
/
Declare
Lv_tbl_RU_record_list typ_tbl_column;
Lv_tbl_emo typ_tbl_emo;
Begin
Select typ_obj_column(emo_no, emo_name)
bulk collect into lv_tbl_RU_record_list
from employee_details;
Select col1
bulk collect into lv_tbl_emo
from table(lv_tbl_RU_record_list)
where col2 in ('Alice','Carol');
FOR i IN 1 .. lv_tbl_emo.COUNT LOOP
DBMS_OUTPUT.PUT_LINE(lv_tbl_emo(i));
END LOOP;
END;
/
输出:
1
3