/**Begin D:\PDM_UPGRADE\PDM1\FA_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_RESTARTREALBILL_D') 
 CREATE TABLE T_FA_RESTARTREALBILL_D (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FDEPREUSEID BIGINT DEFAULT 0 NOT NULL,
FCLEARBILLID BIGINT DEFAULT 0 NOT NULL,
FCLEARBILLDETAILID BIGINT DEFAULT 0 NOT NULL,
FREALCARDID BIGINT DEFAULT 0 NOT NULL,
FASSETQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRESTCLEARQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRESTASSETVALUE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRESTADDUPDEPRE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRESTDECVAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRESTPRERESIDUALVAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FADDEDDEPRE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRESTARTTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FCLEARALLPERIODID BIGINT DEFAULT 0 NOT NULL,
FBAKREALCARDID BIGINT DEFAULT 0 NOT NULL,
FADDEDDEPREAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASECURRENCYID BIGINT DEFAULT 0 NOT NULL,
FMEASUREUNITID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_RESTARTREALBILL') 
 CREATE TABLE T_FA_RESTARTREALBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO VARCHAR(30) 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,
FORGID BIGINT DEFAULT 0 NOT NULL,
FRESTARTDATE DATETIME,
FREASON VARCHAR(255) DEFAULT ' ' NOT NULL,
FCHANGEMODEID BIGINT DEFAULT 0 NOT NULL,
FRESTARTPERIODID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_CLRBILLENTRY_D' AND KSQL_COL_NAME IN ('FBIZSTATUS')) 
 ALTER TABLE T_FA_CLRBILLENTRY_D ADD (FBIZSTATUS VARCHAR(50) DEFAULT 'READY' NOT NULL );

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