UPDATE OR INSERT INTO SYS_PROGRAM (PGMID, GRPSEQ, grpcd, GRPNM, SUBSEQ, SUBCD, SUBNM, SYSVER, PGMGB, MENUDSP,
            IMGNO, MENULVL, SORTSEQ, UDLINE, USEGB,
            VERPGM, DLLNM, PGMNM, HOTPGM, HOTPGMNM, PGMHINT, CRTID, CRTDT, MODID, MODDT) VALUES
            ('USER1110', 1, 'USER', '통계', 1, 'USER', '통계관련', '', 'C',
            'N', 39, 1, 100, 'N', 'Y', '1.0', 'system', '합계와통계', 'N', '',
            '합계부분과 통계창을 볼 수 있습니다', '999', '2023-03-01 01:01:01', '999', '2023-03-01 01:01:01')

    EXECUTE BLOCK AS BEGIN 
           if (not exists(select 1 from rdb$relations where rdb$relation_name = 'SAL_HGBGJ')) then 
           begin 
             execute statement 'CREATE TABLE SAL_HGBGJ (
                BGJCD VARCHAR(12) NOT NULL, 
                GJGB DVCHAR05, 
                BHIL DVCHAR10, 
                BHSG DVCHAR10, 
                BHAMT DNUM182, 
                SYIL DVCHAR10, 
                SYAMT DNUM182, 
                IGCASH DNUM182, 
                IGCARD DNUM182, 
                CASHJPNO DVCHAR20, 
                CARDJPNO DVCHAR20, 
                BIGO01 DVCHAR50, 
                JPNO DVCHAR20, 
                ACCJPNO DVCHAR20)'; 
             execute statement 'alter table SAL_HGBGJ ADD CONSTRAINT PK_SAL_HGBGJ PRIMARY KEY (BGJCD)'; 
            end 
           END 

    EXECUTE block as 
            BEGIN 
            if (not exists(
            select 1 from RDB$RELATION_FIELDS rf 
            where rf.RDB$RELATION_NAME = 'MBR_MILEAGE' and rf.RDB$FIELD_NAME = 'MILEHI')) 
            then 
            execute statement 'ALTER TABLE MBR_MILEAGE ADD MILEHI varchar(1)'; 
            END

UPDATE OR INSERT INTO SYS_CDMASTER (CDGRP, CDCD, CDNM, CDNMYC) VALUES ('MG17', '######', '메시지현금보관증', '메시지현금보관증')

UPDATE MBR_MILEAGE SET MILEHI = 'N'

    EXECUTE BLOCK AS BEGIN 
           if (not exists(select 1 from rdb$relations where rdb$relation_name = 'SAL_HISTIGJG')) then 
           begin 
             execute statement 'CREATE TABLE SAL_HISTIGJG (
               WORKDT     DVCHAR20 NOT NULL, 
               JPNO       DVCHAR20 NOT NULL, 
               WORKGB  DVCHAR06, 
               IOGB       DVCHAR06, 
               ILJA       DVCHAR10 , 
               POSNO      DVCHAR06 , 
               BUYERGB    DVCHAR06 , 
               BUYERCD    DVCHAR10 , 
               BUYERNM    DVCHAR50 , 
               DEPTNM     DVCHAR30 , 
               CASHYSJBH  DVCHAR06 , 
               CARDGJGB   DVCHAR06 , 
               IGCASH     DNUM182 , 
               IGCARD     DNUM182 , 
               IGBANK     DNUM182 , 
               IGEE       DNUM182 , 
               DCAMT      DNUM182 , 
               CUTAMT     DNUM182 , 
               TOTALAMT   DNUM182 , 
               BANKCD     DVCHAR06 , 
               MGILJA     DVCHAR10 , 
               CASHYSJNO  DVCHAR30 , 
               CASHJPNO   DVCHAR20 , 
               CARDNO     DVCHAR30 , 
               CARDJPNO   DVCHAR20 , 
               ACCJPNO    DVCHAR20 , 
               BIGO01     DVCHAR100 , 
               CRTID      DVCHAR20 , 
               CRTDT      DVCHAR20 , 
               MODID      DVCHAR20 , 
               MODDT      DVCHAR20 , 
               WORKID     DVCHAR10 , 
               WORKPOSNO  DVCHAR06)'; 
             execute statement 'alter table SAL_HISTIGJG ADD CONSTRAINT PK_SAL_HISTIGJG PRIMARY KEY (WORKDT, JPNO)'; 
           end 
           END 

EXECUTE block as BEGIN if (NOT EXISTS(SELECT * FROM SYS_CDMASTER WHERE CDCD = 'NICE')) then 
INSERT INTO SYS_CDMASTER (CDGRP, CDCD, CDNM, CDNMYC, CDSEQ, EXTVAL1, EXTVAL2, SYSCD, USEGB, STARTDT, ENDDT, CRTID, CRTDT, MODID, MODDT) 
VALUES ('SS33', 'NICE', 'NICE', '단말기번호', 7, '', '99999', 'Y', 'Y', '2024-01-30', '', 'system', '2024-01-30 01:01:01','system', '2024-01-30 01:01:01'); 
END

UPDATE OR INSERT INTO SYS_CDMASTER (CDGRP, CDCD, CDNM, CDNMYC, CDSEQ, EXTVAL1, EXTVAL2, SYSCD, USEGB, STARTDT, ENDDT, CRTID, CRTDT, MODID, MODDT) 
VALUES ('SS36', 'NICE', 'NICE', 'NICE', 9, '', '', 'Y', 'Y', '2024-01-30', '', 'system', '2024-01-30 01:01:01','system', '2024-01-30 01:01:01') MATCHING (CDGRP, CDCD)

UPDATE OR INSERT INTO SYS_VERSIONDB (DBFNM, VERUPDT) VALUES ('DBUpdate', '2024-01-30') 