create trigger trigger_jsj
before insert on jsj
for each row
begin
 select sequence_jsj.nextval into :new.id from dual;
end;

解决方案 »

  1.   

    对不起 ,我的分都问完了,正好我也有同样的问题,所以借用一下你的空间,谢谢。
    我 的问题也是这样,请问为什么会有这样的错误呀???
    代码如下:
    SQL> desc customer;
     名称                                      是否为空? 类型
     ----------------------------------------- -------- ----------------------------
     CUSTOMER_ID                               NOT NULL NUMBER(10)
     SURNAME                                   NOT NULL VARCHAR2(30)
     FIRST_NAME                                         VARCHAR2(20)
     SALES_REGION                                       CHAR(2)
     YTD_SALES                                          NUMBER(10,2)
     TOTAL_SALES                                        NUMBER(14,2)
    SQL>  create or replace trigger qk_display_110 
      2  before   insert or update 
      3  on customer
      4  for  each row 
      5  declare
      6  new_sales_amt   number;
      7  begin 
      8  new_sales_amt := :new.total_sales_nvl(:old.total_sales ,0);
      9  dbms_output.out_line('new sales amount:'|| new_sales_amt);
     10  /警告: 创建的触发器带有编译错误。
      

  2.   

    :new.total_sales_nvl(:old.total_sales ,0);这句是什么意思?
      

  3.   

    new_sales_amt := :new.total_sales;--这样就可以了
    还有最后要加个end;....
    dbms_output.out_line('new sales amount:'|| new_sales_amt);
    end;
    /
      

  4.   

    对,若是空值可用nvl函数.
    new_sales_amt := nvl(:new.total_sales,0);
      

  5.   

    to dgdlking () :创建触发器时要在最后加上 / 才能执行。