我想把一个函数的返回值加到一个表的列中它应该都在mysql中没有php我有一个带有price,tax和price with tax的表我实现了这个函数来计算带有tax的price,但是我不知道如何把这些值加到那个表中
CREATE TABLE Faturat
(Fatura_ID varchar(10),
price real
,tax real,
CmimiMeTvsh real as (total(price,tax)),
Data varchar(20),
PRIMARY KEY (Fatura_ID));
drop function if exists total;
delimiter //
create function total( x real, y real)
returns real
begin
return X+x*Y/100;
select fatura_id,total(price,tax)
from FATURAT;
CREATE TRIGGER trgAuditOnInsertPunetoret AFTER INSERT ON faturat
FOR EACH ROW
BEGIN
INSERT INTO faturat
VALUES (fatura_id,price,tax,total(price,Tax),data);
end ;
delimiter //
1条答案
按热度按时间kkbh8khc1#
这里可能只需要一个生成的列
顺便说一句,我不认为在生成的列中允许使用用户定义的函数,您的触发器也不会工作-您不允许对触发触发器的表进行操作。