0

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 ;)

1
  • Try: INSERT INTO INVOICES(id, netvalue, grossvalue, tax, receipient) VALUES( '1', '1', :new.weight, '1', '1' ); Commented Jun 1, 2016 at 17:58

1 Answer 1

1

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?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.