IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_SAFETYSTOCK' AND KSQL_COL_NAME ='FEFFECTTTIME') 
 ALTER TABLE T_MDS_SAFETYSTOCK ADD (FEFFECTTTIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_SAFETYSTOCK' AND KSQL_COL_NAME ='FLOSEEFFECTTIME') 
 ALTER TABLE T_MDS_SAFETYSTOCK ADD (FLOSEEFFECTTIME DATETIME );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_QUOTA' AND KSQL_COL_NAME ='FLOSEDATE') 
 ALTER TABLE T_MDS_QUOTA ADD (FLOSEDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_QUOTA' AND KSQL_COL_NAME ='FEFFECTDATE') 
 ALTER TABLE T_MDS_QUOTA ADD (FEFFECTDATE DATETIME );

 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_RPLANCAL' AND KSQL_COL_NAME ='FOUTLOOKPERIOD') 
 ALTER TABLE T_MDS_RPLANCAL ADD (FOUTLOOKPERIOD DECIMAL(23,10) DEFAULT 0 NOT NULL );

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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_PLANEXEC') 
	 CREATE TABLE T_MDS_PLANEXEC
	(
	  FID BIGINT DEFAULT 0 NOT NULL,
	  fnumber       NVARCHAR(80) DEFAULT ' ' NOT NULL,
	  fstatus       NVARCHAR(30) DEFAULT ' ' NOT NULL,
	  fcreatorid    BIGINT DEFAULT 0 NOT NULL,
	  fmodifierid   BIGINT DEFAULT 0 NOT NULL,
	  fenable       NVARCHAR(30) DEFAULT ' ' NOT NULL,
	  fcreatetime   DATETIME,
	  fmodifytime   DATETIME,
	  fmasterid     BIGINT DEFAULT 0 NOT NULL,
	  fcreateorgid  BIGINT DEFAULT 0 NOT NULL,
	  forgid        BIGINT DEFAULT 0 NOT NULL,
	  fuseorg       BIGINT DEFAULT 0 NOT NULL,
	  fctrlstrategy NVARCHAR(30) DEFAULT ' ' NOT NULL,
	  fcalculatepro DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  fstartdate    DATETIME,
	  fenddate      DATETIME,
	  fsummin       DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  frplancalid   BIGINT DEFAULT 0 NOT NULL
	);

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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_EXECLOGEENTRY') 
	CREATE TABLE T_MDS_EXECLOGEENTRY
	(
	  fid          BIGINT DEFAULT 0 NOT NULL,
	  fentryid     BIGINT DEFAULT 0 NOT NULL,
	  fseq         BIGINT DEFAULT 0 NOT NULL,
	  fstepseq     NVARCHAR(50) DEFAULT ' ' NOT NULL,
	  fstepname    NVARCHAR(50) DEFAULT ' ' NOT NULL,
	  fprocessdata BIGINT DEFAULT 0 NOT NULL,
	  foperatmin   DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  fresult      NVARCHAR(200) DEFAULT ' ' NOT NULL,
	  fdetailmsg   NVARCHAR(255) DEFAULT ' ' NOT NULL
	);

 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_PLANEXEC' AND KSQL_COL_NAME ='FDAYSOFWEEK') 
 ALTER TABLE T_MDS_PLANEXEC ADD (FDAYSOFWEEK NVARCHAR(50) DEFAULT ' ' NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_PLANEXEC' AND KSQL_COL_NAME ='FDAYSOFMON') 
 ALTER TABLE T_MDS_PLANEXEC ADD (FDAYSOFMON NVARCHAR(50) DEFAULT ' ' NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_PLANEXEC' AND KSQL_COL_NAME ='FRUNNINGTYPE') 
 ALTER TABLE T_MDS_PLANEXEC ADD (FRUNNINGTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_PLANEXEC' AND KSQL_COL_NAME ='FREPEATTYPE') 
 ALTER TABLE T_MDS_PLANEXEC ADD (FREPEATTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_PLANEXEC' AND KSQL_COL_NAME ='FJOBID') 
 ALTER TABLE T_MDS_PLANEXEC ADD (FJOBID NVARCHAR(50) DEFAULT ' ' NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_PLANEXEC' AND KSQL_COL_NAME ='FPLANID') 
 ALTER TABLE T_MDS_PLANEXEC ADD (FPLANID NVARCHAR(50) DEFAULT ' ' NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_PLANEXEC' AND KSQL_COL_NAME ='FLOSEDATE') 
 ALTER TABLE T_MDS_PLANEXEC ADD (FLOSEDATE DATETIME);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_PLANEXEC' AND KSQL_COL_NAME ='FPREDTIME') 
 ALTER TABLE T_MDS_PLANEXEC ADD (FPREDTIME BIGINT DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_PLANEXEC' AND KSQL_COL_NAME ='FREPEAT') 
 ALTER TABLE T_MDS_PLANEXEC ADD (FREPEAT CHAR(1) DEFAULT ' ' NOT NULL);
 
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_RPLANCAL' AND KSQL_COL_NAME ='FDUMMYSITEID')
 ALTER TABLE T_MDS_RPLANCAL ADD (FDUMMYSITEID BIGINT DEFAULT 0 NOT NULL);
 


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_WRTFF' AND KSQL_COL_NAME ='FCALCULATEPRO')
 ALTER TABLE T_MDS_WRTFF ADD (FCALCULATEPRO DECIMAL(23,10) DEFAULT 0 NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_WRTFF' AND KSQL_COL_NAME ='FSTARTDATE')
 ALTER TABLE T_MDS_WRTFF ADD (FSTARTDATE DATETIME);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_WRTFF' AND KSQL_COL_NAME ='FENDDATE')
 ALTER TABLE T_MDS_WRTFF ADD (FENDDATE DATETIME);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_WRTFF' AND KSQL_COL_NAME ='FSUMMIN')
 ALTER TABLE T_MDS_WRTFF ADD (FSUMMIN DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_WRTFFLOGENTRY') 
	CREATE TABLE T_MDS_WRTFFLOGENTRY
	(
	  fid          BIGINT DEFAULT 0 NOT NULL,
	  fentryid     BIGINT DEFAULT 0 NOT NULL,
	  fseq         BIGINT DEFAULT 0 NOT NULL,
	  fstepseq     NVARCHAR(50) DEFAULT ' ' NOT NULL,
	  fstepname    NVARCHAR(50) DEFAULT ' ' NOT NULL,
	  fprocessdata BIGINT DEFAULT 0 NOT NULL,
	  foperatmin   DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  fresult      NVARCHAR(200) DEFAULT ' ' NOT NULL,
	  fdetailmsg   NVARCHAR(255) DEFAULT ' ' NOT NULL
	);
	
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_WRTFFENTRY') 
	CREATE TABLE T_MDS_WRTFFENTRY
	(
	  fid          BIGINT DEFAULT 0 NOT NULL,
	  fentryid     BIGINT DEFAULT 0 NOT NULL,
	  fseq         BIGINT DEFAULT 0 NOT NULL,
	  fperiod      NVARCHAR(50) DEFAULT ' ' NOT NULL,
	  fmod         DECIMAL(23,10) DEFAULT 0 NOT NULL
	);
	
	IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_RPLANCAL' AND KSQL_COL_NAME ='FDATETYPE') 
 ALTER TABLE T_MDS_RPLANCAL ADD (FDATETYPE NVARCHAR(30) DEFAULT ' ' NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_VRDS' AND KSQL_COL_NAME ='FPERIODS')
 ALTER TABLE T_MDS_VRDS ADD (FPERIODS BIGINT DEFAULT 0 NOT NULL);
 
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATADTLENT' AND KSQL_COL_NAME ='FREMARK')
 ALTER TABLE T_MDS_FCDATADTLENT ADD (FREMARK NVARCHAR(300) DEFAULT ' ' NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATADTLENT' AND KSQL_COL_NAME ='FBASEUNITID')
 ALTER TABLE T_MDS_FCDATADTLENT ADD (FBASEUNITID BIGINT DEFAULT 0 NOT NULL);
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_FCDATATS') 
 CREATE TABLE T_MDS_FCDATATS (
      FID                     BIGINT DEFAULT 0 NOT NULL,
      FBILLNO                 NVARCHAR(30) DEFAULT ' ' NOT NULL,
      FBILLSTATUS             NVARCHAR(50) DEFAULT ' ' NOT NULL,
      FCREATORID              BIGINT DEFAULT 0 NOT NULL,
      FMODIFIERID             BIGINT DEFAULT 0 NOT NULL,
      FENABLESTATUS           NVARCHAR(50) DEFAULT ' ' NOT NULL,
      FCREATETIME             DATETIME,
      FMODIFYTIME             DATETIME,
      FAUDITORID              BIGINT DEFAULT 0 NOT NULL,
      FAUDITDATE              DATETIME,
	  FORGID                  BIGINT DEFAULT 0 NOT NULL,
	  FFCVRNNUM               BIGINT DEFAULT 0 NOT NULL
 );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DATEENTRY') 
 CREATE TABLE T_MDS_DATEENTRY (
      FID                     BIGINT DEFAULT 0 NOT NULL,
      FENTRYID                BIGINT DEFAULT 0 NOT NULL,
      FSEQ                    BIGINT DEFAULT 0 NOT NULL,
      FFIELDKEY               NVARCHAR(50) DEFAULT ' ' NOT NULL,
      FDELIVERYCOLUMN         CHAR(1) DEFAULT '1' NOT NULL,
      FTARGETDATE             DATETIME
 );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_FCDATATSENTRY') 
 CREATE TABLE T_MDS_FCDATATSENTRY (
	  FID                     BIGINT DEFAULT 0 NOT NULL,
	  FENTRYID                BIGINT DEFAULT 0 NOT NULL,
	  FSEQ                    BIGINT DEFAULT 0 NOT NULL,
	  FMATERIALID             BIGINT DEFAULT 0 NOT NULL,
	  FBASEUNITID             BIGINT DEFAULT 0 NOT NULL,
	  FPRODORG                BIGINT DEFAULT 0 NOT NULL,
	  FPLANGP                 BIGINT DEFAULT 0 NOT NULL,
	  FREMARK                 NVARCHAR(300) DEFAULT ' ' NOT NULL,
	  FQTY1                   DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY2                   DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY3                   DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY4                   DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY5                   DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY6                   DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY7                   DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY8                   DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY9                   DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY10                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY11                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY12                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY13                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY14                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY15                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY16                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY17                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY18                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY19                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY20                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY21                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY22                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY23                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY24                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY25                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY26                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY27                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY28                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY29                  DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FQTY30                  DECIMAL(23,10) DEFAULT 0 NOT NULL
 );

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SYNCPLANLOG') 
 CREATE TABLE T_MDS_SYNCPLANLOG (
      FID                     BIGINT DEFAULT 0 NOT NULL,
      FNUMBER                 NVARCHAR(30) 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,
	  FORGID                  BIGINT DEFAULT 0 NOT NULL,
	  FDIRECTION              NVARCHAR(50) DEFAULT ' ' NOT NULL,
	  fSYNCRESULT             NVARCHAR(50) DEFAULT ' ' NOT NULL,
	  FERRORINFO              NVARCHAR(1000) DEFAULT ' ' NOT NULL,
	  FVERSIONID              BIGINT DEFAULT 0 NOT NULL
 );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SYNCPLANLOG_L') 
 CREATE TABLE T_MDS_SYNCPLANLOG_L (
	  FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
	  FID BIGINT DEFAULT 0 NOT NULL,
	  FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
	  FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY31') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY31 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY32') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY32 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY33') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY33 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY34') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY34 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY35') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY35 DECIMAL(23,10) DEFAULT 0 NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY36') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY36 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY37') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY37 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY38') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY38 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY39') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY39 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY40') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY40 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY41') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY41 DECIMAL(23,10) DEFAULT 0 NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY42') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY42 DECIMAL(23,10) DEFAULT 0 NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY43') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY43 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY44') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY44 DECIMAL(23,10) DEFAULT 0 NOT NULL); 
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY45') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY45 DECIMAL(23,10) DEFAULT 0 NOT NULL);  
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY46') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY46 DECIMAL(23,10) DEFAULT 0 NOT NULL);  
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY47') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY47 DECIMAL(23,10) DEFAULT 0 NOT NULL); 
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY48') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY48 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY49') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY49 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY50') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY50 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY51') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY51 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY52') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY52 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY53') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY53 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY54') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY54 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY55') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY55 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY56') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY56 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY57') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY57 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY58') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY58 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY59') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY59 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY60') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY60 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY61') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY61 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY62') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY62 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY63') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY63 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY64') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY64 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY65') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY65 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY66') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY66 DECIMAL(23,10) DEFAULT 0 NOT NULL); 
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY67') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY67 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY68') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY68 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY69') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY69 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY70') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY70 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY71') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY71 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY72') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY72 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY73') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY73 DECIMAL(23,10) DEFAULT 0 NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY74') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY74 DECIMAL(23,10) DEFAULT 0 NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY75') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY75 DECIMAL(23,10) DEFAULT 0 NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY76') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY76 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY77') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY77 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY78') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY78 DECIMAL(23,10) DEFAULT 0 NOT NULL); 
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY79') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY79 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY80') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY80 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY81') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY81 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY82') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY82 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY83') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY83 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY84') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY84 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY85') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY85 DECIMAL(23,10) DEFAULT 0 NOT NULL);
  
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY86') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY86 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY87') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY87 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY88') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY88 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY89') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY89 DECIMAL(23,10) DEFAULT 0 NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY90') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY90 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY91') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY91 DECIMAL(23,10) DEFAULT 0 NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY92') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY92 DECIMAL(23,10) DEFAULT 0 NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY93') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY93 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY94') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY94 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY95') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY95 DECIMAL(23,10) DEFAULT 0 NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY96') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY96 DECIMAL(23,10) DEFAULT 0 NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY97') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY97 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY98') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY98 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY99') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY99 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY100') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY100 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY101') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY101 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY102') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY102 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY103') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY103 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY104') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY104 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY105') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY105 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY106') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY106 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY107') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY107 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY108') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY108 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY109') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY109 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY110') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY110 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY111') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY111 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY112') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY112 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY113') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY113 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY114') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY114 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY115') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY115 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY116') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY116 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY117') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY117 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY118') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY118 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY119') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY119 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY120') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY120 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY121') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY121 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY122') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY122 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY123') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY123 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY124') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY124 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY125') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY125 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY126') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY126 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY127') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY127 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY128') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY128 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY129') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY129 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY130') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY130 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY131') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY131 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY132') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY132 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY133') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY133 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY134') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY134 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY135') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY135 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY136') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY136 DECIMAL(23,10) DEFAULT 0 NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY137') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY137 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY138') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY138 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY139') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY139 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY140') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY140 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY141') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY141 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY142') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY142 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY143') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY143 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY144') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY144 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY145') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY145 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY146') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY146 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY147') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY147 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY148') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY148 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY149') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY149 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FQTY150') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FQTY150 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FRECEIVE1') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FRECEIVE1 DECIMAL(23,10) DEFAULT 0 NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FRECEIVE2') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FRECEIVE2 DECIMAL(23,10) DEFAULT 0 NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FRECEIVE3') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FRECEIVE3 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FRECEIVE4') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FRECEIVE4 DECIMAL(23,10) DEFAULT 0 NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FRECEIVE5') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FRECEIVE5 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FRECEIVE6') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FRECEIVE6 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FRECEIVE7') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FRECEIVE7 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FRECEIVE8') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FRECEIVE8 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FRECEIVE9') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FRECEIVE9 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATSENTRY' AND KSQL_COL_NAME ='FRECEIVE10') 
 ALTER TABLE T_MDS_FCDATATSENTRY ADD (FRECEIVE10 DECIMAL(23,10) DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SITEBASEDATA')  
CREATE TABLE T_MDS_SITEBASEDATA
(
	  FID                BIGINT DEFAULT 0 NOT NULL,
	  FNUMBER            NVARCHAR(30) 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,
	  FSTOCKSETUP        NVARCHAR(50) DEFAULT ' ' NOT NULL,
	  FTRANSACTPRODUCTID BIGINT DEFAULT 0 NOT NULL,
	  FDPSVERSIONID      BIGINT DEFAULT 0 NOT NULL,
	  FSOPVERSIONID      BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SITEBASEDATA_L')
CREATE TABLE T_MDS_SITEBASEDATA_L
(
	  FPKID              VARCHAR(36) DEFAULT ' ' NOT NULL,
	  FID                BIGINT DEFAULT 0 NOT NULL,
	  FLOCALEID          VARCHAR(10) DEFAULT ' ' NOT NULL,
	  FNAME              VARCHAR(100) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SITEBASEENTRY')
CREATE TABLE T_MDS_SITEBASEENTRY
(
	  FID                BIGINT DEFAULT 0 NOT NULL,
	  FENTRYID           BIGINT DEFAULT 0 NOT NULL,
	  FSEQ               BIGINT DEFAULT 0 NOT NULL,
	  FSUPPTYPE          NVARCHAR(50) DEFAULT ' ' NOT NULL,
	  FISSELECTED        CHAR(1) DEFAULT '0' NOT NULL,
	  FSUPPLYTYPE        NVARCHAR(50) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SITEBASESET')
CREATE TABLE T_MDS_SITEBASESET
(
	  FID                BIGINT DEFAULT 0 NOT NULL,
	  FENTRYID           BIGINT DEFAULT 0 NOT NULL,
	  FSEQ               BIGINT DEFAULT 0 NOT NULL,
	  FSTOCKORGID        BIGINT DEFAULT 0 NOT NULL,
	  FSTOCKNUMBERID     BIGINT DEFAULT 0 NOT NULL,
	  FSTOCKINDEXID      BIGINT DEFAULT 0 NOT NULL,
	  FPRIORITY          BIGINT DEFAULT 0 NOT NULL,
	  FISWASTEWH         CHAR(1) DEFAULT '0' NOT NULL
);

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

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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SITESCHEMEDEF')
CREATE TABLE T_MDS_SITESCHEMEDEF
(
	  FID                BIGINT DEFAULT 0 NOT NULL,
	  FNUMBER            NVARCHAR(30) 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,
	  FSALORDERSTID      BIGINT DEFAULT 0 NOT NULL,
	  FSITEBASEDATAID    BIGINT DEFAULT 0 NOT NULL,
	  FISQUOTA           CHAR(1) DEFAULT '0' NOT NULL,
	  FDUMMYSITEID       BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_SITESCHEMEDEF' AND KSQL_COL_NAME ='FSETOFFSETTINGID') 
  ALTER TABLE T_MDS_SITESCHEMEDEF ADD (FSETOFFSETTINGID BIGINT DEFAULT 0 NOT NULL); 

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSFNRESULT')  
CREATE TABLE T_MDS_DPSFNRESULT
(
	  FID            BIGINT DEFAULT 0 NOT NULL,
	  FNUMBER        NVARCHAR(30) 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,
	  FORDERSEQ      BIGINT DEFAULT 0 NOT NULL,
	  FMATERIELID    BIGINT DEFAULT 0 NOT NULL,
	  FBASEUNITID    BIGINT DEFAULT 0 NOT NULL,
	  FMATCHQTY      DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FORGSITEID     BIGINT DEFAULT 0 NOT NULL,
	  FFNQTY         DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FFNTIME        DATETIME,
	  FDPSSCHEMEID   BIGINT DEFAULT 0 NOT NULL,
	  FFNDEFINEID    BIGINT DEFAULT 0 NOT NULL,
	  FMATEQTY    DECIMAL(23,10) DEFAULT 0 NOT NULL
);

EXEC p_AlterColumn 'T_MDS_DPSFNRESULT', 'FORGSITEID', 'BIGINT', 'NOT NULL', '1111', '0';
EXEC p_AlterColumn 'T_MDS_DPSFNRESULT', 'FDPSSCHEMEID', 'BIGINT', 'NOT NULL', '1111', '0';
EXEC p_AlterColumn 'T_MDS_DPSFNRESULT', 'FFNDEFINEID', 'BIGINT', 'NOT NULL', '1111', '0';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSFNRESULT_L')
CREATE TABLE T_MDS_DPSFNRESULT_L
(
	  FPKID              VARCHAR(36) DEFAULT ' ' NOT NULL,
	  FID                BIGINT DEFAULT 0 NOT NULL,
	  FLOCALEID          VARCHAR(10) DEFAULT ' ' NOT NULL,
	  FNAME              VARCHAR(100) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SITESCHEMEDEF_L')
CREATE TABLE T_MDS_SITESCHEMEDEF_L
(
	  FPKID              VARCHAR(36) DEFAULT ' ' NOT NULL,
	  FID                BIGINT DEFAULT 0 NOT NULL,
	  FLOCALEID          VARCHAR(10) DEFAULT ' ' NOT NULL,
	  FNAME              VARCHAR(100) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSPLANEXEC')
CREATE TABLE T_MDS_DPSPLANEXEC
(
	  FID                BIGINT DEFAULT 0 NOT NULL,
	  FNUMBER            NVARCHAR(30) 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,
	  FCREATEORGID       BIGINT DEFAULT 0 NOT NULL,
	  FORGID             BIGINT DEFAULT 0 NOT NULL,
	  FCTRLSTRATEGY      NVARCHAR(50) DEFAULT ' ' NOT NULL,
	  FDAYSOFWEEK        NVARCHAR(50) DEFAULT ' ' NOT NULL,
	  FDAYSOFMON         NVARCHAR(100) DEFAULT ' ' NOT NULL,
	  FRUNNINGTYPE       NVARCHAR(50) DEFAULT ' ' NOT NULL,
	  FREPEATTYPE        NVARCHAR(50) DEFAULT ' ' NOT NULL,
	  FLOSEDATE          DATETIME,
	  FPREDTIME          BIGINT DEFAULT 0 NOT NULL,
	  FREPEAT            CHAR(1) DEFAULT '0' NOT NULL,
	  FJOBID             NVARCHAR(50) DEFAULT ' ' NOT NULL,
	  FPLANID            NVARCHAR(50) DEFAULT ' ' NOT NULL,
	  FCALCULATEPRO      BIGINT DEFAULT 0 NOT NULL,
	  FSTARTDATE         DATETIME,
	  FENDDATE           DATETIME,
	  FSUMMIN            BIGINT DEFAULT 0 NOT NULL,
	  FUSEORG            BIGINT DEFAULT 0 NOT NULL,
	  FDPSSITESCHEMEID   BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSPLANEXEC_L')
CREATE TABLE T_MDS_DPSPLANEXEC_L
(
	  FPKID              VARCHAR(36) DEFAULT ' ' NOT NULL,
	  FID                BIGINT DEFAULT 0 NOT NULL,
	  FLOCALEID          VARCHAR(10) DEFAULT ' ' NOT NULL,
	  FNAME              VARCHAR(100) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSALLOCRESULT')
create table T_MDS_DPSALLOCRESULT
(
	  FID                BIGINT DEFAULT 0 NOT NULL,
	  FNUMBER            NVARCHAR(30) 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,
	  FBILLTYPEFIELD     BIGINT DEFAULT 0 NOT NULL,
	  FORGID             BIGINT DEFAULT 0 NOT NULL,
	  FORDERSEQ          BIGINT DEFAULT 0 NOT NULL,
	  FMATERIALID        BIGINT DEFAULT 0 NOT NULL,
	  FBASEUNITID        BIGINT DEFAULT 0 NOT NULL,
	  FQTY               DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  FACCOUTSTOCKQTY    DECIMAL(23,10) DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSALLOCRESULT_L')
create table T_MDS_DPSALLOCRESULT_L
(
	  FPKID              VARCHAR(36) DEFAULT ' ' NOT NULL,
	  FID                BIGINT DEFAULT 0 NOT NULL,
	  FLOCALEID          VARCHAR(10) DEFAULT ' ' NOT NULL,
	  FNAME              VARCHAR(100) DEFAULT ' ' NOT NULL
);


EXEC p_AlterColumn 'T_MDS_FCDATADTLENT', 'FPLANGP', 'BIGINT', 'NOT NULL', '1111', '0';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATATS' AND KSQL_COL_NAME ='FINVALDATE') 
 ALTER TABLE T_MDS_FCDATATS ADD (FINVALDATE DATETIME);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_DPSALLOCRESULT' AND KSQL_COL_NAME ='FRESIDUEQTY') 
 ALTER TABLE T_MDS_DPSALLOCRESULT ADD (FRESIDUEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_DPSALLOCRESULT' AND KSQL_COL_NAME ='FORGSITEID') 
 ALTER TABLE T_MDS_DPSALLOCRESULT ADD (FORGSITEID BIGINT DEFAULT 0 NOT NULL); 

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_DPSPLANEXEC' AND KSQL_COL_NAME ='FSTARTDATE') 
 ALTER TABLE T_MDS_DPSPLANEXEC ADD (FSTARTDATE DATETIME);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_DPSPLANEXEC' AND KSQL_COL_NAME ='FENDDATE') 
 ALTER TABLE T_MDS_DPSPLANEXEC ADD (FENDDATE DATETIME);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_DPSPLANEXEC' AND KSQL_COL_NAME ='FSUMMIN') 
 ALTER TABLE T_MDS_DPSPLANEXEC ADD (FSUMMIN DECIMAL(23,10) DEFAULT 0 NOT NULL);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_DPSPLANEXEC' AND KSQL_COL_NAME ='FPROCESSCOUNT') 
 ALTER TABLE T_MDS_DPSPLANEXEC ADD (FPROCESSCOUNT BIGINT DEFAULT 0 NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSALLOCENTRY')
create table T_MDS_DPSALLOCENTRY
(
	  FID                BIGINT DEFAULT 0 NOT NULL,
	  fentryid           BIGINT DEFAULT 0 NOT NULL,
	  fseq               BIGINT DEFAULT 0 NOT NULL,
	  fsupplytype        NVARCHAR(50) DEFAULT ' ' NOT NULL,
	  fsupplytime        DATETIME,
	  fmatchseq          BIGINT DEFAULT 0 NOT NULL,
	  fmatchqty          DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  fbillflag          NVARCHAR(50) DEFAULT ' ' NOT NULL
);

EXEC p_AlterColumn 'T_MDS_PLANEXEC', 'FDAYSOFMON', 'NVARCHAR(100)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_DPSTREELOGEENTRY')
CREATE TABLE T_MDS_DPSTREELOGEENTRY
(
	  FID                       BIGINT DEFAULT 0 NOT NULL,
	  fentryid                  BIGINT DEFAULT 0 NOT NULL,
	  fseq                      BIGINT DEFAULT 0 NOT NULL,
	  fparententryid            BIGINT DEFAULT 0 NOT NULL,
	  fentrytreeseq             BIGINT DEFAULT 0 NOT NULL,
	  fentrytreename            NVARCHAR(300) DEFAULT ' ' NOT NULL,
	  fentrytreeoperatmin       DECIMAL(23,10) DEFAULT 0 NOT NULL,
	  fentrytreeresult          NVARCHAR(50) DEFAULT ' ' NOT NULL,
	  fentrytreedetailmsg       NVARCHAR(1000) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SITETRANPRODUCT')
create table T_MDS_SITETRANPRODUCT
(
      FPKID       BIGINT DEFAULT 0 NOT NULL,
      FID         BIGINT DEFAULT 0 NOT NULL,
      FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_SITEDPSVERSION')
create table T_MDS_SITEDPSVERSION
(
      FPKID       BIGINT DEFAULT 0 NOT NULL,
      FID         BIGINT DEFAULT 0 NOT NULL,
      FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_MATERIALGPENTRY')
create table T_MDS_MATERIALGPENTRY
(
  fpkid       BIGINT DEFAULT 0 NOT NULL,
  fid         BIGINT DEFAULT 0 NOT NULL,
  fbasedataid BIGINT DEFAULT 0 NOT NULL
);

--T_MDS_DPSTREELOGEENTRY修改长度
EXEC p_AlterColumn 'T_MDS_DPSTREELOGEENTRY', 'FENTRYTREENAME', 'NVARCHAR(500)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MDS_FCDAENT_MATERIAL') CREATE INDEX IDX_MDS_FCDAENT_MATERIAL ON T_MDS_FCDATADTLENT (FMATERIALID);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_DPSALLOCRESULT' AND KSQL_COL_NAME ='FSITESCHEMEDEF') 
 ALTER TABLE T_MDS_DPSALLOCRESULT ADD (FSITESCHEMEDEF BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_DPSALLOCRESULT' AND KSQL_COL_NAME ='FENDDATE') 
 ALTER TABLE T_MDS_DPSALLOCRESULT ADD (FENDDATE DATETIME );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_DPSALLOCRESULT' AND KSQL_COL_NAME ='FMATEQTY') 
 ALTER TABLE T_MDS_DPSALLOCRESULT ADD (FMATEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL);


EXEC p_AlterColumn 'T_MDS_DPSTREELOGEENTRY', 'FENTRYTREESEQ', 'BIGINT', 'NOT NULL', '1111', '0';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_DPSFNRESULT' AND KSQL_COL_NAME ='FMATEQTY')
  ALTER TABLE T_MDS_DPSFNRESULT ADD (FMATEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL);

  IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_DPSFNRESULT' AND KSQL_COL_NAME ='FISQTYSETOFF')
ALTER TABLE T_MDS_DPSFNRESULT ADD (FISQTYSETOFF CHAR(1) DEFAULT ' ' NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_FLOWLOG')
CREATE TABLE T_MSPLAN_FLOWLOG
(
	  FID                BIGINT DEFAULT 0 NOT NULL,
	  FSTARTTIME         DATETIME,
	  FENDTIME           DATETIME,
	  FRUNSTATUS         NVARCHAR2(50) DEFAULT ' ' NOT NULL,
	  FINSTOCKSTATUS     NVARCHAR2(50) DEFAULT ' ' NOT NULL,
	  FREQSTATUS         NVARCHAR2(50) DEFAULT ' ' NOT NULL,
	  FMFTPROORDERSTATUS NVARCHAR2(50) DEFAULT ' ' NOT NULL,
	  FINSTOCKINFO       NVARCHAR2(500) DEFAULT ' ' NOT NULL,
	  FREQINFO           NVARCHAR2(500) DEFAULT ' ' NOT NULL,
	  FMFTPROORDERINFO   NVARCHAR2(500) DEFAULT ' ' NOT NULL,
	  FPROCESSTYPE       NVARCHAR2(50) DEFAULT ' ' NOT NULL,
	  FSOURCENUMBER      NVARCHAR2(50) DEFAULT ' ' NOT NULL,
	  FTARGETINSTOCKNUM  NVARCHAR2(50) DEFAULT ' ' NOT NULL,
	  FTARGETREQNUM      NVARCHAR2(50) DEFAULT ' ' NOT NULL,
	  FTARGETMFTORDERNUM NVARCHAR2(50) DEFAULT ' ' NOT NULL,
	  FBILLNO            NVARCHAR2(30) DEFAULT ' ' NOT NULL,
	  FUUID              NVARCHAR2(50) DEFAULT ' ' NOT NULL
)




 
 

