trigger impacting insertion of records

From: Atul Kumar <akumar14871(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: trigger impacting insertion of records
Date: 2021-05-06 07:45:12
Message-ID: CA+ONtZ5eovBzbaAHbWavN3p8o7W-3z94pfED8cGMN5ts-6K7dg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I have simple table having structure like given below:

\d bp_ach_trans
Table "bonzipay.bp_ach_trans"
Column | Type |
Modifiers
--------------------+------------------------+-------------------------------------------------------------------
bptransid | integer | not null default
nextval('bp_ach_trans_bptransid_seq1'::regclass)

filename | character varying(50) |
payment_status | character varying(30) |
settledate | character varying(15) |
payment_pastransid | bigint |
tname | character varying(250) |
code | character varying(5) |
error_txt | character varying(200) |
routingnumber | character varying(15) |
tracenumber | character varying(10) |
accountnumber | character varying(15) |
bankaccountnumber | character varying(17) |
type | character varying(1) |
amount | numeric |
site | character varying(30) |
accountype | character varying(2) |
tranid | character varying(15) |

Triggers:
ins_ussf_rec AFTER INSERT ON bp_ach_trans FOR EACH ROW EXECUTE
PROCEDURE ussf_accountnumber_update()

the function definition is like below:

CREATE OR REPLACE FUNCTION bonzipay.ussf_accountnumber_update()
RETURNS trigger
LANGUAGE plpgsql
AS $function$ BEGIN update bonzipay.bp_ach_trans set
accountnumber=replace(accountnumber,'_',' ') where
left(accountnumber,3) = 'US_'; RETURN NEW; END; $function$

my query is:

when I am inserting around 1000 records in the table having
accountnumber not having value 'US_', I am getting only 300 records
insertion. remaining around 700 values are not getting inserted.

why this strange behavior is happening, as I am not inserting any
record having value 'US_' even after that all records are not
inserting.

Any suggestions are welcome.

Regards,
Atul

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jian He 2021-05-06 09:48:12 Chain Hashing
Previous Message Kyotaro Horiguchi 2021-05-06 05:37:28 Re: "invalid contrecord" error on replica