To_CHAR(SYSDATE, ...) ----> TO_DATE

To_CHAR(SYSDATE, ...) ----> TO_DATE

所以我有这个代码:

create or replace TRIGGER tr_after_logon
AFTER LOGON ON SCHEMA

DECLARE

var_date VARCHAR(20);

BEGIN

SELECT TO_CHAR(SYSDATE, 'DD:MM:YYYY HH24:MI:SS')
  INTO var_date FROM DUAL ;

  INSERT INTO activity_log (numero, idsession, action, detail, objet, quand) 

 VALUES (seq_activity.nextval, USERENV('SESSIONID'), 'CONNEXION', ORA_DATABASE_NAME,
  ORA_CLIENT_IP_ADDRESS, TO_DATE(var_date, 'DD:MM:YYYY HH24:MI:SS');

END;

我收到 ORA-01830 错误 - 因为我无法将我的 CHAR 转换为 DATE 格式,对吗?我没能解决这个问题

谢谢你提前帮忙!

假设 quanddate 类型,我看不出你的代码有问题,但为什么不直接这样做呢?

create or replace TRIGGER tr_after_logon
AFTER LOGON ON SCHEMA

BEGIN

  INSERT INTO activity_log (numero, idsession, action, detail, objet, quand) 

 VALUES (seq_activity.nextval, USERENV('SESSIONID'), 'CONNEXION', ORA_DATABASE_NAME,
  ORA_CLIENT_IP_ADDRESS, SYSDATE);

END;