#openGauss #入门 #安装 #数据库 #开源
知识来源:docs-opengauss.osinfra.cn/zh/
或者另一种方式:
RAISE unique_violation USING MESSAGE = 'Duplicate user ID: ' || user_id;
兼容O模式下,支持使用语法EXCEPTION_INIT自定义错误码SQLCODE:
declare
deadlock_detected exception;
pragma exception_init(deadlock_detected, -1);
begin
if 1 > 0 then
raise deadlock_detected;
end if;
exception
when deadlock_detected then
raise notice 'sqlcode:%,sqlstate:%,sqlerrm:%',sqlcode,sqlstate,sqlerrm;
end;
/
--执行结果
NOTICE: sqlcode:-1,sqlstate:-1,sqlerrm: 1: non-GaussDB Exception
#openGauss #入门 #安装 #数据库 #开源