/**Begin D:\work\kuaijishijian\pdm\PDM_UPGRADE_1.4\PDM_UPGRADE\PDM1\AI_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FAH_EVT_DISP_RULE' AND KSQL_COL_NAME ='FNEEDGENEVT')
ALTER TABLE T_FAH_EVT_DISP_RULE ADD (FNEEDGENEVT CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FAH_EVT_DISP_RULE_TMP' AND KSQL_COL_NAME ='FNEEDGENEVT')
ALTER TABLE T_FAH_EVT_DISP_RULE_TMP ADD (FNEEDGENEVT CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FAH_REQUEST_TASK' AND KSQL_COL_NAME ='FNOGENEVTCNT')
ALTER TABLE T_FAH_REQUEST_TASK ADD (FNOGENEVTCNT INT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_TASK_NOEVT_BILLS')
CREATE TABLE T_FAH_TASK_NOEVT_BILLS (
                                        FID BIGINT DEFAULT 0 NOT NULL,
                                        FREQUESTID BIGINT DEFAULT 0 NOT NULL,
                                        FBILLTYPE VARCHAR(36) DEFAULT ' ' NOT NULL,
                                        FSRCBILLID BIGINT DEFAULT 0 NOT NULL,
                                        FSRCBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
                                        FSRCBILLENTRY VARCHAR(36) DEFAULT ' ' NOT NULL,
                                        FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
                                        FDISPATCHID BIGINT DEFAULT 0 NOT NULL,
                                        FDISPATCHVERSION INT DEFAULT 0 NOT NULL,
                                        FMSG NVARCHAR(500) DEFAULT ' ' NOT NULL
);

 EXEC P_ALTERPK 'PK_FAH_TASK_NOEVT_BILLS', 'T_FAH_TASK_NOEVT_BILLS', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_TABNAME = 'T_FAH_TASK_NOEVT_BILLS' AND KSQL_INDNAME = 'IDX_FAH_TASK_NOEVT_BILLS') CREATE INDEX IDX_FAH_TASK_NOEVT_BILLS ON T_FAH_TASK_NOEVT_BILLS ( FREQUESTID );

/**End D:\work\kuaijishijian\pdm\PDM_UPGRADE_1.4\PDM_UPGRADE\PDM1\AI_table.sql **/
