/**Begin D:\PDM_UPGRADE\PDM1\FPM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_REPORT_RULE')
 CREATE TABLE T_FPM_REPORT_RULE (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(50) 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,
FSYSTEMID BIGINT DEFAULT 0 NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FCHECKTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FTOLERANCE DECIMAL(23,4) DEFAULT 0 NOT NULL,
FCHECKEFFECT VARCHAR(50) DEFAULT ' ' NOT NULL,
FTEMPLATECHECK CHAR(1) DEFAULT '0' NOT NULL,
FTEMPLATEID BIGINT DEFAULT 0 NOT NULL,
FUSESTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
FREMARK VARCHAR(255) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FENABLERID BIGINT DEFAULT 0 NOT NULL,
FENABLEDATE DATETIME,
FDISABLEDATE DATETIME,
FSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
FENABLE VARCHAR(50) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCHECKDIMENSION VARCHAR(512) DEFAULT ' ' NOT NULL,
FVALUEFORMULA VARCHAR(512) DEFAULT ' ' NOT NULL,
FCHECKEDDIMENSION VARCHAR(512) DEFAULT ' ' NOT NULL,
FVALUEDFORMULA VARCHAR(512) DEFAULT ' ' NOT NULL,
FDURINGDEVIATION BIGINT DEFAULT 0 NOT NULL,
FDATAVERIFYREL VARCHAR(50) DEFAULT ' ' NOT NULL,
FEXPRESSION VARCHAR(255) DEFAULT ' ' NOT NULL,
FCHECKEDREPORTTYPEID BIGINT DEFAULT 0 NOT NULL,
FCHECKREPORTTYPEID BIGINT DEFAULT 0 NOT NULL,
FCHECKDIMENSIONVALUE VARCHAR(255) DEFAULT ' ' NOT NULL,
FCHECKDIMENSIONVALUE_TAG NCLOB DEFAULT ' ',
FCHECKEDDIMENSIONVALUE VARCHAR(255) DEFAULT ' ' NOT NULL,
FCHECKEDDIMENSIONVALUE_TAG NCLOB DEFAULT ' ',
FVALUEFORMULAVALUE VARCHAR(255) DEFAULT ' ' NOT NULL,
FVALUEFORMULAVALUE_TAG NCLOB DEFAULT ' ',
FVALUEDFORMULAVALUE VARCHAR(255) DEFAULT ' ' NOT NULL,
FVALUEDFORMULAVALUE_TAG NCLOB DEFAULT ' ',
FEXPRESSION_TAG NCLOB DEFAULT ' '
);


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_RULE_DIMENSION')
 CREATE TABLE T_FPM_RULE_DIMENSION (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FDIMENSION VARCHAR(50) DEFAULT ' ' NOT NULL,
FMEMBERSRANGE VARCHAR(50) DEFAULT ' ' NOT NULL
);


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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_REPORT_RULE_L')
 CREATE TABLE T_FPM_REPORT_RULE_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FCOMMENT VARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL
);


EXEC P_ALTERPK 'PK_T_FPM_REPORT_RULE', 'T_FPM_REPORT_RULE', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_NUMBER') CREATE INDEX IDX_NUMBER ON T_FPM_REPORT_RULE ( FNUMBER );


 EXEC P_ALTERPK 'PK_T_FPM_RULE_REPORT_TYPE', 'T_FPM_RULE_REPORT_TYPE', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_REPORT_TYPE_ENTRY') CREATE INDEX IDX_REPORT_TYPE_ENTRY ON T_FPM_RULE_REPORT_TYPE ( FID );


 EXEC P_ALTERPK 'PK_T_FPM_RULE_REPORT_TEM', 'T_FPM_RULE_REPORT_TEM', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TEM_ENTRY') CREATE INDEX IDX_TEM_ENTRY ON T_FPM_RULE_REPORT_TEM ( FID );


 EXEC P_ALTERPK 'PK_T_FPM_RULE_DIMENSION', 'T_FPM_RULE_DIMENSION', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_DIMENSION_ENTRY') CREATE INDEX IDX_DIMENSION_ENTRY ON T_FPM_RULE_DIMENSION ( FID );


 EXEC P_ALTERPK 'PK_T_FPM_RULE_MEMBERS', 'T_FPM_RULE_MEMBERS', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MEMBERS_ENTRY') CREATE INDEX IDX_MEMBERS_ENTRY ON T_FPM_RULE_MEMBERS ( FENTRYID );

 EXEC P_ALTERPK 'PK_T_FPM_REPORT_RULE_L', 'T_FPM_REPORT_RULE_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_REPORT_RULE_L_FID') CREATE INDEX IDX_REPORT_RULE_L_FID ON T_FPM_REPORT_RULE_L ( FID );


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



