【发布时间】:2014-07-01 18:21:42
【问题描述】:
我尝试运行运行其他函数并捕获错误的函数,以防其中一个或几个函数失败。 函数是这样的(我删除了不必要的部分):
CREATE OR REPLACE FUNCTION func()
RETURNS void
LANGUAGE plpgsql
AS $function$
BEGIN
cur_time:=now();
FOR r IN select func_num FROM mytable order by func_num
LOOP
select schema , function_name, last_run, period into _schema, _func_name,_last_run, _period from mytable
;
if _last_run+_period <=cur_time then perform _schema||'.'||_func_name||'()' ; end if;
EXCEPTION WHEN OTHERS THEN
RAISE NOTICE 'exception (code=%): %', SQLCODE, SQLERRM;
_error:=SQLCODE;
if _last_run+_period >=cur_time then update mytable set error=_error where schema=_schema and function_name=_func_name; end if;
END LOOP;
RETURN;
END;
我收到以下错误:“ERROR: ERROR: syntax error at or near "EXCEPTION"”,我找不到它:((
将不胜感激!
【问题讨论】: