解决方案 »

  1.   


    -- 大概这样,写成 PLSQL 块就可以了。
    declare
      m_id  int;
      m_str varchar2(30);
    begin
      m_id := 100;
      insert into t (id) values (m_id);
    exception
      when others then
        m_str = '发生了错误';
    end;
      

  2.   


    exception
      when others then
        m_str = '发生了错误';
    这里是什么意思?  就是插入失败了?  失败了会回滚吗?  还有m_id := 100;  这种赋值,我可以这样吗?  m_id:=select fab_combo_seq.nextval from dual  取得ID吗?因为这个值不是固定的。
      

  3.   

    declare
      m_id  int;
      m_str varchar2(30);
    begin
      select fab_combo_seq.nextval into m_id from dual ;  -- 这样写
      insert into t (id) values (m_id);
      commit ;  -- 显式的提交
    exception
      when others then
      rollback ; -- 显式的让这个事务回滚  
      m_str = '发生了错误';
    end;
      

  4.   

    块状编程
    declare
      --此处变量定义
    begin
      --处理逻辑
    exception
      when others then
       ...--异常处理
    end;