Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 使用触发器用当前的_时间戳更新特定列,它表示触发器已创建但未更新_Sql - Fatal编程技术网

Sql 使用触发器用当前的_时间戳更新特定列,它表示触发器已创建但未更新

Sql 使用触发器用当前的_时间戳更新特定列,它表示触发器已创建但未更新,sql,Sql,这是您的更新: create or replace trigger trg1 before insert on patient referencing old as old new as new for each row begin if inserting then update patient set p_join_date = current_timestamp where :old.patient_id= null; end if; end; 中的的计算结果永远不会为

这是您的
更新

create or replace trigger trg1
before
insert on patient
referencing old as old new as new
 for each row
 begin
 if inserting then
     update patient set p_join_date = current_timestamp where :old.patient_id= null;
 end if;
end;
中的
的计算结果永远不会为true,因此不会更新任何行。大概你的意图是:

update patient
    set p_join_date = current_timestamp
    where :old.patient_id = null;
触发器是高度特定于供应商的,因此请添加一个标记来指定您使用的是
mysql
postgresql
sqlserver
oracle
还是
db2
——或者其他完全不同的东西。
update patient
    set p_join_date = current_timestamp
    where :old.patient_id is null;