This is how I am accessing variable in PostgreSQL.
select CURRENT_SETTING('abc.var1')
Is there an optimal way so that I can get default value i.e. 0 in case variable doesn't exist, instead of receiving an error ?
Use the two parameter version of that function (which prevents an error if the variable is missing), then use coalesce():
select coalesce(current_setting('abc.var1', true), '0');
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