/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\EB_table.sql **/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_DATASET' AND KSQL_COL_NAME ='FBIZMODELID') 
 ALTER TABLE T_EB_DATASET ADD (FBIZMODELID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_BIZRULESET' AND KSQL_COL_NAME ='FPERIODOFFSET') 
 ALTER TABLE T_EB_BIZRULESET ADD (FPERIODOFFSET NVARCHAR(2000) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_BIZRULESET' AND KSQL_COL_NAME ='FAPPLICATIONSCENARIO') 
 ALTER TABLE T_EB_BIZRULESET ADD (FAPPLICATIONSCENARIO BIGINT DEFAULT 0 NOT NULL );


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_ACCOUNTMETRIC') 
CREATE TABLE T_EB_ACCOUNTMETRIC (
   FID                  BIGINT               NOT NULL DEFAULT 0,
   FENTRYID             BIGINT               NOT NULL DEFAULT 0,
   FMETRIC              BIGINT               NOT NULL DEFAULT 0,
   FISTOPOLY            CHAR(1)              NOT NULL DEFAULT '0',
   FDATABYTIME          NVARCHAR(30)         NOT NULL DEFAULT ' ',
   FSKIP                NVARCHAR(30)         NOT NULL DEFAULT ' ',
   FMETRICDESCRIPTION   NVARCHAR(510)        NOT NULL DEFAULT ' ',
   FSEQ                 INT                  NOT NULL DEFAULT 0,
   FCHANGE              CHAR(1)              NOT NULL DEFAULT '1'
);

 EXEC P_ALTERPK 'PK_T_EB_ACCOUNTMETRIC', 'T_EB_ACCOUNTMETRIC', 'FENTRYID', '1';

/*==============================================================*/
/* INDEX: IDX_EB_ACCOUNTMETRIC                                    */
/*==============================================================*/
 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_ACCOUNTMETRIC')
CREATE INDEX IDX_EB_ACCOUNTMETRIC ON T_EB_ACCOUNTMETRIC (
FMETRIC ASC
);
/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\EB_table.sql **/
