更新时间:2023-01-21 22:39:50
PLpgSQL不允许定义自己的异常-因此Orafce无法定义UTL_FILE.*
异常.您应该查看orafce 源代码
PLpgSQL doesn't allow to define own exceptions - so Orafce cannot to define UTL_FILE.*
exceptions. You should to look to orafce source code file.c to list of used exceptions:
代码使用宏CUSTOM_EXCEPTION
#define CUSTOM_EXCEPTION(msg, detail) \
ereport(ERROR, \
(errcode(ERRCODE_RAISE_EXCEPTION), \
errmsg("%s", msg), \
errdetail("%s", detail)))
在此列表中,您可以看到所有PostgreSQL异常.因此,使用的异常的名称为raise_exception
,而异常的原因在SQLERRM
变量中.因此,您的代码应类似于:
In this list you can see all PostgreSQL exceptions. So the name of used exception is raise_exception
and the reason of exception is in SQLERRM
variable. So your code should to look like:
WHEN RAISE_EXCEPTION THEN
CASE SQLERRM
WHEN 'UTL_FILE_INVALID_PATH' THEN
PERFORM ...
WHEN 'UTL_FILE_INVALID_MODE' THEN
PERFORM ...
ELSE
PERFORM ...
END;