\set VERBOSITY terse \set ON_ERROR_STOP BEGIN; WITH upsert AS (update MSG set (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) = (to_timestamp('201302081100', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021') where slot=to_timestamp('201302081100', 'YYYYMMDDHH24MI') and MSG=3 RETURNING *) insert into MSG (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) select to_timestamp('201302081100', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021' WHERE NOT EXISTS (SELECT * FROM upsert WHERE slot=to_timestamp('201302081100', 'YYYYMMDDHH24MI') and MSG=3); WITH upsert AS (update MSG set (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) = (to_timestamp('201302080515', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021') where slot=to_timestamp('201302080515', 'YYYYMMDDHH24MI') and MSG=3 RETURNING *) insert into MSG (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) select to_timestamp('201302080515', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021' WHERE NOT EXISTS (SELECT * FROM upsert WHERE slot=to_timestamp('201302080515', 'YYYYMMDDHH24MI') and MSG=3); WITH upsert AS (update MSG set (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) = (to_timestamp('201302080815', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021') where slot=to_timestamp('201302080815', 'YYYYMMDDHH24MI') and MSG=3 RETURNING *) insert into MSG (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) select to_timestamp('201302080815', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021' WHERE NOT EXISTS (SELECT * FROM upsert WHERE slot=to_timestamp('201302080815', 'YYYYMMDDHH24MI') and MSG=3); WITH upsert AS (update MSG set (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) = (to_timestamp('201302080945', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021') where slot=to_timestamp('201302080945', 'YYYYMMDDHH24MI') and MSG=3 RETURNING *) insert into MSG (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) select to_timestamp('201302080945', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021' WHERE NOT EXISTS (SELECT * FROM upsert WHERE slot=to_timestamp('201302080945', 'YYYYMMDDHH24MI') and MSG=3); WITH upsert AS (update MSG set (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) = (to_timestamp('201302080930', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021') where slot=to_timestamp('201302080930', 'YYYYMMDDHH24MI') and MSG=3 RETURNING *) insert into MSG (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) select to_timestamp('201302080930', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021' WHERE NOT EXISTS (SELECT * FROM upsert WHERE slot=to_timestamp('201302080930', 'YYYYMMDDHH24MI') and MSG=3); WITH upsert AS (update MSG set (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) = (to_timestamp('201302080200', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021') where slot=to_timestamp('201302080200', 'YYYYMMDDHH24MI') and MSG=3 RETURNING *) insert into MSG (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) select to_timestamp('201302080200', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021' WHERE NOT EXISTS (SELECT * FROM upsert WHERE slot=to_timestamp('201302080200', 'YYYYMMDDHH24MI') and MSG=3); WITH upsert AS (update MSG set (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) = (to_timestamp('201302081430', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021') where slot=to_timestamp('201302081430', 'YYYYMMDDHH24MI') and MSG=3 RETURNING *) insert into MSG (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) select to_timestamp('201302081430', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021' WHERE NOT EXISTS (SELECT * FROM upsert WHERE slot=to_timestamp('201302081430', 'YYYYMMDDHH24MI') and MSG=3); WITH upsert AS (update MSG set (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) = (to_timestamp('201302082000', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021') where slot=to_timestamp('201302082000', 'YYYYMMDDHH24MI') and MSG=3 RETURNING *) insert into MSG (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) select to_timestamp('201302082000', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021' WHERE NOT EXISTS (SELECT * FROM upsert WHERE slot=to_timestamp('201302082000', 'YYYYMMDDHH24MI') and MSG=3); WITH upsert AS (update MSG set (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) = (to_timestamp('201302080530', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021') where slot=to_timestamp('201302080530', 'YYYYMMDDHH24MI') and MSG=3 RETURNING *) insert into MSG (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) select to_timestamp('201302080530', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021' WHERE NOT EXISTS (SELECT * FROM upsert WHERE slot=to_timestamp('201302080530', 'YYYYMMDDHH24MI') and MSG=3); WITH upsert AS (update MSG set (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) = (to_timestamp('201302082100', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021') where slot=to_timestamp('201302082100', 'YYYYMMDDHH24MI') and MSG=3 RETURNING *) insert into MSG (slot,MSG,HRV,VIS006,VIS008,IR_016,IR_039,WV_062,WV_073,IR_087,IR_097,IR_108,IR_120,IR_134,PRO,EPI,CLM,TAPE) select to_timestamp('201302082100', 'YYYYMMDDHH24MI'),3,'\xffffff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff','\x01','\x01','\x7f','LTO5_021' WHERE NOT EXISTS (SELECT * FROM upsert WHERE slot=to_timestamp('201302082100', 'YYYYMMDDHH24MI') and MSG=3); COMMIT;