Sql server 如何将SQL Server触发器转换为Oracle触发器?

Sql server 如何将SQL Server触发器转换为Oracle触发器?,sql-server,oracle,triggers,Sql Server,Oracle,Triggers,我正在尝试将SQL Server触发器转换为Oracle触发器,此触发器是关于如果我销售产品且产品数量为0,则必须取消销售,但Oracle的sintaxis有所不同 这是SQL Server版本 create trigger IfQuantityIsZero on Products for update as IF (SELECT Quantity FROM INSERTED) < 0 BEGIN RAISERROR ('The sale can not be made, it

我正在尝试将SQL Server触发器转换为Oracle触发器,此触发器是关于如果我销售产品且产品数量为0,则必须取消销售,但Oracle的sintaxis有所不同

这是SQL Server版本

create trigger IfQuantityIsZero on Products for update 
as 
IF (SELECT Quantity FROM INSERTED) < 0 BEGIN
    RAISERROR ('The sale can not be made, it exceeds the existing quantity of the product.',10,1)
ROLLBACK TRANSACTION
END
像这样的

CREATE OR REPLACE TRIGGER ifquantityiszero BEFORE
     UPDATE  --OR INSERT 
   ON products FOR EACH ROW
BEGIN
     IF
          :NEW.quantity < 1 --refer to the modified columns in products using :NEW.column
     THEN
          RAISE_APPLICATION_ERROR(-20000,'The sale can not be made, it exceeds the existing quantity of the product.'
          );

     END IF;
END;
/

请检查我的答案,如果它对你有用,请接受/投票,这样它也会帮助其他寻求答案的人。请阅读: