我现在就需要一个数组存放几个数据,在之后的程序中会需要用sql语句来判断某个字段的值是否在几个数据中,怎么实现简单?

解决方案 »

  1.   

    SQL> drop type testa;Type droppedSQL> create type testa is table of varchar2(10);
      2  /Type createdSQL> set serverout on;SQL> declare
      2  t_test testa := testa('a','b','c');
      3  cnt integer;
      4  begin
      5       select count(*) into cnt from t where b in (select column_value from table(t_test));
      6       dbms_output.put_line('output:' || cnt);
      7  end;
      8  /output:3PL/SQL procedure successfully completed
      

  2.   

    SQL> delete from t where b = 'b';1 row deletedSQL> commit;Commit completeSQL> select b from t;B
    -----
    a
    c
    d
    eSQL> 
    SQL> declare
      2  t_test testa := testa('a','b','c');
      3  cnt integer;
      4  begin
      5       select count(*) into cnt from t where b in (select column_value from table(t_test));
      6       dbms_output.put_line('output:' || cnt);
      7  end;
      8  /output:2PL/SQL procedure successfully completed