我必须移植一个 PostgreSQL 触发器,但由于我没有太多经验,我不知道如何更改某些部分。原始触发器是:
CREATE TRIGGER aerolinea_tr
AFTER UPDATE
ON public.aerolinea FOR EACH ROW
EXECUTE PROCEDURE public."actualizaWarehoseTemplate"();
DECLARE
mviews RECORD;
BEGIN
IF (TG_OP = 'UPDATE') THEN
FOR mviews IN SELECT DISTINCT template.idtemplate
FROM template
INNER JOIN vueloaerolinea ON (template.idvueloaerolinea = vueloaerolinea.idvueloaerolinea)
WHERE vueloaerolinea.codigolinea = old.codigolinea
LOOP
UPDATE detalletemplate SET idwarehose = new.idwarehouse WHERE detalletemplate.idtemplate = mviews.idtemplate;
END LOOP;
END IF;
RETURN old;
END;
我所做的是:
CREATE TRIGGER aerolinea_tr
ON aerolinea
AFTER UPDATE
AS
BEGIN
-- if no row affected, the trigger ends.
IF @@ROWCOUNT = 0
BEGIN
RETURN;
END;
IF EXISTS(SELECT * FROM inserted)
BEGIN
IF EXISTS(SELECT * FROM deleted)
BEGIN
--Update code goes here.
END
END
END;
但是我找不到与 SQL Server 的 RECORD 等效的东西,而且我不知道该怎么做。