IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_CHECKING_EXP_LIST')
create table t_er_checking_exp_list
(
    fid                    bigint       default 0                                        not null,
    fbillno                varchar(30) default ' ' not null,
    fbillstatus            varchar(50) default ' ' not null,
    fcreatorid             BIGINT DEFAULT 0 NOT NULL,
    fmodifierid            BIGINT DEFAULT 0 NOT NULL,
    fauditorid          BIGINT DEFAULT 0 NOT NULL,
    fauditdate             DATETIME,
    fmodifytime            DATETIME,
    fcreatetime            DATETIME,
    fcostcompanyid         BIGINT DEFAULT 0 NOT NULL,
    fcostdeptid            BIGINT DEFAULT 0 NOT NULL,
    fcheckingtotalamount   DECIMAL(23, 10) default 0                      not null,
    fcurrency              BIGINT DEFAULT 0 NOT NULL,
    fmsgcount              BIGINT DEFAULT 0 NOT NULL,
    fperiod                DATETIME,
    fneedsend              char(1)       default '0'           not null,
    fformid                varchar(50) default ' ' not null
);
EXEC p_AlterPK 'PK_T_ER_CHECKING_EXP_LIST', 'T_ER_CHECKING_EXP_LIST', 'fid', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_VEHICLE_EXP_USER')
create table t_er_vehicle_exp_user
(
    fpkid       bigint       default 0                                        not null,
    fid         BIGINT DEFAULT 0 NOT NULL,
    fbasedataid BIGINT DEFAULT 0 NOT NULL
);
EXEC p_AlterPK 'PK_T_ER_VEHICLE_EXP_USER', 'T_ER_VEHICLE_EXP_USER', 'fpkid', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_CHECKING_EXP_DETAIL')
create table t_er_checking_exp_detail
(
    fid              bigint       default 0                                        not null,
    fentryid         bigint       default 0                                        not null,
    fseq             BIGINT DEFAULT 0 NOT NULL,
    fsourcebookedid  BIGINT DEFAULT 0 NOT NULL,
    fhappenddate     DATETIME,
    fordernum        varchar(50)  default ' ' not null,
    fvendorname      varchar(50)  default ' ' not null,
    fcityname        varchar(50)  default ' ' not null,
    fusetime         DATETIME,
    fdepartaddress   varchar(100) default ' ' not null,
    farriveaddress   varchar(100) default ' ' not null,
    fdistance        varchar(50)  default ' ' not null,
    ftotalamount     DECIMAL(23, 10) default 0                      not null
);
EXEC p_AlterPK 'PK_T_ER_CHECKING_EXP_DETAIL', 'T_ER_CHECKING_EXP_DETAIL', 'fentryid', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_CHECKING_EXP_DETAIL_LK')
create table t_er_checking_exp_detail_lk
(
    fentryid  bigint       default 0                                        not null,
    fpkid     bigint       default 0                                        not null,
    fseq      bigint       default 0                                        not null,
    fstableid bigint       default 0                                        not null,
    fsbillid  bigint       default 0                                        not null,
    fsid      bigint       default 0                                        not null
);
EXEC p_AlterPK 'PK_T_ER_CHECKING_EXP_DETAIL_LK', 'T_ER_CHECKING_EXP_DETAIL_LK', 'fpkid', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_CHECKING_EXP_LIST_TC')
create table t_er_checking_exp_list_tc
(
    fid       bigint       default 0                                        not null,
    ftbillid  bigint       default 0                                        not null,
    fttableid bigint       default 0                                        not null,
    ftid      bigint       default 0                                        not null,
    fsbillid  bigint       default 0                                        not null,
    fstableid bigint       default 0                                        not null,
    fsid      bigint       default 0                                        not null
);
EXEC p_AlterPK 'PK_T_ER_CHECKING_EXP_LIST_TC', 'T_ER_CHECKING_EXP_LIST_TC', 'fid', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_CHECKING_EXP_LIST_WB')
create table t_er_checking_exp_list_wb
(
    fid         bigint       default 0                                        not null,
    fentryid    bigint       default 0                                        not null,
    fseq        bigint       default 0                                        not null,
    fruleverid  bigint       default 0                                        not null,
    fruleitemid bigint       default 0                                        not null,
    foperate    varchar(50) default ' '                                       not null,
    fstableid   bigint       default 0                                        not null,
    fsid        bigint       default 0                                        not null,
    fsbillid    bigint       default 0                                        not null,
    fwritevalue DECIMAL(23, 10) default 0                                     not null
);
EXEC p_AlterPK 'PK_T_ER_CHECKING_EXP_LIST_WB', 'T_ER_CHECKING_EXP_LIST_WB', 'fentryid', '1';