postgres raise info code example
Example 1: postgres raise notice
RAISE INFO 'Hello World !';
RAISE NOTICE '%', variable_name;
RAISE NOTICE 'Current value of parameter (%)', my_var;
RAISE EXCEPTION '% cannot have null salary', EmpName;
Example 2: postgresql raise exception
RAISE EXCEPTION 'This user role does not exist.';
RAISE EXCEPTION 'Nonexistent ID --> %', user_id
USING HINT = 'Please check your user ID';
RAISE 'Duplicate user ID: %', user_id USING ERRCODE = 'unique_violation';
RAISE 'Duplicate user ID: %', user_id USING ERRCODE = '23505';
RAISE division_by_zero;
RAISE SQLSTATE '22012';
RAISE unique_violation USING MESSAGE = 'Duplicate user ID: ' || user_id;