获取错误:错误(2,3):PL / SQL:忽略SQL语句错误(8,5):PL / SQL:ORA-00984:此处不允许列

时间:2016-11-17 12:34:20

标签: plsql plsqldeveloper database-trigger

我的代码如下所示。

create table XXINF_DB_OBJECT_DDL_LOG (
        EVENT_DATE DATE NOT NULL,
        EVENT_TIMESTAMP TIMESTAMP NOT NULL,
        EVENT_TYPE VARCHAR2(30) NOT NULL,
        OBJECT_TYPE VARCHAR2(30) NOT NULL,
        OBJECT_OWNER VARCHAR2(30) NOT NULL,
        OBJECT_NAME VARCHAR2(30) NOT NULL,
        DB_USER  VARCHAR2(30) NOT NULL,
        OS_USER VARCHAR2(100) ,
        HOST_NAME VARCHAR2(100),
        HOST_IP_ADDRESS VARCHAR2(30)
);

create or replace trigger XXINF_DB_OBJECT_DDL_LOG_AUDIT
AFTER DDL ON schema
begin
  insert into XXINF_DB_OBJECT_DDL_LOG values(
    sysdate,
    systimestamp,     
    ora_sysevent,      
    ora_dict_obj_type,
    ora_dict_obj_owner,    
    ora_dict_odj_name,
    ora_login_user,
    SYS_CONTEXT('USERENV','OS_USER'),
    SYS_CONTEXT('USERENV','TERMINAL'),
    SYS_CONTEXT('USERENV','IP_ADDRESS')
  );  
END;
/

当我执行get error:

  

错误(2,3):PL / SQL:忽略SQL语句错误(8,5):PL / SQL:
  ORA-00984:这里不允许列

1 个答案:

答案 0 :(得分:0)

请使用以下更正:

create or replace  trigger XXINF_DB_OBJECT_DDL_LOG_AUDIT
AFTER DDL ON SCHEMA
begin
  insert into XXINF_DB_OBJECT_DDL_LOG
    (
      EVENT_DATE,
      EVENT_TIMESTAMP,
      EVENT_TYPE,
      OBJECT_TYPE,
      OBJECT_OWNER,
      OBJECT_NAME,
      DB_USER,
      OS_USER,
      HOST_NAME,
      HOST_IP_ADDRESS

    )
    values
    (
    sysdate,
    systimestamp,     
    ora_sysevent,      
    ora_dict_obj_type ,
    ora_dict_obj_owner,    
    ora_dict_obj_name ,
    ora_login_user ,
    SYS_CONTEXT('USERENV','OS_USER'),
    SYS_CONTEXT('USERENV','TERMINAL'),
    SYS_CONTEXT('USERENV','IP_ADDRESS') );  

END;
/