Baker Baker -5 years ago 139
SQL Question

Postgres show command in block of code

How can you use the

command in block of code?

I tried it several ways, but all I got was an error

do $$
show enable_mergejoin; -- I need to to print this value (on/off)
end $$

Answer Source

show returns a result. In PL/pgSQL you can't "just" run a statement, the result of a statement must be stored in a variable:

do $$
  l_value text;
  show enable_mergejoin into l_value; -- retrieve and store the value
  raise notice '%', l_value; -- print the content
end $$
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download