IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_DROPPLANORDERLOG') 
 CREATE TABLE T_MRP_DROPPLANORDERLOG (
FID BIGINT DEFAULT 0 NOT NULL,
Fbillno NVARCHAR(50) DEFAULT ' ' NOT NULL,
fplanorderid BIGINT DEFAULT 0 NOT NULL,
ftargetorderid BIGINT DEFAULT 0 NOT NULL,
fdropstatus NVARCHAR(30) DEFAULT ' ' NOT NULL,
fdropqty DECIMAL(23,10) DEFAULT 0 NOT NULL,
foperationdate DATETIME,
foperator BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_DROPCONFENTRY') 
 CREATE TABLE T_MSPLAN_DROPCONFENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FORDERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FTARGETBILL NVARCHAR(50) DEFAULT ' ' NOT NULL,
FISDEFAULT NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MSPLAN_DROPCONFIGURE') 
 CREATE TABLE T_MSPLAN_DROPCONFIGURE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) 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,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FORGID 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,
FALGOREGISTER BIGINT DEFAULT 0 NOT NULL
);


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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_DROPPLANORDERLOG' AND KSQL_COL_NAME ='FSOUREORDER') 
 ALTER TABLE T_MRP_DROPPLANORDERLOG ADD (FSOUREORDER NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_DROPPLANORDERLOG' AND KSQL_COL_NAME ='FTARGETORDER') 
 ALTER TABLE T_MRP_DROPPLANORDERLOG ADD (FTARGETORDER NVARCHAR(50) DEFAULT ' ' NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_ALGOREGISTER' AND KSQL_COL_NAME ='FALGOTYPE') 
 ALTER TABLE T_MRP_ALGOREGISTER ADD (FALGOTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_ALGOREGISTER' AND KSQL_COL_NAME ='FREMARK') 
 ALTER TABLE T_MRP_ALGOREGISTER ADD (FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_MRP_ALGOREGISTER_L' AND KSQL_COL_NAME ='FREMARK') 
 ALTER TABLE T_MRP_ALGOREGISTER_L ADD (FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL );
 