Inserting DEFAULT value into a column when a parameter is NULL
问题 I would like to write a stored procedure like this: CREATE OR REPLACE FUNCTION my_function(param_1 text, param_2 text DEFAULT NULL::text) RETURNS bigint AS $$ DECLARE ret bigint; BEGIN INSERT INTO my_table(val_1, val_2) VALUES (param_1, param_2); -- do some more stuff RETURN ret; END; $$ LANGUAGE plpgsql; However, I would like to use val_2 column's DEFAULT value instead of NULL - if NULL is provided as the param_2 value. Something like this: INSERT INTO my_table(val_1, val_2) VALUES (param_1,