b    number(2);strSql:='select a into b from A'
Execute immediate strSql;
commit;各位高手,在这个SQL中,我怎么把b的值取出来啊?
调试的时候走到commit就报错,请高手帮忙解决一下,谢谢

解决方案 »

  1.   


    declare
       b number(2);
    begin
       select a
         into b
         from A;  dbms_out.put_line('b的值为:'||b);
    exception
      when others then;
        dbms_out.put_line('未找到数据!');
    end;
      

  2.   

    这样不行,这个表是动态组成的
    然后我要在这个表里查出字段a的值,放到变量b中,后面要用到b的值
      

  3.   

    strSql:='select a from A'
    Execute immediate strSql into b;
    commit;
      

  4.   

    dbms_output.putline
    插入表也行
      

  5.   

    A表中有好多字段,我不能把全部查出来啊
    只要查出字段a的值,插入变量b
      

  6.   

    简单的select ... into 要commit干嘛
      

  7.   

    正确  采用into可以将数据放到b中
      

  8.   

    Execute immediate strSql into b;
      

  9.   

    execute immediate strsql into b;