/**Begin D:\software\PDM_UPGRADE\PDM1\FPM_table.sql **/
 EXEC p_AlterColumn 'T_FPM_TEMPLATE_DIMSET', 'FLEVEL', 'VARCHAR(50)', 'NOT NULL', '1111', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_TEMPLATE_DIMSET' AND KSQL_COL_NAME IN ('FMEMBERSCOPE')) 
 ALTER TABLE T_FPM_TEMPLATE_DIMSET ADD (FMEMBERSCOPE VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_TEMPLATE_DIMSET' AND KSQL_COL_NAME IN ('FFILTERDIM')) 
 ALTER TABLE T_FPM_TEMPLATE_DIMSET ADD (FFILTERDIM CHAR(1) DEFAULT '0' NOT NULL );
 EXEC p_AlterColumn 'T_FPM_TEMPLATEBAK_DIMSET', 'FLEVEL', 'VARCHAR(50)', 'NOT NULL', '1111', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_TEMPLATEBAK_DIMSET' AND KSQL_COL_NAME IN ('FMEMBERSCOPE')) 
 ALTER TABLE T_FPM_TEMPLATEBAK_DIMSET ADD (FMEMBERSCOPE VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_TEMPLATEBAK_DIMSET' AND KSQL_COL_NAME IN ('FFILTERDIM')) 
 ALTER TABLE T_FPM_TEMPLATEBAK_DIMSET ADD (FFILTERDIM CHAR(1) DEFAULT '0' NOT NULL );

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


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


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


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_INNERCANCELDETAIL') 
 CREATE TABLE T_FPM_INNERCANCELDETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMODIFIERFIELD BIGINT DEFAULT 0 NOT NULL,
FMODIFYDATEFIELD DATETIME,
FCANCELORGID BIGINT DEFAULT 0 NOT NULL,
FSUBJECTID BIGINT DEFAULT 0 NOT NULL,
FAVCANCELAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCANCELAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBALANCEAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREPORTDATAID BIGINT DEFAULT 0 NOT NULL,
FREPORTID BIGINT DEFAULT 0 NOT NULL,
FREPORTNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_INNERCANCELRECORD') 
 CREATE TABLE T_FPM_INNERCANCELRECORD (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO VARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
FCANCELRULEID BIGINT DEFAULT 0 NOT NULL,
FCANCELRULEENTRYNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FCANCELRULEENTRYID BIGINT DEFAULT 0 NOT NULL,
FSUMPLANRECORDID BIGINT DEFAULT 0 NOT NULL,
FSYSTEMID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FSUMMARYTYPE BIGINT DEFAULT 0 NOT NULL,
FORGREPORTTYPE BIGINT DEFAULT 0 NOT NULL,
FORGREPORTPERIOD BIGINT DEFAULT 0 NOT NULL,
FCURRENCYMAP VARCHAR(50) DEFAULT ' ' NOT NULL,
FEXRATETABLE BIGINT DEFAULT 0 NOT NULL,
FEXRATEDATE DATETIME,
FAMOUNTUNIT VARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FREMARK VARCHAR(205) DEFAULT ' ' NOT NULL,
FCANCELRULENAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FDIFFPROCESSMODETYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FSUMCANCELAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUMDIFFAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL
);



/**End D:\software\PDM_UPGRADE\PDM1\FPM_table.sql **/
