i have a "before update trigger" on a table. How to set default value on a column ? :
CREATE OR REPLACE FUNCTION trigger() RETURNS TRIGGER AS
$$
TD["new"]["test"] = DEFAULT # Doesn't work
$$ LANGUAGE plpython2u VOLATILE;
I don't think that there is a way to do that, as default values are evaluated before the triggers are called.
For simple default values (constants), you may be able to work around that by looking up pg_get_expr(adbin, adrelid) AS default_value in the corresponding entry in pg_catalog.pg_attrdef and using that, but it sure ain't a pretty solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With