/**Begin D:\PDM\pdm_upgrade\pdm1\ER2_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_STAKEHOLDERAFTER') 
 CREATE TABLE T_ER_STAKEHOLDERAFTER (
FPKID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_STAKEHOLDERBILL') 
 CREATE TABLE T_ER_STAKEHOLDERBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FTEL VARCHAR(50) DEFAULT ' ' NOT NULL,
FCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FBILLNO VARCHAR(30) DEFAULT ' ' NOT NULL,
FCHANGEDATE DATETIME,
FDESCRIPTION VARCHAR(600) DEFAULT ' ' NOT NULL,
FCHANGETYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FAUDITDATE DATETIME,
FCREATETIME DATETIME,
FNEXTAUDITOR VARCHAR(50) DEFAULT ' ' NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FBILLSTATUS VARCHAR(10) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAPPLIERID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FAPPLIERPOSITION VARCHAR(50) DEFAULT ' ' NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FREMARKS VARCHAR(200) DEFAULT ' ' NOT NULL,
FCOSTDEPTID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_STAKEHOLDERBILL_TC') 
 CREATE TABLE T_ER_STAKEHOLDERBILL_TC (
FID BIGINT DEFAULT 0 NOT NULL,
FTBILLID BIGINT DEFAULT 0 NOT NULL,
FTTABLEID BIGINT DEFAULT 0 NOT NULL,
FTID BIGINT DEFAULT 0 NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FSTABLEID BIGINT DEFAULT 0 NOT NULL,
FSID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_STAKEHOLDERBILL_WB') 
 CREATE TABLE T_ER_STAKEHOLDERBILL_WB (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FRULEVERID BIGINT DEFAULT 0 NOT NULL,
FRULEITEMID BIGINT DEFAULT 0 NOT NULL,
FOPERATE VARCHAR(50) DEFAULT ' ' NOT NULL,
FSTABLEID BIGINT DEFAULT 0 NOT NULL,
FSID BIGINT DEFAULT 0 NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FWRITEVALUE DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_STAKEHOLDERDETAIL') 
 CREATE TABLE T_ER_STAKEHOLDERDETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FORIBILLTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FORIBILLNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FORIDESCRIPTION VARCHAR(500) DEFAULT ' ' NOT NULL,
FSTAKEHOLDERBEFORE VARCHAR(200) DEFAULT ' ' NOT NULL,
FREMARKS VARCHAR(200) DEFAULT ' ' NOT NULL,
FBIZDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_STAKERELATEBILL') 
 CREATE TABLE T_ER_STAKERELATEBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO VARCHAR(30) DEFAULT ' ' NOT NULL,
FBIZDATE DATETIME,
FDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL,
FPROJECTOWER VARCHAR(50) DEFAULT ' ' NOT NULL
);



/**End D:\PDM\pdm_upgrade\pdm1\ER2_table.sql **/
