CREATE or replace FUNCTION test() RETURNS boolean AS $$
$filename = '/home/postgres';
if (-e $filename) {
exec /home/postgres/test.sh &
return true; }
return false;
$$ LANGUAGE plperlu;
执行/home/postgres/test.sh &时显示语法错误。 请问如何在PostgreSQL函数/过程中调用bash脚本。
system
行中似乎缺少一个单引号。 - Laurenz Albereturn
是不好的做法(因为子程序并不总是返回标量)。在这里使用return 0
更有意义。 - ikegami&&
非常适合紧凑地编写逻辑表达式,例如$foo == 27 && $bar >= 5
。低优先级形式最好用于流程控制,例如assert_we_are_done() and return 1;
(or
更经常用于此)。 - daotoad