有表table1 含字段id等;有个记录表,如下
TYPE TBL_TYPE IS TABLE OF  table1%ROWTYPE   INDEX BY PLS_INTEGER;
  TB  TBL_TYPE; 给TB赋值
  SELECT *  BULK COLLECT INTO TB FROM table1;这时我想将TB中的id列和其它表进行关联查询,请问怎么写

select count(1) into i from table2,(TB中的id列集合) z
where table2.id=(TB中的id)
上面括号中的地方该怎么写呢?

解决方案 »

  1.   

    不知道可不可以,试试如下写法
    select count(1) into i from table2,(SELECT ID FROM TABLE(CAST TB AS TBL_TYPE)) z
    where table2.id=(Z.ID)
      

  2.   

    是不是这样啊?select count(1) into i from table2
    where table2.id in (select id from TB)//也就是你的id的集合
      

  3.   

    select count(1) into i from table2
    where table2.id =TB.id)