0

New row is added to table A and i need trigger which will automatically insert row in table B after row has been inserted in table A.

CREATE FUNCTION insertblocked (
)
RETURNS trigger AS
$body$
BEGIN
    INSERT INTO tableB (blocked.id,blocked.number,blocked.date)
    VALUES (new.id,new.prefix,now())
    RETURN NEW;
END
$body$
LANGUAGE 'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER;

CREATE TRIGGER insertblocked
  AFTER INSERT 
  ON public.tableA FOR EACH ROW 
  EXECUTE PROCEDURE insertblocked();

Please help and advise, why is sql compiler returning and error

QUERY: INSERT INTO blocked (blocked.id,blocked.number,blocked.date) VALUES ( $1 , $2 ,now()) RETURN $3

0

1 Answer 1

2

You're missing a semi-column ; at the end of your insert statement.

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.