IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_BASECONFIG')
CREATE TABLE T_FMM_BASECONFIG
(
  FID BIGINT DEFAULT 0 NOT NULL,
  FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FNAME NVARCHAR(50) 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,
  FCONFIGOBJID NVARCHAR(255) DEFAULT 0 NOT NULL,
  FISSYS CHAR(1) DEFAULT '0' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_BASECONFIG_L')
CREATE TABLE T_FMM_BASECONFIG_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
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_CONFIGENTRY')
CREATE TABLE T_FMM_CONFIGENTRY
(
  FID BIGINT DEFAULT 0 NOT NULL,
  FENTRYID BIGINT DEFAULT 0 NOT NULL,
  FSEQ INT DEFAULT 0 NOT NULL,
  FFIELDNAME NVARCHAR(200) DEFAULT ' ' NOT NULL,
  FFIELDTAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
  FFIELDTYPE NVARCHAR(5) DEFAULT ' ' NOT NULL,
  FVISIBLE CHAR(1) DEFAULT '0' NOT NULL,
  FMUSTINPUTBLE CHAR(1) DEFAULT '0' NOT NULL,
  FISLOCK CHAR(1) DEFAULT '0' NOT NULL,
  FDEFAULTVALUE NVARCHAR(500) DEFAULT ' ' NOT NULL,
  FFIELDDESC NVARCHAR(500) DEFAULT ' ' NOT NULL, 
  FDEFAULTVALUETXT NVARCHAR(255) DEFAULT ' ' NOT NULL,
  FDEFAULTVALUETXT_TAG  NCLOB
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_SCENEPARAM')
CREATE TABLE T_FMM_SCENEPARAM
(
  FID BIGINT DEFAULT 0 NOT NULL,
  FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL, 
  FNAME NVARCHAR(50) 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,
  FDESC NVARCHAR(200) DEFAULT ' ' NOT NULL, 
  FISSYS CHAR(1) DEFAULT '0' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_SCENEPARAM_L')
CREATE TABLE T_FMM_SCENEPARAM_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
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_SCENEPARAMENTRY')
CREATE TABLE T_FMM_SCENEPARAMENTRY
(
  FID BIGINT DEFAULT 0 NOT NULL, 
  FENTRYID BIGINT DEFAULT 0 NOT NULL,
  FSEQ INT DEFAULT 0 NOT NULL, 
  FCONFIGTYPE NVARCHAR(5) DEFAULT ' ' NOT NULL, 
  FCONFIGOBJNAME NVARCHAR(200) DEFAULT ' ' NOT NULL,
  FCONFIGOBJSTR NVARCHAR(50) DEFAULT ' ' NOT NULL, 
  FFIELDNAME NVARCHAR(200) DEFAULT ' ' NOT NULL, 
  FFIELDTAG NVARCHAR(50) DEFAULT ' ' NOT NULL,
  FDEFAULTVALUE NVARCHAR(500) DEFAULT ' ' NOT NULL, 
  FDEFAULTVALUETXT NVARCHAR(255) DEFAULT ' ' NOT NULL, 
  FDEFAULTVALUETXT_TAG NCLOB, 
  FSCENEGROUPID BIGINT DEFAULT 0 NOT NULL, 
  FPARAMORGID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_SCENEGROUP')
CREATE TABLE T_FMM_SCENEGROUP
(
  FID BIGINT DEFAULT 0 NOT NULL,
  FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL, 
  FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
  FISDEFAULT CHAR(1) DEFAULT '0' NOT NULL,
  FCREATEDATE DATETIME , 
  FCREATERID BIGINT DEFAULT 0 NOT NULL,
  FSCENEPARAMID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_SCENEGROUP_L')
CREATE TABLE T_FMM_SCENEGROUP_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
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_PROCESSPLANLIB')
CREATE TABLE T_FMM_PROCESSPLANLIB
(
  FID BIGINT DEFAULT 0 NOT NULL, 
  FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
  FNAME NVARCHAR(50) 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,
  FDESC NVARCHAR(50) DEFAULT ' ' NOT NULL, 
  FISSYS CHAR(1) DEFAULT '0' NOT NULL, 
  FXML NVARCHAR(255) DEFAULT ' ' NOT NULL,
  FXML_TAG NCLOB, 
  FNODEDATA NVARCHAR(255) DEFAULT ' ' NOT NULL, 
  FNODEDATA_TAG NCLOB
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_PROCESSPLANLIB_L')
CREATE TABLE T_FMM_PROCESSPLANLIB_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
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_PROCESSLIBPARAM')
CREATE TABLE T_FMM_PROCESSLIBPARAM
(
  FPKID BIGINT DEFAULT 0 NOT NULL, 
  FENTRYID BIGINT DEFAULT 0 NOT NULL, 
  FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_PROCESSPLANLIBENTRY')
CREATE TABLE T_FMM_PROCESSPLANLIBENTRY
(
  FID BIGINT DEFAULT 0 NOT NULL, 
  FENTRYID BIGINT DEFAULT 0 NOT NULL,
  FSEQ INT DEFAULT 0 NOT NULL, 
  FPROCESSNODEID BIGINT DEFAULT 0 NOT NULL,
  FNODEID NVARCHAR(50) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_PROCESSPLANNODE')
CREATE TABLE T_FMM_PROCESSPLANNODE
(
  FID BIGINT DEFAULT 0 NOT NULL, 
  FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL, 
  FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
  FNODETYPE NVARCHAR(5) DEFAULT ' ' NOT NULL, 
  FTARGETOBJID NVARCHAR(255) DEFAULT 0 NOT NULL, 
  FSRCOBID NVARCHAR(255) DEFAULT 0 NOT NULL,
  FCREATERID BIGINT DEFAULT 0 NOT NULL,  
  FCREATEDATE DATETIME , 
  FMODIFIERID BIGINT DEFAULT 0 NOT NULL, 
  FMODIFYDATE DATETIME 
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_PROCESSPLANNODE_L')
CREATE TABLE T_FMM_PROCESSPLANNODE_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
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FMM_NODECONFIGOBJ')
CREATE TABLE T_FMM_NODECONFIGOBJ
(
  FPKID BIGINT DEFAULT 0 NOT NULL,
  FID BIGINT DEFAULT 0 NOT NULL, 
  FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);
