/*借款单项目干系人*/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_DAILYLOANOWER')
 CREATE TABLE T_ER_DAILYLOANOWER (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);
EXEC P_ALTERPK 'PK_T_ER_DAILYLOANOWER', 'T_ER_DAILYLOANOWER', 'FPKID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_DAILYLOANBILLID') CREATE INDEX IDX_ER_DAILYLOANBILLID ON T_ER_DAILYLOANOWER ( FID );
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_DAILYLOANUSERID') CREATE INDEX IDX_ER_DAILYLOANUSERID ON T_ER_DAILYLOANOWER ( FBASEDATAID );


/*费用申请单项目干系人*/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_DAILYAPPLYOWER')
 CREATE TABLE T_ER_DAILYAPPLYOWER (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);
EXEC P_ALTERPK 'PK_T_ER_DAILYAPPLYOWER', 'T_ER_DAILYAPPLYOWER', 'FPKID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_DAILYAPPLYBILL') CREATE INDEX IDX_ER_DAILYAPPLYBILL ON T_ER_DAILYAPPLYOWER ( FID );
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_DAILYAPPLYUSER') CREATE INDEX IDX_ER_DAILYAPPLYUSER ON T_ER_DAILYAPPLYOWER ( FBASEDATAID );


/*预付单项目干系人*/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_PREPAYOWER') 
 CREATE TABLE T_ER_PREPAYOWER (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);
EXEC P_ALTERPK 'PK_T_ER_PREPAYOWER', 'T_ER_PREPAYOWER', 'FPKID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_PREPAYBILL') CREATE INDEX IDX_ER_PREPAYBILL ON T_ER_PREPAYOWER ( FID );
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_PREPAYUSER') CREATE INDEX IDX_ER_PREPAYUSER ON T_ER_PREPAYOWER ( FBASEDATAID );


/*出差申请单项目干系人*/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_TRIPREQOWER') 
 CREATE TABLE T_ER_TRIPREQOWER (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);
EXEC P_ALTERPK 'PK_T_ER_TRIPREQOWER', 'T_ER_TRIPREQOWER', 'FPKID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_TRIPREQBILLID') CREATE INDEX IDX_ER_TRIPREQBILLID ON T_ER_TRIPREQOWER ( FID );
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_TRIPREQUSERID') CREATE INDEX IDX_ER_TRIPREQUSERID ON T_ER_TRIPREQOWER ( FBASEDATAID );