/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\TCTB_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCTB_DRAFT_MAIN') 
 CREATE TABLE T_TCTB_DRAFT_MAIN (
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,
FTYPE VARCHAR(36) DEFAULT ' ' NOT NULL,
FTEMPLATETYPE VARCHAR(36) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
FSTARTDATE DATETIME,
FENDDATE DATETIME,
FDRAFTPURPOSE VARCHAR(50) DEFAULT ' ' NOT NULL,
FACCOUNTORG BIGINT DEFAULT 0 NOT NULL,
FJTNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FDRAFTTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FDATASOURCE VARCHAR(50) DEFAULT ' ' NOT NULL,
FISDECLARE CHAR(1) DEFAULT '0' NOT NULL,
FISMODIFIED VARCHAR(50) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCTB_TAX_MAIN' AND KSQL_COL_NAME ='FISINITIAL') 
 ALTER TABLE T_TCTB_TAX_MAIN ADD (FISINITIAL CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCTB_CATEGORYINFO' AND KSQL_COL_NAME ='FRESIDENTTYPE') 
 ALTER TABLE T_TCTB_CATEGORYINFO ADD (FRESIDENTTYPE VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCTB_APITUDEINFO' AND KSQL_COL_NAME ='FSHANGHAI') 
 ALTER TABLE T_TCTB_APITUDEINFO ADD (FSHANGHAI CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCTB_APITUDEINFO' AND KSQL_COL_NAME ='FISSUEDATE') 
 ALTER TABLE T_TCTB_APITUDEINFO ADD (FISSUEDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCTB_APITUDEINFO' AND KSQL_COL_NAME ='FCERTIFICATENO') 
 ALTER TABLE T_TCTB_APITUDEINFO ADD (FCERTIFICATENO VARCHAR(50) DEFAULT ' ' NOT NULL );

/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\TCTB_table.sql **/
