0

この Microsoft SQL Server トリガーを変換したい

ALTER TRIGGER [dbo].[trg_EliminoItems]
ON [dbo].[PedidosEncabezado]
INSTEAD OF DELETE
AS
BEGIN

    SET NOCOUNT ON;

    insert into HistPedidosEncabezado select * from PedidosEncabezado where PedidosID in ( select PedidosID from deleted )
    insert into HistPedidosItems select * from PedidosItems where PedidosID in ( select PedidosID from deleted )

    delete from PedidosItems where PedidosID in ( select PedidosID from deleted )
    delete from PedidosEncabezado where PedidosID in ( select PedidosID from deleted )

END

SQLiteに。

4

1 に答える 1

0

SQLite はテーブルでのトリガーを許可しませんがINSTEAD OF、とにかくそれらのレコードを削除するつもりでした:

CREATE TRIGGER trg_EliminoItems
BEFORE DELETE ON PedidosEncabezado
FOR EACH ROW
BEGIN
    INSERT INTO HistPedidosEncabezado
      SELECT * FROM PedidosEncabezado WHERE PedidosID = OLD.PedidosID;
    INSERT INTO HistPedidosItems
      SELECT * FROM PedidosItems      WHERE PedidosID = OLD.PedidosID;
    DELETE FROM PedidosItems          WHERE PedidosID = OLD.PedidosID;
END;
于 2013-08-26T21:17:55.670 に答える