drop table if exists session.tmp_corplan_report_ml; declare global temporary table session.tmp_corplan_report_ml ( seqno integer8 not null not default, pagibigid varchar(25) not null not default, account_no varchar(25) not null not default, lname varchar(60) not null not default, fname varchar(60) not null not default, mid varchar(60), name_ext varchar(10), birthdate ansidate not null not default, civil_status char(2), gender char(1), basic money, program_code varchar(10) not null not default, membership_category varchar(5) not null not default, employerid varchar(25) not null not default, branch_code varchar(10) not null not default, init_percov char(6) not null with default, last_percov char(6) not null with default, init_remit ansidate not null not default, last_remit ansidate not null not default, occupationcode varchar(10) not null with default, ee money not null not default, er money not null not default, div money not null not default, country varchar(100) not null with default, mobile_no varchar(30) not null with default, with_final_claim integer2 not null with default, paymentcount integer not null with default, cutdate ansidate not null not default, rundate ansidate not null not default ) with page_size = 16384 ; \ninsert into session.tmp_corplan_report_ml select first 1000000 a.seqno, a.pagibigid, a.account_no, a.lname, a.fname, a.mid, a.name_ext, a.birthdate, a.civil_status, a.gender, a.basic, a.program_code, a.membership_category, a.employerid, a.branch_code, a.init_percov, a.last_percov, a.init_remit, a.last_remit, a.occupationcode, a.ee, a.er, a.div, a.country, a.mobile_no, a.with_final_claim, Int2(-1), AnsiDate(b.cutdate), AnsiDate('today') as rundate from cpr_memberlist a inner join report_parameters b on b.cutdate <> Date('') left join stg_corplan_report_ml c on a.pagibigid = c.pagibigid and a.account_no = c.account_no and a.program_code = c.program_code where c.pagibigid is null; modify session.tmp_corplan_report_ml to btree unique on seqno; \n