2015-11-13 62 views
0

如何在代码块中使用show命令?Postgres在代码块中显示命令

我试了几种方法,但我得到的是

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

请添加一些细节如果可能的话 – Coffee

+0

为什么你就不能使用'显示enable_mergejoin'没有PL/pgSQL的封锁? –

+0

,因为我需要检查当前事务中的设置 – Baker

回答

1

show返回结果的误差。在PL/pgSQL里,你不能“仅仅”运行语句,语句的结果必须被存储在一个变量:

do $$ 
declare 
    l_value text; 
begin 
    show enable_mergejoin into l_value; -- retrieve and store the value 
    raise notice '%', l_value; -- print the content 
end $$ 
; 
0

其他解决方案是使用administrative functionscurrent_settingset_setting。这些函数访问相同的代码SHOWSET命令:

do $$ 
begin 
    raise notice '%', current_seting('enable_mergejoin'); 
end$$