/**Begin D:\softwaresetup\PDM_UPGRADE\PDM1\FPM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_DETAILPLANFIELD' AND KSQL_COL_NAME IN ('FDETAILDIMTYPE'))
 ALTER TABLE T_FPM_DETAILPLANFIELD ADD (FDETAILDIMTYPE VARCHAR(50) DEFAULT ' ' NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_TEMPLATE_CURRENCY')
 CREATE TABLE T_FPM_TEMPLATE_CURRENCY (
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_TEMPLATE_L')
 CREATE TABLE T_FPM_TEMPLATE_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FCOMMENT VARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_TEMPLATE_DIMSET')
 CREATE TABLE T_FPM_TEMPLATE_DIMSET (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FDIMID BIGINT DEFAULT 0 NOT NULL,
FTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FCONTAINSUBTOTAL CHAR(1) DEFAULT '0' NOT NULL,
FISOPEN CHAR(1) DEFAULT '0' NOT NULL,
FLEVEL INT DEFAULT 0 NOT NULL,
FISHIDE CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_TEMPLATE_SUBJECT')
 CREATE TABLE T_FPM_TEMPLATE_SUBJECT (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSUBJECTID BIGINT DEFAULT 0 NOT NULL,
FSUBTEMPLATEID BIGINT DEFAULT 0 NOT NULL,
FFORMULA VARCHAR(1000) DEFAULT ' ' NOT NULL,
FFORMULA_TAG NCLOB,
FREPORTWAYS VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_TEMPLATE_USEORG')
 CREATE TABLE T_FPM_TEMPLATE_USEORG (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FUSEORG BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_TEMPLATE_EXPAND')
 CREATE TABLE T_FPM_TEMPLATE_EXPAND (
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_TEMPLATE_MEMBER')
 CREATE TABLE T_FPM_TEMPLATE_MEMBER (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);



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