云数据库 GaussDB-提示信息函数

时间:2025-02-12 15:09:14

提示信息函数

  • report_application_error()

    描述:PL执行过程中,可以使用此函数来抛ERROR。

    返回值类型:void

    表1 report_application_error参数说明

    参数

    类型

    说明

    是否必选

    log

    text

    error消息的内容。

    code

    int4

    error消息对应的error code,范围为:-20999 ~ -20000。

    示例
    openGauss=#  CREATE OR REPLACE FUNCTION GET_RESULT_UNKNOWN(opengauss(#     IN context_id int, /*context_id*/opengauss(#     IN col_type text /*col_type*/opengauss(# )RETURNS INTEGERopengauss-# AS $$opengauss$# BEGINopengauss$#     if col_type is NULL thenopengauss$#         PG_CATA LOG .REPORT_APPLICATION_ERROR('invalid input for the third parameter col_type should not be null');opengauss$#     end if;opengauss$#     PG_CATALOG.REPORT_APPLICATION_ERROR('UnSupport data type for column_value(context: '||context_id||', '||PG_CATALOG.QUOTE_LITERAL(col_type)||')');opengauss$#     return -1;opengauss$# END;opengauss$# $$ LANGUAGE plpgsql;CREATE FUNCTIONopengauss=# CALL GET_RESULT_UNKNOWN(NULL, NULL);ERROR:  invalid input for the third parameter col_type should not be nullCONTEXT:  SQL statement "CALL pg_catalog.report_application_error('invalid input for the third parameter col_type should not be null')"PL/pgSQL function get_result_unknown(integer,text) line 4 at PERFORM
support.huaweicloud.com/distributed-devg-v2-gaussdb/gaussdb-12-0285.html