0

I have write like this code in PostgreSQL. But value is not inserting into BENMASTHIST table. please help to solve this error.

EXECUTE 'INSERT INTO BENMASTHIST SELECT BENMAST_ENTITY_CODE, BENMAST_CUSTOMER_CODE, BENMAST_BEN_CODE,
                          FN_GETCD(' ||
                                P_ENTITY_CODE || '),' || W_BEN_HIST_SL ||
                                ', BENMAST_NAME, BENMAST_MOBILE_NO,
                          BENMAST_EMAIL_ID, BENMAST_PHOTO, BENMAST_SOURCE, BENMAST_CR_BY, BENMAST_CR_ON,
                          BENMAST_MO_BY, BENMAST_MO_ON, BENMAST_AU_BY, BENMAST_AU_ON, TBA_KEY, BENMAST_REMARKS,
                                 BENMAST_ADDR,BENMAST_CITY,BENMAST_STATE
                          FROM BENMAST WHERE BENMAST_ENTITY_CODE =$1 AND BENMAST_CUSTOMER_CODE =$2 AND BENMAST_BEN_CODE =$3'
                USING P_ENTITY_CODE, P_CUST_CODE, P_BEN_CODE;
            EXCEPTION
              WHEN OTHERS THEN
                P_SUC_FLAG := 'F';
                P_ERROR    := 'BENREG013'; --'Error While Inserting Into Benmast';
                ROLLBACK;
            END;
sp k
  • 25
  • 4
  • Remove EXCEPTION entirely and try again. If it still doesn't work, then don't run it dynamically but provide hardcoded values and see what happens (as it looks as if WHERE clause caused no rows to be returned by that SELECT statement >> that applies only if there was no other exception, of course). – Littlefoot Jul 25 '22 at 07:03
  • Please **[edit]** your question and add the exact and complete error message you get. –  Jul 25 '22 at 07:05
  • It has no errors. But while de-bugging in table BENMASTHIST not value are inserting. – sp k Jul 25 '22 at 11:11
  • Look at the Postgres log to see what is actually hitting the database. – Adrian Klaver Jul 25 '22 at 15:15

0 Answers0