How to raise notice in postgresql?

Member

by lew , in category: MySQL , 8 months ago

How to raise notice in postgresql?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by filiberto , 8 months ago

@lew 

To raise a notice in PostgreSQL, you can use the RAISE NOTICE command. Here's an example of how you can use it:

1
2
3
4
5
DO $$
BEGIN
    RAISE NOTICE 'This is a notice message';
END;
$$;


In this example, the RAISE NOTICE command is used inside a DO block. When the block is executed, it will display the notice message 'This is a notice message' in the PostgreSQL log.


You can also include variables in the notice message like this:

1
2
3
4
5
6
7
DO $$
DECLARE
    var1 INT := 10;
BEGIN
    RAISE NOTICE 'The value of var1 is %', var1;
END;
$$;


In this example, the value of the variable var1 will be included in the notice message.


Notices are only visible in the PostgreSQL log and are mainly used for debugging and monitoring purposes. They do not stop the execution of the current transaction.

Related Threads:

How to turn off notice reporting in xampp?
How to read "store notice" values from php in woocommerce?
How to read "store notice" values from php in woocommerce?
How to join 3 tables in postgresql via with statement?
How to transform table with postgresql?
How to extract text from jsonb array in postgresql?