Oracle SQL trigger for automatically set a column value

前端 未结 1 1802
温柔的废话
温柔的废话 2021-01-19 13:25

I am writing a Oracle trigger. This trigger should automatically set the value of the column \"productId\" to be the oid of the row just inserted.

The trigger I wrot

1条回答
  •  不思量自难忘°
    2021-01-19 14:02

    Looks like you are trying to use SQL Server syntax on an Oracle database! Try this:

    create or replace trigger MyProduct_id_trg 
    before insert on MyProduct
    for each row
    begin 
       :new.productId := :new.oid;
    end; 
    

    (Note: before not after, and with for each row.)

    0 讨论(0)
提交回复
热议问题