ltantonov
ltantonov

Reputation: 143

Trigger inserting new row after update of another table in Oracle SQL Developer

I would like to create trigger which should create new row in table INVOICES after a new row is created in FREIGHTS table. The trigger should get value from table FREIGHTS and put it in column in table INVOICES.

For now it looks as follows:

create or replace TRIGGER NewInvoice
AFTER INSERT ON FREIGHTS
FOR EACH ROW
BEGIN
 INSERT INTO INVOICES(id, netvalue, grossvalue, tax, receipient)
 SELECT '1', '1', weight, '1', '1'
 FROM FREIGHTS
END;

The error is at the final END statement.

Thanks in advance for your support ;)

Upvotes: 0

Views: 2065

Answers (1)

OldProgrammer
OldProgrammer

Reputation: 12169

Assuming weight is a column in FREIGHTS table:

create or replace TRIGGER NewInvoice
AFTER INSERT ON FREIGHTS
FOR EACH ROW
BEGIN
 INSERT INTO INVOICES(id, netvalue, grossvalue, tax, receipient)
  values ('1', '1', :new.weight, '1', '1');

END;

Maybe read the docs?

Upvotes: 1

Related Questions