/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\MDS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MDS_PDCC') 
 CREATE TABLE T_MDS_PDCC (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FPREDVERSION BIGINT DEFAULT 0 NOT NULL,
FSOURCETYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSOURCENAME BIGINT DEFAULT 0 NOT NULL,
FDTYPE BIGINT DEFAULT 0 NOT NULL,
FCHANGEWAY NVARCHAR(30) DEFAULT ' ' NOT NULL,
FAMOUNTTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSTART DATETIME,
FEND DATETIME,
FDEDUCT_H BIGINT DEFAULT 0 NOT NULL,
FDEDUCT_T BIGINT DEFAULT 0 NOT NULL,
FMOD DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEDUCT CHAR(1) DEFAULT ' ' NOT NULL,
FCALSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FREPEAT CHAR(1) DEFAULT ' ' NOT NULL,
FJOBID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPLANID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDAYSOFWEEK NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDAYSOFMON NVARCHAR(100) DEFAULT ' ' NOT NULL,
FRUNNINGTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FREPEATTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FLOSEDATE DATETIME,
FPREDTIME BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCCORLENTRY' AND KSQL_COL_NAME ='FVRNTYPE') 
 ALTER TABLE T_MDS_FCCORLENTRY ADD (FVRNTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATAENTRY' AND KSQL_COL_NAME ='FPLANGPP') 
 ALTER TABLE T_MDS_FCDATAENTRY ADD (FPLANGPP NVARCHAR(50) DEFAULT ' ' NOT NULL );
 EXEC p_AlterColumn 'T_MDS_FCDATADTLENT', 'FQTYSRC', 'NVARCHAR(50)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MDS_FCDATADTLENT' AND KSQL_COL_NAME ='FPLANGP') 
 ALTER TABLE T_MDS_FCDATADTLENT ADD (FPLANGP NVARCHAR(50) DEFAULT ' ' NOT NULL );

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