/**Begin D:\PDM\PDM_UPGRADE\pdm1\IFM_table.sql **/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INTOBJECT' AND KSQL_COL_NAME IN ('FINITACCUM')) 
 ALTER TABLE T_IFM_INTOBJECT ADD (FINITACCUM DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INTOBJECT' AND KSQL_COL_NAME IN ('FINTSETTLESCHEMEID')) 
 ALTER TABLE T_IFM_INTOBJECT ADD (FINTSETTLESCHEMEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INTOBJECT' AND KSQL_COL_NAME IN ('FINTTHRESHOLD')) 
 ALTER TABLE T_IFM_INTOBJECT ADD (FINTTHRESHOLD BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INTOBJECT' AND KSQL_COL_NAME IN ('FINTFREEAMT')) 
 ALTER TABLE T_IFM_INTOBJECT ADD (FINTFREEAMT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_INTOBJECT_DEPINT_E') 
 CREATE TABLE T_IFM_INTOBJECT_DEPINT_E (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FDEPOSITAMTBEGIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEPOSITAMTEND DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINTFLOATWAY VARCHAR(50) DEFAULT ' ' NOT NULL,
FINTFLOATPOINT DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_INTOBJECT_OVERINT_E') 
 CREATE TABLE T_IFM_INTOBJECT_OVERINT_E (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FDEPOSITBEGIN DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEPOSITEND DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOVERFLOATWAY VARCHAR(50) DEFAULT ' ' NOT NULL,
FOVERINTFLOATPOINT DECIMAL(23,10) DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_BIZDEALBILL_DEPOSIT') 
 CREATE TABLE T_IFM_BIZDEALBILL_DEPOSIT (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(80) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBIZSTATUS NVARCHAR(80) DEFAULT ' ' NOT NULL,
FAPPLYTYPE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FAPPLYORGID BIGINT DEFAULT 0 NOT NULL,
FAPPLIDATE DATETIME,
FFINORGINFOID BIGINT DEFAULT 0 NOT NULL,
FINVESTVARIETIESID BIGINT DEFAULT 0 NOT NULL,
FSETTLEACCOUNTID BIGINT DEFAULT 0 NOT NULL,
FFINACCOUNT NVARCHAR(80) DEFAULT ' ' NOT NULL,
FFINACCOUNTID BIGINT DEFAULT 0 NOT NULL,
FLASTREDEEMDATE DATETIME,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FSURPLUSAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEALOPINION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREDEEMDATE DATETIME,
FRELEASETYPE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FISREVENUE CHAR(1) DEFAULT '0' NOT NULL,
FDEALUSERID BIGINT DEFAULT 0 NOT NULL,
FDEMANDRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPREDICTINSTAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREALREVENUE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTALAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXPIREREDEPOSIT NVARCHAR(80) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDEPOSITAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINTDATE DATETIME,
FTERM NVARCHAR(80) DEFAULT ' ' NOT NULL,
FEXPIREDATE DATETIME,
FPRENOTICEDAY NVARCHAR(80) DEFAULT ' ' NOT NULL,
FINTERESTTYPE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FINTERESTRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREFERENCERATE BIGINT DEFAULT 0 NOT NULL,
FRATESIGN NVARCHAR(80) DEFAULT ' ' NOT NULL,
FRATEFLOATPOINT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRATEADJUSTSTYLE NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBASIS NVARCHAR(80) DEFAULT ' ' NOT NULL,
FREDEPOSITAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRODUCTID BIGINT DEFAULT 0 NOT NULL,
FFINBILLNOID BIGINT DEFAULT 0 NOT NULL,
FAPPLYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_BIZDEALBILL_ENTRY') 
 CREATE TABLE T_IFM_BIZDEALBILL_ENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FESTARTDATE DATETIME,
FEENDDATE DATETIME,
FEDAYS INT DEFAULT 0 NOT NULL,
FEFINAMOUNT DECIMAL(23) DEFAULT 0 NOT NULL,
FEPLANREVENUE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FECONVERTDAYS INT DEFAULT 0 NOT NULL,
FEREVENUEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_BIZDEALBILL_DEPOSIT_E') 
 CREATE TABLE T_IFM_BIZDEALBILL_DEPOSIT_E (
FID BIGINT DEFAULT 0 NOT NULL,
FDEALDATE DATETIME
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INNERACCT' AND KSQL_COL_NAME IN ('FAUTHQUERPT'))
 ALTER TABLE T_IFM_INNERACCT ADD (FAUTHQUERPT CHAR(1) DEFAULT '1' NOT NULL );

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