/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BCM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ISGROUPSRCEXPRENTRY') 
 CREATE TABLE T_BCM_ISGROUPSRCEXPRENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FEXPRESSIONS VARCHAR(500) DEFAULT ' ' NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ISGROUPSRCMAPENTRY') 
 CREATE TABLE T_BCM_ISGROUPSRCMAPENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FDIMENSIONID BIGINT DEFAULT 0 NOT NULL,
FMEMBERID BIGINT DEFAULT 0 NOT NULL,
FSCOPE INT DEFAULT 1 NOT NULL,
FISDYNA CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ISGROUPTARGMAPENTRY') 
 CREATE TABLE T_BCM_ISGROUPTARGMAPENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FDIMENSIONID BIGINT DEFAULT 0 NOT NULL,
FMEMBERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ISSINGLEMAP') 
 CREATE TABLE T_BCM_ISSINGLEMAP (
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FDIMMAPID BIGINT DEFAULT 0 NOT NULL,
FSCOPE INT DEFAULT 1 NOT NULL,
FSRCMEMBNUMBER VARCHAR(200) DEFAULT ' ' NOT NULL,
FTARGMEMBNUMBER VARCHAR(200) DEFAULT ' ' NOT NULL,
FTARGMEMBID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ISSINGLEMAP_L') 
 CREATE TABLE T_BCM_ISSINGLEMAP_L (
FTARGMEMBNAME NVARCHAR(200) DEFAULT ' ' NOT NULL,
FSRCMEMBNAME NVARCHAR(200) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FPKID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(36) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ISSINGLEMAPENTRY') 
 CREATE TABLE T_BCM_ISSINGLEMAPENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSRCDIMID BIGINT DEFAULT 0 NOT NULL,
FSRCMEMBID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ISGROUPMAP') 
 CREATE TABLE T_BCM_ISGROUPMAP (
ID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FGROUP INT DEFAULT 0 NOT NULL,
FDIMMAPID BIGINT DEFAULT 0 NOT NULL,
FSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FCOMPUTEOPRT INT DEFAULT 1 NOT NULL,
FISDYNA CHAR(1) DEFAULT '0' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_ANALYSOLUCOLUMNDIM' AND KSQL_COL_NAME IN ('FSEQ')) 
 ALTER TABLE T_BCM_ANALYSOLUCOLUMNDIM ADD (FSEQ INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_ANALYSOLUPAGEDIM' AND KSQL_COL_NAME IN ('FSEQ')) 
 ALTER TABLE T_BCM_ANALYSOLUPAGEDIM ADD (FSEQ INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_ANALYSOLUROWDIM' AND KSQL_COL_NAME IN ('FSEQ')) 
 ALTER TABLE T_BCM_ANALYSOLUROWDIM ADD (FSEQ INT DEFAULT 0 NOT NULL );

/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BCM_table.sql **/
