不懂
:new.w_id:=ll_no;
这句是什么意思?

解决方案 »

  1.   

    sql中可以在表上创建自增列,其序列增长是自动的,这与oracle
    创建序列并与表联系的方式不同。此外,sql中没有行级触发器的
    概念,您的意思是基于自增序列创建另一个工作序列,在sql中可以
    用instead of insert触发器完成:
    create trigger trg_xwxx on whir_xwxx      
    instead of insert
    as
    begin
    insert into whir_xwxx 
        select id,cast(convert(char(6),getdate(),112) as int)*10000+id as w_id,... from inserted      
    end
    go
      

  2.   

    如上所说,哪个ORACLE的触发器中好象是限制这个自增列的最大值为9999,然后回滚,你可以在触发器中设置一个整数变量:
    create trigger trg_xwxx on whir_xwxx      
    instead of insert
    as
    begin
    declare @i int
    set @i=1
    insert into whir_xwxx 
        select id,cast(convert(char(6),getdate(),112) as int)*10000+@i as w_id,@i=(case @i+1 when @i>9999 then 1 else @i+1 end),... from inserted      
    end
    go
      

  3.   

    上面有一点错就是when @i>9999变为when @i>9998