postgresql raise exception

-- Simple exception:
RAISE EXCEPTION 'This user role does not exist.';

-- This example will abort the transaction with the given error message and 
-- hint:
RAISE EXCEPTION 'Nonexistent ID --> %', user_id
      USING HINT = 'Please check your user ID';

-- These two examples show equivalent ways of setting the SQLSTATE:
RAISE 'Duplicate user ID: %', user_id USING ERRCODE = 'unique_violation';
RAISE 'Duplicate user ID: %', user_id USING ERRCODE = '23505';

-- There is a second RAISE syntax in which the main argument is the condition 
-- name or SQLSTATE to be reported, for example:
RAISE division_by_zero;
RAISE SQLSTATE '22012';

-- In this syntax, USING can be used to supply a custom error message, detail, 
-- or hint. Another way to do the earlier example is
RAISE unique_violation USING MESSAGE = 'Duplicate user ID: ' || user_id;

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
raise error postgresql raise statement -- postgresql postgresql raise throw exception postgresql throw exception in function postgresql postgres dont throw exception postgresql if then throw exception in function postgresql throw exception in function how to throw error in postgresql postgres raise info postgresql raise exception in trigger raise postgres raise exception sql postgresql raise in postgresql postgresql function handle exception postgresql function exception postgresql raise exception and catch php postgresql raise exception using errcode postgresql procedure raise exception raise exception postgres psql raise exception raise exception psql postgres function raise exception postgresl raise postgresql raise info example raise exception with variable postgrs postgres error when using with postgres raise in function postgres raise exception example postgresql error force raise error postgres raise psql raise pslq raise error in procedure pgsql postgres trigger raise sqlstate raise exception postgresql postgresql throw exception postgres check throw custom error postgres Include Error Detail example postgres specify include error detail RAISE EXCEPTION plpgsql postgres throw exception postgres raise error raise error in postgresql with seterror equivalent in postgres with seterror in postgres postgresql raise error postgresql custom exception for check errors pgadmin function throw exception postgres raise exception postgres procedure raise exception postgres raise exception format raise postgresql postgres raise postgresql raise exception
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source