/**Begin D:\PDM\PDM_UPGRADE\pdm1\FCS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FCS_DATASNAP' AND KSQL_COL_NAME IN ('FCOLUMNS'))
 ALTER TABLE T_FCS_DATASNAP ADD (FCOLUMNS NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FCS_DATASNAP' AND KSQL_COL_NAME IN ('FCOLUMNS_TAG'))
 ALTER TABLE T_FCS_DATASNAP ADD (FCOLUMNS_TAG NCLOB DEFAULT ' ' );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FCS_SNAPSCHEME')
CREATE TABLE T_FCS_SNAPSCHEME (
                                  FID BIGINT DEFAULT 0 NOT NULL,
                                  FNUMBER NVARCHAR(80),
                                  FNAME NVARCHAR(255),
                                  FSTATUS NVARCHAR(30),
                                  FCREATORID BIGINT,
                                  FDISABLEDATE DATETIME,
                                  FDISABLERID BIGINT,
                                  FENABLERID BIGINT,
                                  FENABLEDATE DATETIME,
                                  FORGID BIGINT,
                                  FMASTERID BIGINT,
                                  FENABLE NVARCHAR(30),
                                  FCREATETIME DATETIME,
                                  FMODIFIERID BIGINT,
                                  FMODIFYTIME DATETIME,
                                  FREPORTFORMID NVARCHAR(36),
                                  FQUERYSCHEMEID NVARCHAR(36),
                                  FPLUGIN NVARCHAR(80),
                                  FCOMMENT NVARCHAR(255)
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FCS_SCHEME_PARAMS')
CREATE TABLE T_FCS_SCHEME_PARAMS (
                                     FID BIGINT,
                                     FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                     FSEQ BIGINT,
                                     FPARAMNAME NVARCHAR(50),
                                     FPARAMTYPE NVARCHAR(30),
                                     FPARAMVALUE NVARCHAR(255),
                                     FBASEDATAINFO NVARCHAR(255)
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FCS_EXPORTSCHEME')
CREATE TABLE T_FCS_EXPORTSCHEME (
                                    FID BIGINT DEFAULT 0 NOT NULL,
                                    FDISABLEDATE DATETIME,
                                    FDISABLERID BIGINT DEFAULT 0 NOT NULL,
                                    FENABLERID BIGINT DEFAULT 0 NOT NULL,
                                    FENABLEDATE DATETIME,
                                    FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                    FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                    FORGID BIGINT DEFAULT 0 NOT NULL,
                                    FSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                    FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                    FENABLE NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                    FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                    FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                    FCREATETIME DATETIME,
                                    FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                    FMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FCS_SNAPSCHEME_COMB')
CREATE TABLE T_FCS_SNAPSCHEME_COMB (
                                       FID BIGINT,
                                       FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                       FSEQ BIGINT,
                                       FSNAPSCHEMEID BIGINT,
                                       FSNAPSCHEMENUMBER NVARCHAR(50),
                                       FREPORTFORMID NVARCHAR(36),
                                       FQUERYSCHEMEID NVARCHAR(36),
                                       FCMNT NVARCHAR(255),
                                       FSCHEMESTATUS NVARCHAR(30),
                                       FEXPORTNAME NVARCHAR(512)
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FCS_EXPORTSCHEME_L')
CREATE TABLE T_FCS_EXPORTSCHEME_L (
                                      FPKID NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                      FID BIGINT DEFAULT 0 NOT NULL,
                                      FLOCALEID NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                      FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                      FCOMMENT NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FCS_SNAPSCHEME_L')
CREATE TABLE T_FCS_SNAPSCHEME_L (
                                    FPKID NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                    FID BIGINT DEFAULT 0 NOT NULL,
                                    FLOCALEID NVARCHAR(30),
                                    FNAME NVARCHAR(255),
                                    FCOMMENT NVARCHAR(255)
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FCS_SNAPSCHEME_COMB_L')
CREATE TABLE T_FCS_SNAPSCHEME_COMB_L (
                                         FPKID NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                         FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                         FLOCALEID NVARCHAR(30),
                                         FCMNT NVARCHAR(255)
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FCS_SNAPLOG')
CREATE TABLE T_FCS_SNAPLOG (
                               FID BIGINT DEFAULT 0 NOT NULL,
                               FBILLNO NVARCHAR(80) 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,
                               FTRACEID NVARCHAR(80) DEFAULT ' ' NOT NULL,
                               FCOSTTIME INT DEFAULT 0 NOT NULL,
                               FEXCEPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
                               FEXCEPTION_TAG NCLOB DEFAULT ' ',
                               FREPORTID NVARCHAR(80) DEFAULT ' ' NOT NULL,
                               FSNAPSCHEMEID BIGINT DEFAULT 0 NOT NULL,
                               FTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
                               FDESC NVARCHAR(255) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FCS_SNAPSCHEME_PARAMS')
CREATE TABLE T_FCS_SNAPSCHEME_PARAMS (
                                         FID BIGINT,
                                         FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                         FSEQ BIGINT,
                                         FPARAMNAME NVARCHAR(50),
                                         FPARAMTYPE NVARCHAR(30),
                                         FPARAMVALUE NVARCHAR(255),
                                         FBASEDATAINFO NVARCHAR(255)
);


--- drop TABLE --------- 请认真检查该脚本 -------------------
IF EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FCS_SCHEME_PARAMS')
DROP TABLE T_FCS_SCHEME_PARAMS;

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FCS_SNAPLOG_H')
 CREATE TABLE T_FCS_SNAPLOG_H (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) 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,
FTRACEID NVARCHAR(80) DEFAULT ' ' NOT NULL,
FCOSTTIME INT DEFAULT 0 NOT NULL,
FEXCEPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FEXCEPTION_TAG NCLOB DEFAULT ' ',
FREPORTID NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSNAPSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDESC NVARCHAR(255) DEFAULT ' ' NOT NULL
);

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME', 'FNUMBER', 'NVARCHAR(80)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME', 'FNAME', 'NVARCHAR(255)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME', 'FSTATUS', 'NVARCHAR(30)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME', 'FCREATORID', 'BIGINT', 'NOT NULL', '0011', '0';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME', 'FDISABLERID', 'BIGINT', 'NOT NULL', '0011', '0';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME', 'FENABLERID', 'BIGINT', 'NOT NULL', '0011', '0';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME', 'FORGID', 'BIGINT', 'NOT NULL', '0011', '0';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME', 'FMASTERID', 'BIGINT', 'NOT NULL', '0011', '0';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME', 'FENABLE', 'NVARCHAR(30)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME', 'FMODIFIERID', 'BIGINT', 'NOT NULL', '0011', '0';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME', 'FREPORTFORMID', 'NVARCHAR(36)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME', 'FQUERYSCHEMEID', 'NVARCHAR(36)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME', 'FPLUGIN', 'NVARCHAR(80)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME', 'FCOMMENT', 'NVARCHAR(255)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_COMB', 'FID', 'BIGINT', 'NOT NULL', '0011', '0';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_COMB', 'FSEQ', 'BIGINT', 'NOT NULL', '0011', '0';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_COMB', 'FSNAPSCHEMEID', 'BIGINT', 'NOT NULL', '0011', '0';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_COMB', 'FSNAPSCHEMENUMBER', 'NVARCHAR(50)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_COMB', 'FREPORTFORMID', 'NVARCHAR(36)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_COMB', 'FQUERYSCHEMEID', 'NVARCHAR(36)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_COMB', 'FCMNT', 'NVARCHAR(255)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_COMB', 'FSCHEMESTATUS', 'NVARCHAR(30)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_COMB', 'FEXPORTNAME', 'NVARCHAR(512)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_PARAMS', 'FID', 'BIGINT', 'NOT NULL', '0011', '0';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_PARAMS', 'FSEQ', 'BIGINT', 'NOT NULL', '0011', '0';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_PARAMS', 'FPARAMNAME', 'NVARCHAR(50)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_PARAMS', 'FPARAMTYPE', 'NVARCHAR(30)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_PARAMS', 'FPARAMVALUE', 'NVARCHAR(255)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_PARAMS', 'FBASEDATAINFO', 'NVARCHAR(255)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_L', 'FLOCALEID', 'NVARCHAR(30)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_L', 'FNAME', 'NVARCHAR(255)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_L', 'FCOMMENT', 'NVARCHAR(255)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_COMB_L', 'FLOCALEID', 'NVARCHAR(30)', 'NOT NULL', '0011', ''' ''';

EXEC p_AlterColumn 'T_FCS_SNAPSCHEME_COMB_L', 'FCMNT', 'NVARCHAR(255)', 'NOT NULL', '0011', ''' ''';

/**End D:\PDM\PDM_UPGRADE\pdm1\FCS_table.sql **/
