-1
   EXCEPTION WHEN DUP_VAL_ON_INDEX THEN
          dup_prod_limt_info := 'An error ocurred trying to inset a record into FICS_CLM.T_CLM_CPARTY_PROD_LMT with CPARTY_PROD_LIMIT_TXN_ID <' || max_limit_txn_id || 
          '> CPARTY_ID <' || pro_lim_rec.CPARTY_ID || '> BU_LVL4_CODE <' || pro_lim_rec.BU_LVL4_CODE || '> PROD_CODE <' || pro_lim_rec.PROD_CODE || '>';
          RAISE dup_prod_limit;

1 Answer 1

0

you can use the clause RAISE EXCEPTION in EXCEPTION BLOCK

example:

DECLARE
mensaje text;
mensaje_detalle text;
sqlerror text;
begin
--do something;

EXCEPTION
WHEN syntax_error THEN
RAISE EXCEPTION 'sintaxis error';
--for unknown exception
WHEN OTHERS THEN
GET STACKED DIAGNOSTICS mensaje = message_text, mensaje_detalle =
pg_exception_detail, sqlerror = returned_sqlstate;
RAISE EXCEPTION 'other error: %, %, %', sqlerror, mensaje,mensaje_detalle;
END;
Sign up to request clarification or add additional context in comments.

2 Comments

if duplicate comes he is raising exception , after that it will come out from loop RAISE dup_prod_limit; ( loop etc..) EXCEPTION WHEN dup_prod_limit THEN Perr_msg := dup_prod_limt_info; WHEN OTHERS THEN Perr_msg := 'An error was encountered while executing procedure P_CLM_CLOSE_PRODUCT_LIMITS <' || SQLERRM || '>'; How to write this in postgree??
in PostgreSQL The condition treated by EXCEPTION WHEN can be any of those shown in ERROR CODE (postgresql.org/docs/10/errcodes-appendix.html). if your error is not lited here. you can use special condition name OTHERS, as the example of the answer, or check this answer stackoverflow.com/questions/7767413/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.