/**Begin D:\PDM_UPGRADE\PDM1\PUR_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_REGSUPGOODS' AND KSQL_COL_NAME IN ('FMONTHLYCAPACITY')) 
 ALTER TABLE T_PUR_REGSUPGOODS ADD (FMONTHLYCAPACITY NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_REGSUPGOODS' AND KSQL_COL_NAME IN ('FYEARCAPACITY')) 
 ALTER TABLE T_PUR_REGSUPGOODS ADD (FYEARCAPACITY NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_REGSUPLINK' AND KSQL_COL_NAME IN ('FBIZSCOPETYPE')) 
 ALTER TABLE T_PUR_REGSUPLINK ADD (FBIZSCOPETYPE CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_APTITUDE' AND KSQL_COL_NAME IN ('FTYPE')) 
 ALTER TABLE T_PUR_APTITUDE ADD (FTYPE CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_APTITUDE' AND KSQL_COL_NAME IN ('FCERTIFIAPPLYID')) 
 ALTER TABLE T_PUR_APTITUDE ADD (FCERTIFIAPPLYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_APTITUDE' AND KSQL_COL_NAME IN ('FEXAMRESULT')) 
 ALTER TABLE T_PUR_APTITUDE ADD (FEXAMRESULT CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_APTITUDE' AND KSQL_COL_NAME IN ('FRESULTREMARK')) 
 ALTER TABLE T_PUR_APTITUDE ADD (FRESULTREMARK NCLOB DEFAULT ' ' );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_PRODUCT') 
 CREATE TABLE T_PUR_PRODUCT (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FPRODUCTOOLNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FPRODUCTOOLNUM DECIMAL(19) DEFAULT 0 NOT NULL,
FPRODUCTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSTAFFNUMS DECIMAL(19) DEFAULT 0 NOT NULL,
FQESTAFFNUMS DECIMAL(19) DEFAULT 0 NOT NULL,
FPUTDATE DATETIME,
FCYCLE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FTRAFFIC NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_REGCORESTAFF') 
 CREATE TABLE T_PUR_REGCORESTAFF (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FCORESTAFFNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCORESTAFFPOST NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCORESNATIONALITY BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_REGSUCUSTOMER') 
 CREATE TABLE T_PUR_REGSUCUSTOMER (
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FTOPCUSTOMER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FTRADEVOLUME DECIMAL(19,6) DEFAULT 0.0 NOT NULL,
FTRADECUR BIGINT DEFAULT 0 NOT NULL,
FCOOPERATSCOPE NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_REGSTOCK') 
 CREATE TABLE T_PUR_REGSTOCK (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSTOCKNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSTOCKRATIO DECIMAL(19,6) DEFAULT 0.0 NOT NULL,
FNATIONALITY BIGINT DEFAULT 0 NOT NULL,
FSTOCKLEVEL CHAR(1) DEFAULT ' ' NOT NULL,
FSTOCKREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_REGSUPPLIER_C') 
 CREATE TABLE T_PUR_REGSUPPLIER_C (
FID BIGINT DEFAULT 0 NOT NULL,
FCERTIFIAPPLYID BIGINT DEFAULT 0 NOT NULL,
FISSUERFIID VARCHAR(80) DEFAULT ' ' NOT NULL,
FDUNSNUMBER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSUPNAMEEN VARCHAR(255) DEFAULT ' ' NOT NULL,
FTAXREGISTREDADS NVARCHAR(255) DEFAULT ' ' NOT NULL,
FENTERPRISETYPE CHAR(1) DEFAULT ' ' NOT NULL,
FTECHNICIANNUM DECIMAL(19) DEFAULT 0 NOT NULL,
FQUALITYSTAFFNUM DECIMAL(19) DEFAULT 0 NOT NULL,
FMANAGECUR BIGINT DEFAULT 0 NOT NULL,
FMANAGEMENTSTAFF DECIMAL(19) DEFAULT 0 NOT NULL,
FTYEAR NVARCHAR(255) DEFAULT ' ' NOT NULL,
FLASTYEAR NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBEFOREYEAR NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDESIGNCAPACITY CHAR(1) DEFAULT ' ' NOT NULL,
FSTANDCAPACITY CHAR(1) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_CACATEGORY') 
 CREATE TABLE T_PUR_CACATEGORY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FCATEGORYID BIGINT DEFAULT 0 NOT NULL,
FNOTE NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_CAMEMBER') 
 CREATE TABLE T_PUR_CAMEMBER (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FMEMBERID BIGINT DEFAULT 0 NOT NULL,
FROLEID BIGINT DEFAULT 0 NOT NULL,
FISLEADER CHAR(1) DEFAULT ' ' NOT NULL,
FNOTE NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_CERTIFIAPPLY') 
 CREATE TABLE T_PUR_CERTIFIAPPLY (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(80) 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,
FBIZTYPEID BIGINT DEFAULT 0 NOT NULL,
FOPERGROUPID BIGINT DEFAULT 0 NOT NULL,
FHAVEISSUE CHAR(1) DEFAULT ' ' NOT NULL,
FPROJECTNAME NVARCHAR(255) DEFAULT ' ',
FCERTIFICATIONBACKGROUND NCLOB DEFAULT ' '
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_ISSUERFI') 
 CREATE TABLE T_PUR_ISSUERFI (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) 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,
FSUPPLIERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FLINKMAN NVARCHAR(255) DEFAULT ' ' NOT NULL,
FEMAIL VARCHAR(100) DEFAULT ' ' NOT NULL,
FPHONE VARCHAR(30) DEFAULT ' ' NOT NULL,
FBIZTYPEID BIGINT DEFAULT 0 NOT NULL,
FREGSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FCERTIFIAPPLYID BIGINT DEFAULT 0 NOT NULL,
FHAVEREGRFI CHAR(1) DEFAULT ' ' NOT NULL,
FHAVECONFIRM CHAR(1) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_RFICONENTRY') 
 CREATE TABLE T_PUR_RFICONENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FRFICONTENTID BIGINT DEFAULT 0 NOT NULL,
FRFIDESC NCLOB DEFAULT ' ',
FREQUIRED CHAR(1) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_RFIENTRYINFO') 
 CREATE TABLE T_PUR_RFIENTRYINFO (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FRFIDESC NCLOB DEFAULT ' ',
FREQUIRED CHAR(1) DEFAULT ' ' NOT NULL,
FRFICONTENTID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_RFICONTENT') 
 CREATE TABLE T_PUR_RFICONTENT (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(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,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY CHAR(1) DEFAULT ' ' NOT NULL,
FUSEORGID BIGINT DEFAULT 0 NOT NULL,
FSEQNUMBER VARCHAR(10) DEFAULT ' ' NOT NULL,
FPAGENUMBER VARCHAR(100) DEFAULT ' ' NOT NULL,
FPAGENAME NVARCHAR(512) DEFAULT ' ' NOT NULL,
FISPUBLIC CHAR(1) DEFAULT ' ' NOT NULL,
FPRESET CHAR(1) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_RFICONTENT_L') 
 CREATE TABLE T_PUR_RFICONTENT_L (
FPKID VARCHAR(20) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(512) DEFAULT ' ' NOT NULL,
FLOCALEID VARCHAR(20) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_APTITUDESTDCONFIG') 
 CREATE TABLE T_PUR_APTITUDESTDCONFIG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(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,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY CHAR(1) DEFAULT ' ' NOT NULL,
FUSEORGID BIGINT DEFAULT 0 NOT NULL,
FEVAFACTORCONFIGID BIGINT DEFAULT 0 NOT NULL,
FASSESSCONTENT NVARCHAR(512) DEFAULT ' ' NOT NULL,
FNOTE NVARCHAR(2000) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_APTITUDESTDCONFIG_L') 
 CREATE TABLE T_PUR_APTITUDESTDCONFIG_L (
FPKID VARCHAR(20) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(20) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNOTE NVARCHAR(255)
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_EVAFACTOR') 
 CREATE TABLE T_PUR_EVAFACTOR (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(50) 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,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY CHAR(1) DEFAULT ' ' NOT NULL,
FASSESS VARCHAR(512) DEFAULT ' ' NOT NULL,
FUSEORGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_EVAFACTOR_L') 
 CREATE TABLE T_PUR_EVAFACTOR_L (
FPKID VARCHAR(20) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(20) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_CONTENTCONFIG') 
 CREATE TABLE T_PUR_CONTENTCONFIG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY CHAR(1) DEFAULT ' ' NOT NULL,
FBIZTYPEID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FUSEORGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_CONTENTCONFIG_L') 
 CREATE TABLE T_PUR_CONTENTCONFIG_L (
FPKID VARCHAR(20) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(20) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNOTE NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_TARGETANDCATEGORY') 
 CREATE TABLE T_PUR_TARGETANDCATEGORY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FCATEGORYID BIGINT DEFAULT 0 NOT NULL,
FTARGET VARCHAR(512) DEFAULT ' ' NOT NULL,
FCATEGORYNOTE NCLOB DEFAULT ' '
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_ASSESSENTRY') 
 CREATE TABLE T_PUR_ASSESSENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FEVAFACTORCONFIGID BIGINT DEFAULT 0 NOT NULL,
FASSESSCONTENT VARCHAR(255) DEFAULT ' ' NOT NULL,
FEXAMCATEGORYID BIGINT DEFAULT 0 NOT NULL,
FTARGET VARCHAR(255) DEFAULT ' ' NOT NULL,
FISSATISFIED VARCHAR(50) DEFAULT ' ' NOT NULL,
FEXAMREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_MGATT') 
 CREATE TABLE T_PUR_MGATT (
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_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CAMEMBER' AND KSQL_COL_NAME IN ('FROLEID')) 
 ALTER TABLE T_PUR_CAMEMBER ADD (FROLEID BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_RFICONTENT' AND KSQL_COL_NAME IN ('FPRESET')) 
 ALTER TABLE T_PUR_RFICONTENT ADD (FPRESET CHAR(1) DEFAULT ' ' NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_ISSUERFI' AND KSQL_COL_NAME IN ('FHAVECONFIRM')) 
 ALTER TABLE T_PUR_ISSUERFI ADD (FHAVECONFIRM CHAR(1) DEFAULT ' ' NOT NULL);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CACATEGORY' AND KSQL_COL_NAME IN ('FNOTE')) 
 ALTER TABLE T_PUR_CACATEGORY ADD (FNOTE NVARCHAR(512) DEFAULT ' ' NOT NULL);

 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_MATERIAL' AND KSQL_COL_NAME IN ('FTYPE')) 
 ALTER TABLE T_PUR_MATERIAL ADD (FTYPE CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_MATERIAL' AND KSQL_COL_NAME IN ('FCERTIFIAPPLYID')) 
 ALTER TABLE T_PUR_MATERIAL ADD (FCERTIFIAPPLYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_SCENE' AND KSQL_COL_NAME IN ('FCAAPPLYID')) 
 ALTER TABLE T_PUR_SCENE ADD (FCAAPPLYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_SCENE' AND KSQL_COL_NAME IN ('FAPPLYTYPE')) 
 ALTER TABLE T_PUR_SCENE ADD (FAPPLYTYPE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_SCENE' AND KSQL_COL_NAME IN ('FSUPPLIERLINKMAN')) 
 ALTER TABLE T_PUR_SCENE ADD (FSUPPLIERLINKMAN NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_SCENE' AND KSQL_COL_NAME IN ('FSUPLINKEMAIL')) 
 ALTER TABLE T_PUR_SCENE ADD (FSUPLINKEMAIL VARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_SCENE' AND KSQL_COL_NAME IN ('FSUPLINKMOBILE')) 
 ALTER TABLE T_PUR_SCENE ADD (FSUPLINKMOBILE VARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_SAMPLE' AND KSQL_COL_NAME IN ('FTYPE')) 
 ALTER TABLE T_PUR_SAMPLE ADD (FTYPE CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_SAMPLE' AND KSQL_COL_NAME IN ('FCERTIFIAPPLYID')) 
 ALTER TABLE T_PUR_SAMPLE ADD (FCERTIFIAPPLYID BIGINT DEFAULT 0 NOT NULL );
 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_RFICONENTRY' AND KSQL_COL_NAME IN ('FRFIDESC')) 
 ALTER TABLE T_PUR_RFICONENTRY ADD (FRFIDESC NCLOB DEFAULT ' ');
 EXEC p_AlterColumn 'T_PUR_CERTIFIAPPLY', 'FPROJECTNAME', 'NVARCHAR(512)', 'NULL', '0100', '';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_INSPECT') 
 CREATE TABLE T_PUR_INSPECT (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FINSPECTSTAFF BIGINT DEFAULT 0 NOT NULL,
FISLEADER CHAR(1) DEFAULT ' ' NOT NULL,
FINSPECTREMARKS NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_AUDITENTRY') 
 CREATE TABLE T_PUR_AUDITENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FINSPECTPROJECT BIGINT DEFAULT 0 NOT NULL,
FINSPECTSCORE DECIMAL(23,2) DEFAULT 0 NOT NULL,
FJUDGERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_AUDITENTRYATT') 
 CREATE TABLE T_PUR_AUDITENTRYATT (
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_PUR_INSPECTFIND') 
 CREATE TABLE T_PUR_INSPECTFIND (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FINSPECTFINDPRO BIGINT DEFAULT 0 NOT NULL,
FINSPECTFINDTYPE BIGINT DEFAULT 0 NOT NULL,
FINSPECTFINDEXPL NVARCHAR(512) DEFAULT ' ' NOT NULL,
FINSPECTFINDGRADE BIGINT DEFAULT 0 NOT NULL,
FINSPECTFINDPEO BIGINT DEFAULT 0 NOT NULL
);
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_EXAMATTACHMENT') 
 CREATE TABLE T_PUR_EXAMATTACHMENT (
FPKID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);
EXEC p_AlterColumn 'T_PUR_ISSUERFI', 'FLINKMAN', 'NVARCHAR(255)', 'NOT NULL', '0100', ''' ''';
EXEC p_AlterColumn 'T_PUR_ASSESSENTRY', 'FEXAMREMARK', 'NVARCHAR(512)', 'NOT NULL', '0100', ''' ''';
/**End D:\PDM_UPGRADE\PDM1\PUR_table.sql **/
