/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\TCCIT_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCCIT_APITUDEINFO' AND KSQL_COL_NAME ='FANNUALCOME') 
 ALTER TABLE T_TCCIT_APITUDEINFO ADD (FANNUALCOME VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCCIT_ITEM_ENTRY') 
 CREATE TABLE T_TCCIT_ITEM_ENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FDATADIRECTION VARCHAR(30) DEFAULT ' ' NOT NULL,
FBIZNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FDATATYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FAMOUNTFIELD BIGINT DEFAULT 0 NOT NULL,
FTABLE BIGINT DEFAULT 0 NOT NULL,
FFILTERCONDITION NCLOB,
FFCONDITIONJSON NCLOB
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCCIT_SHARING_EDIT') 
 CREATE TABLE T_TCCIT_SHARING_EDIT (
FID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FPLANNAME VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCCIT_SHARING_L') 
 CREATE TABLE T_TCCIT_SHARING_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCCIT_SHARING_ORGS') 
 CREATE TABLE T_TCCIT_SHARING_ORGS (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCCIT_SHARING_RULES') 
 CREATE TABLE T_TCCIT_SHARING_RULES (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FRULEID BIGINT DEFAULT 0 NOT NULL,
FTYPE VARCHAR(30) DEFAULT ' ' NOT NULL
);



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