/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\SRC_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_PURLISTTPL') 
 CREATE TABLE T_SRC_PURLISTTPL (
FPKID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_SUPSCHEME') 
 CREATE TABLE T_SRC_SUPSCHEME (
FID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(300) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FISSYSPRESET BIGINT DEFAULT 0 NOT NULL,
FCONDITION NVARCHAR(510) DEFAULT ' ' NOT NULL,
FCONDITION_TAG NCLOB,
FBASEDATAID VARCHAR(36) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FMATCHFIELD INT DEFAULT 0 NOT NULL,
FFIELDNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FFIELDID VARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_SUPSCHEME_L') 
 CREATE TABLE T_SRC_SUPSCHEME_L (
FPKID NVARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(300) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_SUPSCHEMEBASE') 
 CREATE TABLE T_SRC_SUPSCHEMEBASE (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_SUPSCHEMEENTRY') 
 CREATE TABLE T_SRC_SUPSCHEMEENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPLUGINNAME VARCHAR(100) DEFAULT ' ' NOT NULL,
FNOTE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL
);


 EXEC p_AlterColumn 'T_SRC_CHANGELOG', 'FBILLNAME1', 'VARCHAR(255)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INVITESUPPLIER' AND KSQL_COL_NAME ='FISEXEMPT') 
 ALTER TABLE T_SRC_INVITESUPPLIER ADD (FISEXEMPT CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PATTERN' AND KSQL_COL_NAME ='FMATCHFIELD') 
 ALTER TABLE T_SRC_PATTERN ADD (FMATCHFIELD INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_FEESURPLUS' AND KSQL_COL_NAME ='FSUMRECEIPT') 
 ALTER TABLE T_SRC_FEESURPLUS ADD (FSUMRECEIPT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_FEESURPLUS' AND KSQL_COL_NAME ='FSUMRETURN') 
 ALTER TABLE T_SRC_FEESURPLUS ADD (FSUMRETURN DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_FEESURPLUS' AND KSQL_COL_NAME ='FSUMCARRYOVER') 
 ALTER TABLE T_SRC_FEESURPLUS ADD (FSUMCARRYOVER DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_FEESURPLUS' AND KSQL_COL_NAME ='FSUMADJUST') 
 ALTER TABLE T_SRC_FEESURPLUS ADD (FSUMADJUST DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_FEESURPLUS' AND KSQL_COL_NAME ='FSUMUSE') 
 ALTER TABLE T_SRC_FEESURPLUS ADD (FSUMUSE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_FEESURPLUS' AND KSQL_COL_NAME ='FSURPLUSTYPE') 
 ALTER TABLE T_SRC_FEESURPLUS ADD (FSURPLUSTYPE CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_FEESURPLUS' AND KSQL_COL_NAME ='FSUMTRANSFER') 
 ALTER TABLE T_SRC_FEESURPLUS ADD (FSUMTRANSFER DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PAYMENTENTRY' AND KSQL_COL_NAME ='FSURPLUSTYPE') 
 ALTER TABLE T_SRC_PAYMENTENTRY ADD (FSURPLUSTYPE CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PAYMENTENTRY' AND KSQL_COL_NAME ='FCARRYOVERAMOUNT') 
 ALTER TABLE T_SRC_PAYMENTENTRY ADD (FCARRYOVERAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PAYMENTENTRY' AND KSQL_COL_NAME ='FCARRYOVERUSERID') 
 ALTER TABLE T_SRC_PAYMENTENTRY ADD (FCARRYOVERUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PAYMENTENTRY' AND KSQL_COL_NAME ='FCARRYOVERDATE') 
 ALTER TABLE T_SRC_PAYMENTENTRY ADD (FCARRYOVERDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PAYMENTENTRY' AND KSQL_COL_NAME ='FCARRYOVEROPINION') 
 ALTER TABLE T_SRC_PAYMENTENTRY ADD (FCARRYOVEROPINION NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PAYMENTENTRY' AND KSQL_COL_NAME ='FRESULT') 
 ALTER TABLE T_SRC_PAYMENTENTRY ADD (FRESULT CHAR(1) DEFAULT ' ' NOT NULL );

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