IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_REPORTEXTMODEL') 
CREATE TABLE T_MSPLAN_REPORTEXTMODEL (
	FID BIGINT DEFAULT 0 NOT NULL,
	FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
	FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
	FSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
	FCREATORID BIGINT DEFAULT 0 NOT NULL,
	FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
	FENABLE NVARCHAR(50) DEFAULT ' ' NOT NULL,
	FCREATETIME DATETIME,
	FMODIFYTIME DATETIME,
	FMASTERID BIGINT DEFAULT 0 NOT NULL,
	FREPORTENTITY NVARCHAR(36) DEFAULT ' ' NOT NULL,
	FISSYSSET CHAR(1) DEFAULT '0' NOT NULL,
	FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL
	
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_REPORTEXTENTITY') 
CREATE TABLE T_MSPLAN_REPORTEXTENTITY (
	FID BIGINT DEFAULT 0 NOT NULL,
	FENTRYID BIGINT DEFAULT 0 NOT NULL,
	FSEQ BIGINT DEFAULT 0 NOT NULL,
	FEXTENTITY NVARCHAR(36) DEFAULT ' ' NOT NULL,
	FMATCHDIMENSIONS BIGINT DEFAULT 0 NOT NULL,
	FFILTERRULE NVARCHAR(2000) DEFAULT ' ' NOT NULL,
	FFILTERRULEVALUE NVARCHAR(2000) DEFAULT ' ' NOT NULL,
	FFILTERRULEVALUE_TAG NCLOB,
	FDSNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_REPORTEXTCOLUMN') 
CREATE TABLE T_MSPLAN_REPORTEXTCOLUMN (
	FID BIGINT DEFAULT 0 NOT NULL,
	FENTRYID BIGINT DEFAULT 0 NOT NULL,
	FSEQ BIGINT DEFAULT 0 NOT NULL,
	FDATASOURCEENTITY NVARCHAR(36) DEFAULT ' ' NOT NULL,
	FFIELDNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
	FFIELDNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
	FFIELDUNVISIBLE CHAR(1) DEFAULT '0' NOT NULL,
	FCALCULATEEXC NVARCHAR(2000) DEFAULT ' ' NOT NULL,
	FCALCULATEEXC_TAG NCLOB,
	FCALCULATETEXT NVARCHAR(2000) DEFAULT ' ' NOT NULL,
	FDATATYPE NVARCHAR(255) DEFAULT ' ' NOT NULL,
	FISSYSSETFIELD CHAR(1) DEFAULT '0' NOT NULL,
	FCONVERTTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
	FSRCDSNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL
	
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_REPORTEXTMODEL_L') 
CREATE TABLE T_MSPLAN_REPORTEXTMODEL_L (
	FPKID NVARCHAR(36) DEFAULT ' ' NOT NULL,
	FID BIGINT DEFAULT 0 NOT NULL,
	FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
	FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
	FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL
	
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_REPORTEXTCOLUMN_L') 
CREATE TABLE T_MSPLAN_REPORTEXTCOLUMN_L (
	FPKID NVARCHAR(36) DEFAULT ' ' NOT NULL,
	FENTRYID BIGINT DEFAULT 0 NOT NULL,
	FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
	FFIELDNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
	FDATATYPE NVARCHAR(255) DEFAULT ' ' NOT NULL
	
);



--调整多语言字段的长度为200
 EXEC P_ALTERCOLUMN 'T_MSPLAN_REPORTEXTMODEL_L', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' '''; 
 EXEC P_ALTERCOLUMN 'T_MSPLAN_REPORTEXTMODEL', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' '''; 

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

