![]() ![]() ![]() There is a second RAISE syntax in which the main argument is the condition name or SQLSTATE to be reported, for example: RAISE 'Duplicate user ID: %', user_id USING ERRCODE = '23505' RAISE 'Duplicate user ID: %', user_id USING ERRCODE = 'unique_violation' These two examples show equivalent ways of setting the SQLSTATE: USING HINT = 'Please check your user ID' RAISE EXCEPTION 'Nonexistent ID -> %', user_id This example will abort the transaction with the given error message and hint: Specifies the error code (SQLSTATE) to report, either by condition name, as shown in Appendix A, or directly as a five-character SQLSTATE code. This option can't be used in the form of RAISE that includes a format string before USING. Each expression can be any string-valued expression. You can attach additional information to the error report by writing USING followed by option = expression items. RAISE NOTICE 'Calling cs_create_job(%)', v_job_id In this example, the value of v_job_id will replace the % in the string: The number of arguments must match the number of % placeholders in the format string, or an error is raised during the compilation of the function. Inside the format string, % is replaced by the string representation of the next optional argument's value. The format string can be followed by optional argument expressions to be inserted into the message. The format string specifies the error message text to be reported. See Chapter 20 for more information.Īfter level if any, you can specify a format string (which must be a simple string literal, not an expression). Whether messages of a particular priority are reported to the client, written to the server log, or both is controlled by the log_min_messages and client_min_messages configuration variables. EXCEPTION raises an error (which normally aborts the current transaction) the other levels only generate messages of different priority levels. Allowed levels are DEBUG, LOG, INFO, NOTICE, WARNING, and EXCEPTION, with EXCEPTION being the default. The level option specifies the error severity. Use the RAISE statement to report messages and raise errors. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |