哦,不好意思,刚才发贴的时候没贴完,是这样的
--  Before insert trigger ""tib_users"" for table ""users""
create trigger "tib_users" before insert
on "users" for each row
declare
    integrity_error  exception;
    errno            integer;
    errmsg           char(200);
    dummy            integer;
    found            boolean;begin
    --  Column ""user_id"" uses sequence Seq_13_users
    select Seq_13_users.NEXTVAL INTO :new."user_id" from dual;--  Errors handling
exception
    when integrity_error then
       raise_application_error(errno, errmsg);
end;
/

解决方案 »

  1.   

    给你个例子:
    CREATE OR REPLACE TRIGGER order_info_insert
       INSTEAD OF INSERT ON order_info
     DECLARE
       duplicate_info EXCEPTION;
       PRAGMA EXCEPTION_INIT (duplicate_info, -00001);
     BEGIN
       INSERT INTO customers
         (customer_id, cust_last_name, cust_first_name) 
       VALUES (
       :new.customer_id, 
       :new.cust_last_name,
       :new.cust_first_name);
     INSERT INTO orders (order_id, order_date, customer_id)
     VALUES (
       :new.order_id,
       :new.order_date,
       :new.customer_id);
     EXCEPTION
       WHEN duplicate_info THEN
         RAISE_APPLICATION_ERROR (
           num=> -20107,
           msg=> 'Duplicate customer or order ID');
     END order_info_insert;
    /
      

  2.   

    楼上写的这个触发器好像是为了实现给customers和orders 两个表插入数据呢?
    要是想实现序列自动增长的功能该怎么写呢?
      

  3.   

    是啊,我也很奇怪,但是一直没办法用,老是出错:ORA-04098: 触发器 'RJJ.tib_users' 无效且未通过重新确认。都快疯掉了 ,555~~
      

  4.   

    确保有owner名称:RJJ
    select a.status from user_triggers a where a.trigger_name='TIB_USERS'
    看看状态是不是disabled
      

  5.   

    ORA-04098 trigger 'string.string' is invalid and failed re-validationCause: A trigger was attempted to be retrieved for execution and was found to be invalid. This also means that compilation/authorization failed for the trigger.Action: Options are to resolve the compilation/authorization errors, disable the trigger, or drop the trigger.
      

  6.   

    我也是用PD9.5生成ORACLE,也出现这样的问题了.
    楼主解决了吗?能告诉我是怎么做的呀?
      

  7.   

    顺便问一句:在创建序列的语句中,“cache 20”这个语句是什么意思,起什么作用?其中的数字又应该怎样指定呢?数字大小有什么意义吗?