Igor
Igor

Reputation: 2659

How to pick a default value to the column in the trigger?

We implement some triggers which perform some operations with insert data before committing them to the database and when some conditions fail the trigger should pick up the default value for corresponding column.

How to perform it inside the trigger?

Thank you. PS. we work with PostgreSQL, but implementations with other DBMS may give a hint.

Upvotes: 0

Views: 141

Answers (1)

Frank Heikens
Frank Heikens

Reputation: 126991

NEW.colname = DEFAULT will do the trick.

Upvotes: 2

Related Questions