Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I'm converting plsql to PostgreSQL how to return raised exception in PostgreSQL

I’m converting plsql to PostgreSQL.
In plsql:

declare
W_USR_EXCE EXCEPTION;
......
raise W_USR_EXCE;

I have converted in PostgreSQL like this

     IF (W_DAY_TOTAL_AMT > W_NEW_LIMIT) THEN
            W_ERR_MSG := 'Exceeds Benificiary Limit';
 RETURN EXCEPTION USING ERRCODE = '50011';

if "if" condition executed am getting "W_ERR_MSG" message along with that i need EXCEPTION to return

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

but it is not returning any value.
Please help me to solve this error.

>Solution :

Just for reference you can use the below psudo code to raise any error message in POSTGRESQL :

RAISE EXCEPTION ‘Nonexistent ID –> %’, user_id
USING HINT = ‘Please check your user ID’;

follow the link for more details :
https://www.postgresql.org/docs/current/plpgsql-errors-and-messages.html

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading