table 更新后设置 2 列

Set 2 colums after an update on a table

所以我试图在插入后从我的 table 中输入大写字母 2 字段。所以我创建了一个触发器,但由于我想更新 2 个字段,所以我不确定该怎么做。这就是我所做的,但我认为这不是正确的方法。当有插入时,我想将这两个字段设置为大写。

谢谢:)

CREATE or ALTER TRIGGER majVilleClient
on client
instead of insert
as
begin
update client
set nom_client =upper(nom_client)
where nom_client in (select nom_client from inserted)
set nom_ville = upper(nom_ville)
where nom_ville in (select nom_ville from inserted) 
end```

在您标记问题的 MySQL 中,您将使用 BEFORE INSERT 触发器,因此您可以在写入之前更改值:

delimiter //

create trigger majvilleclient
before update on client
for each row
begin
    set new.nom_client = upper(new.nom_client);
    set new.nom_ville  = upper(new.nom_ville);
end;
//

delimiter ;

更新这就是我所做的,但我不确定这是否有效。

CREATE or ALTER TRIGGER majVilleClient
on client
after insert
as
begin
update client
set nom_client =upper(nom_client),
    nom_ville = upper(nom_ville)
where nom_ville in (select nom_ville from inserted) and nom_client in (select nom_client from inserted) 
end```

我不熟悉你的 dms,但肯定不熟悉 MySQL,你应该改变它

但是当您的第一次更新成功时,您可以使用以下内容。

CREATE or ALTER TRIGGER majVilleClient
on client
instead of insert
as
begin
update client
set nom_client =upper(nom_client)
,nom_ville = upper(nom_ville)
where nom_client in (select nom_client from inserted)

结束