- SQL code
-- 交易视图插入时触发器CREATE TRIGGER Trade_V_T_I INSTEAD OF INSERT ON Trade_V FOR EACH ROWBEGIN INSERT INTO Trade ( C_Id, P_Id, Price, Count, "Date", Note ) VALUES ( ( SELECT Id FROM Client_V WHERE City = NEW.City AND Unit = NEW.Unit AND Name = NEW.Client ), ( SELECT Id FROM Product_V WHERE Factory = NEW.Factory AND "Type" = NEW.Product ), -- 首次 ( CASE WHEN NEW.Price ISNULL THEN ( SELECT Price FROM Product_V WHERE Factory = NEW.Factory AND "Type" = NEW.Product ) ELSE NEW.Price END ), NEW.Count, NEW."Date", NEW.Note ); UPDATE Client_V SET Arrear = Arrear + ( -- 再次 ( CASE WHEN NEW.Price ISNULL THEN ( SELECT Price FROM Product_V WHERE Factory = NEW.Factory AND "Type" = NEW.Product ) ELSE NEW.Price END ) * NEW.Count ) WHERE City = NEW.City AND Unit = NEW.Unit AND Name = NEW.Client;END;
有没有复用手段?比如赋给一个临时局部变量。
------解决方案--------------------------------------------------------
不支持 变量