IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYMENTBILL' AND KSQL_COL_NAME IN ('FPAYMENTIDENTIFYID')) 
 ALTER TABLE T_CAS_PAYMENTBILL ADD (FPAYMENTIDENTIFYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CAS_PAYAPPLYBILL' AND KSQL_COL_NAME IN ('FPAYMENTIDENTIFYID')) 
 ALTER TABLE T_CAS_PAYAPPLYBILL ADD (FPAYMENTIDENTIFYID BIGINT DEFAULT 0 NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_PAYMENTIDENTIFY') 
 CREATE TABLE T_CAS_PAYMENTIDENTIFY (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(10) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT '0' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FTYPE NVARCHAR(100) DEFAULT ' ' NOT NULL,
FISDEFAULT CHAR(1) DEFAULT '0' NOT NULL,
FDESCRIBE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FISSYSTEM CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_CAS_PAYMENTIDENTIFY_L') 
 CREATE TABLE T_CAS_PAYMENTIDENTIFY_L (
FPKID NVARCHAR(18) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);


 EXEC P_ALTERPK 'PK_T_CAS_PAYMENTIDENTIFY', 'T_CAS_PAYMENTIDENTIFY', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_CAS_PBID_FNUMBER') CREATE INDEX IDX_CAS_PBID_FNUMBER ON T_CAS_PAYMENTIDENTIFY ( FNUMBER );

 EXEC P_ALTERPK 'PK_T_CAS_PAYMENTIDENTIFY_L', 'T_CAS_PAYMENTIDENTIFY_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_CAS_PMIL_FID') CREATE INDEX IDX_CAS_PMIL_FID ON T_CAS_PAYMENTIDENTIFY_L ( FID );

