I have a function where I need to get a configuration parameter and assign it to a variable that I will use later in the function. The problem is that when the configuration parameter is not recognized (because it does not exist yet) the function dies. I want to evaluate if the variable was able to be assigned and if not set a null value to it.
This is what I tried:
DECLARE conf_param text; num integer; BEGIN SELECT current_setting('the_setting') INTO conf_param; -- here is where dies when the_setting is not recognized! IF FOUND THEN num := conf_param::integer; ELSE num := NULL; END IF; -- more stuff
I am not sure if I am using
Found the way is needed.