/**Begin D:\PDM_UPGRADE\PDM1\BCM_table.sql **/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_PAPERTEMPLATE') 
 CREATE TABLE T_BCM_PAPERTEMPLATE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FTEMPLATECATALOG BIGINT DEFAULT 0 NOT NULL,
FPERMCLASS BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSCENARIOID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FEFFECTIVEDATE DATETIME,
FEXPIRINGDATE DATETIME,
FVERSIONSTATUS CHAR(1) DEFAULT '1' NOT NULL,
FVERSIONNUMBER DECIMAL(5,2) DEFAULT 1.0 NOT NULL,
FVERSIONDESCRIPTION NVARCHAR(500) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT '0' NOT NULL,
FTEMPLATETYPE VARCHAR(2) DEFAULT ' ' NOT NULL,
FGROUPID BIGINT DEFAULT 0 NOT NULL,
FDESCRIPTION NVARCHAR(500) DEFAULT ' ' NOT NULL,
FISAUTOSHOW CHAR(1) DEFAULT '0' NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSELLER BIGINT DEFAULT 0 NOT NULL,
FPURCHASER BIGINT DEFAULT 0 NOT NULL,
FMERGENODE BIGINT DEFAULT 0 NOT NULL,
FCOUNT INT DEFAULT 0 NOT NULL,
FSPREADTYPE CHAR(1) DEFAULT '1' NOT NULL,
FINVRELATIONTYPE CHAR(1) DEFAULT '1' NOT NULL,
FAREAPOINT VARCHAR(50) DEFAULT ' ' NOT NULL,
FJOURNALTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FBALANCETYPE CHAR(1) DEFAULT ' ' NOT NULL,
FBUSSNESSTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FLINKCREATETY CHAR(1) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_PAPERTEMPLATE_S')
 CREATE TABLE T_BCM_PAPERTEMPLATE_S (
FID BIGINT DEFAULT 0 NOT NULL,
FSPREADJSON NCLOB,
FDATA NCLOB,
FEFFECTIVESCOPE NCLOB,
FTEMPLATEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_PAPERTEMPLATE_L') 
 CREATE TABLE T_BCM_PAPERTEMPLATE_L (
FPKID VARCHAR(30) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FVERSIONDESCRIPTION NVARCHAR(500) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_PAPERTPLCATALOG') 
 CREATE TABLE T_BCM_PAPERTPLCATALOG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPARENTTEXT VARCHAR(50) DEFAULT ' ' NOT NULL,
FPERMCLASS BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FLEVEL BIGINT DEFAULT 0 NOT NULL,
FSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FMODELORG BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FFULLNAME NVARCHAR(500) DEFAULT ' ' NOT NULL,
FISLEAF CHAR(1) DEFAULT '1' NOT NULL,
FLONGNUMBER VARCHAR(500) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCATALOGTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FPARENTID BIGINT DEFAULT 0 NOT NULL,
FINSTRUCTION NVARCHAR(500) DEFAULT ' ' NOT NULL,
FSCENEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_PAPERTPLCATALOG_L') 
 CREATE TABLE T_BCM_PAPERTPLCATALOG_L (
FPKID VARCHAR(30) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FFULLNAME NVARCHAR(500) DEFAULT ' ' NOT NULL,
FINSTRUCTION NVARCHAR(500) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_PAPERDISTRIBUTION') 
 CREATE TABLE T_BCM_PAPERDISTRIBUTION (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FENTITYID BIGINT DEFAULT 0 NOT NULL,
FTEMPLATEID BIGINT DEFAULT 0 NOT NULL,
FTEXTNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPROPERTY BIGINT DEFAULT 0 NOT NULL,
FPROPERTYVALUE BIGINT DEFAULT 0 NOT NULL,
FRANGE VARCHAR(6) DEFAULT ' ' NOT NULL,
FISEXCEPT CHAR(1) DEFAULT '0' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);



/**End D:\PDM_UPGRADE\PDM1\BCM_table.sql **/
