IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PMTS_PLAN_MODEL') 
CREATE TABLE T_PMTS_PLAN_MODEL
(
  FID BIGINT DEFAULT 0 NOT NULL,          	
  FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL, 	
  FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL, 
  FSTATUS NVARCHAR(1) DEFAULT ' ' NOT NULL, 	
  FCREATORID BIGINT DEFAULT 0 NOT NULL,   
  FMODIFIERID BIGINT DEFAULT 0 NOT NULL,  	
  FENABLE NVARCHAR(1) DEFAULT ' ' NOT NULL, 	
  FCREATETIME DATETIME ,                  	
  FMODIFYTIME DATETIME ,                  	
  FMASTERID BIGINT DEFAULT 0 NOT NULL,    	
  FLONGNUMBER NVARCHAR(500) DEFAULT ' ' NOT NULL, 
  FLEVEL INT DEFAULT 0 NOT NULL,          	
  FISLEAF CHAR(1) DEFAULT '0' NOT NULL,  
  FPARENTID BIGINT DEFAULT 0 NOT NULL,    	
  FCREATEORGID BIGINT DEFAULT 0 NOT NULL, 
  FCTRLSTRATEGY NVARCHAR(5) DEFAULT ' ' NOT NULL, 	
  FSOURCEDATAID BIGINT DEFAULT 0 NOT NULL, 	
  FBITINDEX INT DEFAULT 0 NOT NULL,       
  FSOURCEBITINDEX INT DEFAULT 0 NOT NULL, 	
  FMODELTYPEID BIGINT DEFAULT 0 NOT NULL, 	
  FREMARK NVARCHAR(58) DEFAULT ' ' NOT NULL, 	
  FWBSTYPEID BIGINT DEFAULT 0 NOT NULL,   	
  FPROJECTSTAGEID BIGINT DEFAULT 0 NOT NULL, 	
  FRESPONSORGID BIGINT DEFAULT 0 NOT NULL, 	
  FRESPONSPERSONID BIGINT DEFAULT 0 NOT NULL, 	
  FCOSTOBJ CHAR(1) DEFAULT '0' NOT NULL,  	
  FAUDITORID BIGINT DEFAULT 0 NOT NULL,   
  FAUDITDATE DATETIME ,                   	
  FISTEMPLATE CHAR(1) DEFAULT '0' NOT NULL, 	
  FVERSION NVARCHAR(50) DEFAULT ' ' NOT NULL, 	
  FPREPARATIONTIME DATETIME ,             	
  FTEMPLATESET NVARCHAR(5) DEFAULT ' ' NOT NULL, 	
  FWBSNAME NVARCHAR(50) DEFAULT ' ' NOT NULL, 
  FWTIMEUNIT NVARCHAR(5) DEFAULT ' ' NOT NULL, 	
  FMODELNAME NVARCHAR(50) DEFAULT ' ' NOT NULL, 
  FMODELSTATUS NVARCHAR(1) DEFAULT ' ' NOT NULL, 	
  FMODELNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL, 	
  FPREPAREDBY BIGINT DEFAULT 0 NOT NULL,  
  FESTIMATEDDAYS DECIMAL(23,10) DEFAULT 0 NOT NULL 
);

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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PMTS_TASKTPENTRYENTITYS') 
CREATE TABLE T_PMTS_TASKTPENTRYENTITYS
(
  FID BIGINT DEFAULT 0 NOT NULL,          	
  FENTRYID BIGINT DEFAULT 0 NOT NULL,     
  FSEQ INT DEFAULT 0 NOT NULL,            
  FTASKNAME NVARCHAR(50) DEFAULT ' ' NOT NULL, 
  FWBSTNAME NVARCHAR(50) DEFAULT ' ' NOT NULL, 
  FTASKTYPEID BIGINT DEFAULT 0 NOT NULL,
  FTIMEUNIT NVARCHAR(5) DEFAULT ' ' NOT NULL, 	
  FPLANTIME DECIMAL(23,10) DEFAULT 0 NOT NULL, 	
  FWORKLOADUNIT NVARCHAR(5) DEFAULT ' ' NOT NULL, 	
  FPLANHOURS DECIMAL(23,10) DEFAULT 0 NOT NULL, 	
  FPLANSTARTDATE DATETIME ,               	
  FPLANENDDATE DATETIME ,               
  FTRESPONSORG BIGINT DEFAULT 0 NOT NULL, 	
  FTRESPONSPERSON BIGINT DEFAULT 0 NOT NULL, 	
  FTASKRELATIONTWO NVARCHAR(5) DEFAULT ' ' NOT NULL, 
  FTASKRELATION NVARCHAR(5) DEFAULT ' ' NOT NULL, 	
  FPERCENTTYPE NVARCHAR(5) DEFAULT ' ' NOT NULL, 
  FPRETASK NVARCHAR(50) DEFAULT ' ' NOT NULL, 	
  FPOSTTASK NVARCHAR(50) DEFAULT ' ' NOT NULL 
);




