Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kNQFR-0007iS-Q5 for pgsql-bugs@arkaria.postgresql.org; Wed, 30 Sep 2020 00:45:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kNQFP-0000YF-IX for pgsql-bugs@arkaria.postgresql.org; Wed, 30 Sep 2020 00:45:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kNQFO-0000Y8-TQ for pgsql-bugs@lists.postgresql.org; Wed, 30 Sep 2020 00:45:31 +0000 Received: from sonic305-22.consmr.mail.ne1.yahoo.com ([66.163.185.148]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kNQFG-0008Do-Dw for pgsql-bugs@lists.postgresql.org; Wed, 30 Sep 2020 00:45:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1601426719; bh=li/Qz5po5DFg/6Bri6SX45XtdEzDHB8ua0+6bkGkiUI=; h=Date:From:To:Subject:References:From:Subject; b=Pc1TaCUoZrae0UfegMSlFrOwCNnMGZxn1Jkd9rR930TxmD4uIkuBtj6m4h+W2cTOIEoVzz6d5nptIP9icf2sEYt7xRZdfhSS1PU9ZajgCtagrBFeIrtU0WGdKICW+xY6f0FoDdKORE0uFpAgkBNn4ABwZ9QwT4FE75sc4/xO1Np9h36gTWeIRZBhvFlOJXQ0DL9s4AVbuIC5XgFX9bqLWhyuz9H/XlfxlHsaa43dTCBc7oc55TD7A/Ab/GYNKDLYbEkVPo5BJZMXLny7GrfgwmCWe1jGNYDutCShGBHVirrV/6cKeK6K5xyJeK/jwW2mPRPZaldl0jEdIp6lokEHtQ== X-YMail-OSG: FMk3JAwVM1mRwH07lU3tWB586V62WvUecMd89ctq0pHe4_y22Eg1l0O8ZdyiiAN cklloQTxGQRIYF09qo3GGjTa231Kq4ga2HDfnXvAZAp2xiNizPrL..QWue2ltiaii3E88PnCeZsn o7ItOaPhxKnyxe5N5DEKrGR0AYMTbgEXuTjCer56vIZBs3ZiU1gmuEHwCRW93N2Wm9.65AF9kmMa pAVujlJR9Y6NSuRY4wOPrzsNCUmihhR9_07m5CoP3HCt9BsDfboouWT1xWcccpvWNtHKigClXNue .Aya_z6olYRUz7XB6wISLH19nSM6RrUWjb.CGywqvoS.13NTopcxoldmWNvv8gsAjaQo0XzSR8px oNk.KmySkq6N6UA8a_aLEFk1Lj7USmqC8_ybJpSAI2S3hbsWkkajeI5SibiB3ZNVt49zLZbtHFSx bt4LQOi845uTt4ahbHoT.aCEBKYKgom7DTQ7gwVwxrAbrL5ffVX6Bv6EjDsEgnOeBEHXuCw2dfQw bJAwj9jK_f1LUda_CEWbRV5ke3lZbgQyS8treOXZ2GRzyqy4RmybFje6GH5nerFOCb078jJ7.AQB l_X17hVe1yTMyE97klXRVs5TXTatg6mEaWholyjkmhzWe4p.DgcTvc4MaW1Dg9L_5103Sbq26rH8 xGIz.eMkQsq2g.c0r1erwsTHkNTfuH7SbNfnqW5WGaFppxf7bk47ybRoGdrKOYzapOZuC3hC5PnR ICsN94yeBxLD7ppzZeHCWyHi8f6cmy58NVJ2GszyQyGMHeaYVJnMP08aI7d6LYHaKm31QLvrug4B Zi63Ey6HfFjiddVYIyyvTtNe4BaT3Sxw.0hKNRpoJqNihcHvFFc9Gv5V8EN_hwh8ENZkwKeiJmvt 2jGaLLwbQXVTgAbhGGhwKwNkhx7u6rUKcgKawbk.BiyveKfrruUSjrr53UUbM.xp5dlK4YW3q0ov gIhsNnVCOS0XhijJBwpIGwzVHHMuw43xr_UaPI5PLW4TjggoYJfisE3kwMfvjiok4DLAZNEfU0LO 3dQLkon9dY4BwG2sAcaa3_YPHILElDBRTSkVRCJvNwLWleScbUv6ED15Y2VYAlS9ghZ0PgqUiH8s dzeMy4MhTRWecYg1A1THuXWRYJt95.0VVLeH7YaTViWdPH8gVIjMnncyg1eMI6uET7fB7TQ0lrx6 xdNVoMggtH.NrofKx1wZjtZEYHUuqKwE5NLU8h4aMB9OTNpqANmZvlax3328khXpVSWbGTBAaHFm 9cHngvA6_HAwbtXM.BTVU2OOyD5vfWs.hj99hXD9fQAgXLWi3E_z.oYeUx2jXWvW.MV9FJwJ2pkU chWIh7N99DPy9LE6f1KxKut5soJ3lGbwG2P8SOOGFUIr8WtypMiUGYYZkY34qLxN5TAIJFNIfHvo oawRS4mk50nzs5BaUPV1ItNEgoDlT6OXmPou8RbxL5y9DGBvnAaeWLn7lokL4SZyuU12tjuBE Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.ne1.yahoo.com with HTTP; Wed, 30 Sep 2020 00:45:19 +0000 Date: Wed, 30 Sep 2020 00:45:16 +0000 (UTC) From: Nagaraj Raj To: PostgreSQL Mailing Lists Message-ID: <592586284.142826.1601426716345@mail.yahoo.com> Subject: Trigger function is not working as expected after migration from v9.6 to v11.7 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_142825_1008143277.1601426716340" References: <592586284.142826.1601426716345.ref@mail.yahoo.com> X-Mailer: WebService/1.1.16718 YMailNorrin Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 Content-Length: 30110 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_142825_1008143277.1601426716340 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, I have implemented table partition with an=C2=A0inheritance approach=C2=A0 = and the trigger function is not working as expected=C2=A0after migration fr= om v9.6 to v11.7 The issue is, I have a table and created=C2=A0inheritance tables for each m= onth; it has a date column load_date as it takes=C2=A0current_timestamp=C2= =A0 and respective this created trigger function with BEFORE=C2=A0=C2=A0INS= ERT OR UPDATE.=C2=A0 Everything good so far, but earlier=C2=A0 I have=C2=A0inheritance tables ti= ll August 2020, so I created=C2=A0inheritance tables till December 2020, an= d somehow I missed for the month September 2020 in the table creation. Stil= l, I updated the trigger function without missing=C2=A0September 2020. So, when injection started for=C2=A0September 2020=C2=A0into a master table= , the trigger didn't occur through any error because it's satisfied the con= ditions of the trigger function and after passing through the trigger funct= ion, it should look for a table=C2=A0September 2020, because the condition = is base on=C2=A0load_date (current_timestamp=C2=A0) if not it should insert= into a master table or through any error, The server acted strangely, records inserted to the master table, but load_= date didn't take=C2=A0current_timestamp; it recorded future timestamp, i.e.= , January 2021. Attached trigger function and trigger with table structure, problem is if t= he child table does exit it's not omitting the error and data directing to = the master table with a futuristic data value of load_dttm. basically, it was working code in version 9.6. Postgres 11 | db<>fiddle |=20 |=20 | |=20 Postgres 11 | db<>fiddle Free online SQL environment for experimenting and sharing. | | | -- Table: l_billing_account -- DROP TABLE l_billing_account; CREATE TABLE l_billing_account(=C2=A0 =C2=A0 billing_account_guid character= varying(40) COLLATE pg_catalog."default" NOT NULL,=C2=A0 =C2=A0 ingestion_= process_id bigint NOT NULL DEFAULT '-1'::integer,=C2=A0 =C2=A0 load_dttm ti= mestamp(6) without time zone NOT NULL,=C2=A0 =C2=A0 log_position_number cha= racter varying(40) COLLATE pg_catalog."default" NOT NULL,=C2=A0 =C2=A0 oper= ation_code character varying(40) COLLATE pg_catalog."default" NOT NULL,=C2= =A0 =C2=A0 commit_dttm timestamp(6) without time zone NOT NULL,=C2=A0 =C2= =A0 oracle_scn character varying(40) COLLATE pg_catalog."default",=C2=A0 = =C2=A0 ban integer NOT NULL,=C2=A0 =C2=A0 bl_cur_bill_seq_no smallint,=C2= =A0 =C2=A0 bl_last_prod_date timestamp(6) without time zone,=C2=A0 =C2=A0 b= ill_method character varying(2) COLLATE pg_catalog."default",=C2=A0 =C2=A0 = bill_method_eff_date timestamp(6) without time zone,=C2=A0 =C2=A0 rstr_fee_= qid character varying(15) COLLATE pg_catalog."default",=C2=A0 =C2=A0 prev_b= ill_format character varying(2) COLLATE pg_catalog."default",=C2=A0 =C2=A0 = CONSTRAINT billing_account_pkey PRIMARY KEY (billing_account_guid, ban)); -- FUNCTION: func_l_billing_account_insert_trigger() CREATE FUNCTION func_l_billing_account_insert_trigger()=C2=A0 =C2=A0 RETURN= S trigger=C2=A0 =C2=A0 LANGUAGE 'plpgsql'=C2=A0 =C2=A0 COST 100=C2=A0 =C2= =A0 VOLATILE NOT LEAKPROOFAS $BODY$BEGIN=C2=A0 =C2=A0=C2=A0 =C2=A0IF=C2=A0 = ( NEW.load_dttm >=3D=C2=A0 '2020-02-01 00:00:00-07' AND=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0NEW.load_dttm <=C2=A0 '2020-02-16 00:00:00-07' ) THEN=C2=A0 = =C2=A0 =C2=A0 =C2=A0 INSERT INTO l_billing_account_y2020m02begin VALUES (NE= W.*);=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 ELSIF ( NEW.load_dttm >=3D=C2= =A0 '2020-02-16 00:00:00-07' AND=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 N= EW.load_dttm <=C2=A0 '2020-03-01 00:00:00-07' ) THEN=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 INSERT INTO l_billing= _account_y2020m02end VALUES (NEW.*);=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0 ELSIF ( NEW.load_dttm >=3D=C2=A0 '2020-03-01 00:00:00-07' AND=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 NEW.load_dttm <=C2=A0 '2020-03-16 00:00= :00-07' ) THEN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 = =C2=A0 =C2=A0 INSERT INTO l_billing_account_y2020m03begin VALUES (NEW.*); = ELSIF ( NEW.load_dttm >=3D=C2=A0 '2020-03-16 00:00:00-07' AND=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 NEW.load_dttm <=C2=A0 '2020-04-01 00:00:00-07' = ) THEN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 = =C2=A0 INSERT INTO l_billing_account_y2020m03end VALUES (NEW.*); =C2=A0 =C2=A0 ELSIF ( NEW.load_dttm >=3D=C2=A0 '2020-04-01 00:00:00-07' AND= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 NEW.load_dttm <=C2=A0 '2020-04-16= 00:00:00-07' ) THEN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0 =C2=A0 =C2=A0 INSERT INTO l_billing_account_y2020m04begin VALUES (NE= W.*); ELSIF ( NEW.load_dttm >=3D=C2=A0 '2020-04-16 00:00:00-07' AND=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 NEW.load_dttm <=C2=A0 '2020-05-01 00:00:00-07'= ) THEN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 = =C2=A0 INSERT INTO l_billing_account_y2020m04end VALUES (NEW.*); ELSIF ( NEW.load_dttm >=3D=C2=A0 '2020-05-01 00:00:00-07' AND=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 NEW.load_dttm <=C2=A0 '2020-05-16 00:00:00-07'= ) THEN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 = =C2=A0 INSERT INTO l_billing_account_y2020m05begin VALUES (NEW.*); ELSIF (= NEW.load_dttm >=3D=C2=A0 '2020-05-16 00:00:00-07' AND=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 NEW.load_dttm <=C2=A0 '2020-06-01 00:00:00-07' ) THEN= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 = INSERT INTO l_billing_account_y2020m05end VALUES (NEW.*); ELSIF ( NEW.load_dttm >=3D=C2=A0 '2020-06-01 00:00:00-07' AND=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 NEW.load_dttm <=C2=A0 '2020-06-16 00:00:00-07'= ) THEN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 = =C2=A0 INSERT INTO l_billing_account_y2020m06begin VALUES (NEW.*); ELSIF (= NEW.load_dttm >=3D=C2=A0 '2020-06-16 00:00:00-07' AND=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 NEW.load_dttm <=C2=A0 '2020-07-01 00:00:00-07' ) THEN= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 = INSERT INTO l_billing_account_y2020m06end VALUES (NEW.*); ELSIF ( NEW.load_dttm >=3D=C2=A0 '2020-07-01 00:00:00-07' AND=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 NEW.load_dttm <=C2=A0 '2020-07-16 00:00:00-07'= ) THEN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 = =C2=A0 INSERT INTO l_billing_account_y2020m07begin VALUES (NEW.*); ELSIF (= NEW.load_dttm >=3D=C2=A0 '2020-07-16 00:00:00-07' AND=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 NEW.load_dttm <=C2=A0 '2020-08-01 00:00:00-07' ) THEN= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 = INSERT INTO l_billing_account_y2020m07end VALUES (NEW.*); ELSIF ( NEW.load_dttm >=3D=C2=A0 '2020-08-01 00:00:00-07' AND=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 NEW.load_dttm <=C2=A0 '2020-08-16 00:00:00-07'= ) THEN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 = =C2=A0 INSERT INTO l_billing_account_y2020m08begin VALUES (NEW.*); ELSIF (= NEW.load_dttm >=3D=C2=A0 '2020-08-16 00:00:00-07' AND=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 NEW.load_dttm <=C2=A0 '2020-09-01 00:00:00-07' ) THEN= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 = INSERT INTO l_billing_account_y2020m08end VALUES (NEW.*); ELSIF ( NEW.load_dttm >=3D=C2=A0 '2020-09-01 00:00:00-07' AND=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 NEW.load_dttm <=C2=A0 '2020-09-16 00:00:00-07'= ) THEN INSERT INTO l_billing_account_y2020m09begin VALUES (NEW.*);=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ELSIF ( NEW.load_dttm >=3D=C2=A0 '2020-09-16 00:00:00-07' AND=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 NEW.load_dttm <=C2=A0 '2020-10-01 00:00:00-07'= ) THEN =C2=A0 =C2=A0 =C2=A0 =C2=A0 INSERT INTO l_billing_account_y2020m09end VALUE= S (NEW.*); ELSIF ( NEW.load_dttm >=3D=C2=A0 '2020-10-01 00:00:00-07' AND=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 NEW.load_dttm <=C2=A0 '2020-10-16 00:00:00-07'= ) THEN INSERT INTO l_billing_account_y2020m10begin VALUES (NEW.*); ELSIF ( NEW.load_dttm >=3D=C2=A0 '2020-10-16 00:00:00-07' AND=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 NEW.load_dttm <=C2=A0 '2020-11-01 00:00:00-07'= ) THEN INSERT INTO l_billing_account_y2020m10end VALUES (NEW.*); =C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 ELSE=C2=A0 =C2=A0 =C2=A0 =C2=A0 RAISE EXCE= PTION=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 ' out of range exception.=C2=A0 Fix = the func_l_billing_account_insert_trigger() function.=C2=A0=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0HINT: Might need to create a new partition table, load_= dttm is out of range in existing child_tables=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0Action:=C2=A0 Please contact DBA' ;=C2=A0 =C2=A0 END IF;=C2=A0 =C2=A0= RETURN NULL;END;$BODY$; -- Trigger: l_billing_account_partition_trigger CREATE TRIGGER l_billing_account_partition_trigger=C2=A0 =C2=A0 BEFORE INSE= RT OR UPDATE=C2=A0=C2=A0 =C2=A0 ON l_billing_account=C2=A0 =C2=A0 FOR EACH = ROW=C2=A0 =C2=A0 EXECUTE PROCEDURE func_l_billing_account_insert_trigger(); -- Table: l_billing_account_y2020m09end -- DROP TABLE l_billing_account_y2020m09end; CREATE TABLE l_billing_account_y2020m09end( CONSTRAINT l_billing_account_y2= 020m09end_load_dttm_check CHECK (load_dttm >=3D '2020-09-16 00:00:00'::time= stamp without time zone=C2=A0AND load_dttm < '2020-10-01 00:00:00'::timesta= mp without time zone)) INHERITS (l_billing_account); We are running PostgreSQL 11.7 on x86_64-pc-Linux-gnu, compiled by GCC (GCC= ) 4.9.3, 64-bit Thanks,Rj ------=_Part_142825_1008143277.1601426716340 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

I have implemented table partition with an = ;inheritance approach  and the trigger function is not working as expe= cted after migration from v9.6 to v11.7

= The issue is, I have a table and created inheritance tables for each m= onth; it has a date column load_date as it takes current_timestamp&nbs= p; and respective this created trigger function with BEFORE  INSE= RT OR UPDATE. 

Everyt= hing good so far, but earlier  I have inheritance tables till Aug= ust 2020, so I created inheritance tables till December 2020, and some= how I missed for the month September 2020 in the table creation. Still, I u= pdated the trigger function without missing September 2020.


So, when = injection started for September 2020 into a master table, the tri= gger didn't occur through any error because it's satisfied the conditions o= f the trigger function and after passing through the trigger function, it s= hould look for a table September 2020, because the condition is base o= n load_date (current_timestamp ) if not it should insert into a m= aster table or through any error,

The server = acted strangely, records inserted to the master table, but load_date didn't= take current_timestamp; it recorded future timestamp, i.e., January 2= 021.



<= /div>
Attached trigger function and trigger with table stru= cture, problem is if the child table does exit it's not omitting the error = and data directing to the master table with a futuristic data value of load= _dttm.

basi= cally, it was working code in version 9.6.

=








-- Table: l_billing_acc= ount

-- DROP TABLE l_billing_accoun= t;

CREATE TABLE l_billing_account
(
    billing_account_guid character varying(4= 0) COLLATE pg_catalog."default" NOT NULL,
    ingestion= _process_id bigint NOT NULL DEFAULT '-1'::integer,
    = load_dttm timestamp(6) without time zone NOT NULL,
    = log_position_number character varying(40) COLLATE pg_catalog."default" NOT = NULL,
    operation_code character varying(40) COLLATE = pg_catalog."default" NOT NULL,
    commit_dttm timestam= p(6) without time zone NOT NULL,
    oracle_scn charact= er varying(40) COLLATE pg_catalog."default",
    ban in= teger NOT NULL,
    bl_cur_bill_seq_no smallint,
<= div>    bl_last_prod_date timestamp(6) without time zone,
    bill_method character varying(2) COLLATE pg_catalog."defau= lt",
    bill_method_eff_date timestamp(6) without time= zone,
    rstr_fee_qid character varying(15) COLLATE p= g_catalog."default",
    prev_bill_format character var= ying(2) COLLATE pg_catalog."default",
    CONSTRAINT bi= lling_account_pkey PRIMARY KEY (billing_account_guid, ban)
);



-- FUNCTION: func_l_billing_acc= ount_insert_trigger()



CREATE FUNCTION func_l_billi= ng_account_insert_trigger()
    RETURNS trigger
    LANGUAGE 'plpgsql'
    COST 100
<= div>    VOLATILE NOT LEAKPROOF
AS $BODY$
BEGI= N
   
   IF  ( NEW.load_dttm &= gt;=3D  '2020-02-01 00:00:00-07' AND
      &n= bsp;  NEW.load_dttm <  '2020-02-16 00:00:00-07' ) THEN
        INSERT INTO l_billing_account_y2020m02begin = VALUES (NEW.*);
          
=09ELSIF ( NEW.load_dttm &g= t;=3D  '2020-02-16 00:00:00-07' AND
      &nb= sp;     NEW.load_dttm <  '2020-03-01 00:00:00-07' ) THEN<= /div>
            
  =       INSERT INTO l_billing_account_y2020m02end VALUES (NEW.= *);
        
    ELS= IF ( NEW.load_dttm >=3D  '2020-03-01 00:00:00-07' AND
&nb= sp;           NEW.load_dttm <  '2020-03-16= 00:00:00-07' ) THEN
           &nb= sp;
        INSERT INTO l_billing_account_y20= 20m03begin VALUES (NEW.*);
=09=09
=09E= LSIF ( NEW.load_dttm >=3D  '2020-03-16 00:00:00-07' AND
&= nbsp;           NEW.load_dttm <  '2020-04-= 01 00:00:00-07' ) THEN
           &= nbsp;
        INSERT INTO l_billing_account_y= 2020m03end VALUES (NEW.*);

  &= nbsp; ELSIF ( NEW.load_dttm >=3D  '2020-04-01 00:00:00-07' AND
            NEW.load_dttm <  '2= 020-04-16 00:00:00-07' ) THEN
          =   
        INSERT INTO l_billing_ac= count_y2020m04begin VALUES (NEW.*);

=09ELSIF ( NEW.load_dttm >= ;=3D  '2020-04-16 00:00:00-07' AND
      &nbs= p;     NEW.load_dttm <  '2020-05-01 00:00:00-07' ) THEN
            
  &= nbsp;     INSERT INTO l_billing_account_y2020m04end VALUES (NEW.*= );

=09ELSIF ( NEW.load_dttm >=3D  '2020-05-01 00:00:00-0= 7' AND
            NEW.load_dttm &l= t;  '2020-05-16 00:00:00-07' ) THEN
      &nb= sp;     
        INSERT INTO l= _billing_account_y2020m05begin VALUES (NEW.*);
=09=09
=09ELSIF ( NEW.load_dttm >=3D  '2020-05-16 00:00:00= -07' AND
            NEW.load_dttm = <  '2020-06-01 00:00:00-07' ) THEN
      &= nbsp;     
        INSERT INTO= l_billing_account_y2020m05end VALUES (NEW.*);

=09ELSIF ( NEW.lo= ad_dttm >=3D  '2020-06-01 00:00:00-07' AND
    =         NEW.load_dttm <  '2020-06-16 00:00:00-0= 7' ) THEN
            
        INSERT INTO l_billing_account_y2020m06begin = VALUES (NEW.*);
=09=09
=09ELSIF ( NEW.= load_dttm >=3D  '2020-06-16 00:00:00-07' AND
   = ;         NEW.load_dttm <  '2020-07-01 00:00:00= -07' ) THEN
            
=
        INSERT INTO l_billing_account_y2020m06end = VALUES (NEW.*);

=09ELSIF ( NEW.load_dttm >=3D  '2020-07-= 01 00:00:00-07' AND
            NEW= .load_dttm <  '2020-07-16 00:00:00-07' ) THEN
  &nbs= p;         
        = INSERT INTO l_billing_account_y2020m07begin VALUES (NEW.*);
=09=09
=09ELSIF ( NEW.load_dttm >=3D  '2020-0= 7-16 00:00:00-07' AND
            N= EW.load_dttm <  '2020-08-01 00:00:00-07' ) THEN
  &n= bsp;         
       = ; INSERT INTO l_billing_account_y2020m07end VALUES (NEW.*);

=09E= LSIF ( NEW.load_dttm >=3D  '2020-08-01 00:00:00-07' AND
&= nbsp;           NEW.load_dttm <  '2020-08-= 16 00:00:00-07' ) THEN
           &= nbsp;
        INSERT INTO l_billing_account_y= 2020m08begin VALUES (NEW.*);
=09=09
=09ELSIF ( NEW.load_dttm >=3D  '2020-08-16 00:00:00-07' AND
            NEW.load_dttm <  '2020-0= 9-01 00:00:00-07' ) THEN
           = ; 
        INSERT INTO l_billing_account= _y2020m08end VALUES (NEW.*);

=09ELSIF ( NEW.load_dttm >=3D&nb= sp; '2020-09-01 00:00:00-07' AND
        &nbs= p;   NEW.load_dttm <  '2020-09-16 00:00:00-07' ) THEN
=09
=09INSERT INTO l_billing_account_y2020m0= 9begin VALUES (NEW.*);
           <= /div>

=09ELSIF ( NEW.load_dttm >=3D  '2020-09-16 00:00:00-07' = AND
            NEW.load_dttm <&= nbsp; '2020-10-01 00:00:00-07' ) THEN

        INSERT INTO l_billing_account_y2020m09end VA= LUES (NEW.*);

=09ELSIF ( NEW.load_dttm >=3D  '2020-10-01= 00:00:00-07' AND
            NEW.l= oad_dttm <  '2020-10-16 00:00:00-07' ) THEN

=09INSERT IN= TO l_billing_account_y2020m10begin VALUES (NEW.*);

=09ELSIF ( NE= W.load_dttm >=3D  '2020-10-16 00:00:00-07' AND
  &nb= sp;         NEW.load_dttm <  '2020-11-01 00:00:= 00-07' ) THEN

=09INSERT INTO l_billing_account_y2020m10end VALUE= S (NEW.*);

    
    ELSE
        RAISE EXCEPT= ION 
        ' out of range exception.&n= bsp; Fix the func_l_billing_account_insert_trigger() function. 
<= div>         HINT: Might need to create a new part= ition table, load_dttm is out of range in existing child_tables
&= nbsp;        Action:  Please contact DBA' ;
<= div>    END IF;
    RETURN NULL;
EN= D;
$BODY$;




-- Trigger: l_billing_account_partition= _trigger


<= div>
CREATE TRIGGER l_billing_account_partitio= n_trigger
    BEFORE INSERT OR UPDATE 
&= nbsp;   ON l_billing_account
    FOR EACH ROW
    EXECUTE PROCEDURE func_l_billing_account_insert_trigger= ();

-- Table= : l_billing_account_y2020m09end

-- = DROP TABLE l_billing_account_y2020m09end;

CREATE TABLE l_billing_account_y2020m09end
( CONSTRAINT l_= billing_account_y2020m09end_load_dttm_check CHECK (load_dttm >=3D '2020-= 09-16 00:00:00'::timestamp without time zone 
AND load_dttm = < '2020-10-01 00:00:00'::timestamp without time zone)
) INHERI= TS (l_billing_account);



We are running PostgreSQL 11.7 on x86_64-pc-= Linux-gnu, compiled by GCC (GCC) 4.9.3, 64-bit

Thanks,
Rj







------=_Part_142825_1008143277.1601426716340--