Prompt Message Function
- report_application_error()
Description: This function can be used to throw errors during PL execution.
Return type: void
Table 1 report_application_error parameter description Parameter
Type
Description
Required (Yes/No)
log
text
Content of an error message.
Yes
code
int4
Error code corresponding to an error message. The value ranges from –20999 to –20000.
No
ExampleopenGauss=# CREATE OR REPLACE FUNCTION GET_RESULT_UNKNOWN( opengauss(# IN context_id int, /*context_id*/ opengauss(# IN col_type text /*col_type*/ opengauss(# )RETURNS INTEGER opengauss-# AS $$ opengauss$# BEGIN opengauss$# if col_type is NULL then opengauss$# PG_CATALOG.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 FUNCTION opengauss=# CALL GET_RESULT_UNKNOWN(NULL, NULL); ERROR: invalid input for the third parameter col_type should not be null CONTEXT: 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
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.