id1为varchar2值为8,9
delete from s where a=181 and b not in ( id1 );
数据如下:
id     a     b 
1     181    8
2     181    9
3     181    10
4     181    11
删除id为3,4的
是存储过程
报错是无效数字。这个怎么解决

解决方案 »

  1.   

    delete from s where a=181 and b not in ( id1 ); 红色部分应该换成具体的值要不的话你就要用动态sql了
      

  2.   

    delete from s where a=181 and b not in ( 8,9); 那就这样写了
      

  3.   

    那就只能拼字符串
    aa:=’8,9,10,11';
    select * from test where instr(','||aa||',',','||name||',')<=0
      

  4.   

    存储过程?CREATE OR REPLACE PROCEDURE TEST
    IS
    BEGIN
    declare
      aa varchar(20);
     begin
      aa:='8,9,10,11';
      delete from s where instr(',' ¦ ¦aa ¦ ¦',',',' ¦ ¦id1¦ ¦',') <=0 
      EXCEPTION
        WHEN OTHERS THEN
            DBMS_OUTPUT.PUT_LINE(TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS')||SQLCODE || SQLERRM);
            RAISE;
     end;
    END;
    /
    这样你试试