/**Begin C:\PDM_UPGRADE\PDM1\SRC_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT' AND KSQL_COL_NAME IN ('FRATIOTYPE')) 
 ALTER TABLE T_SRC_PROJECT ADD (FRATIOTYPE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_APPLY' AND KSQL_COL_NAME IN ('FBIZTYPEID')) 
 ALTER TABLE T_SRC_APPLY ADD (FBIZTYPEID BIGINT DEFAULT 0 NOT NULL );
 EXEC p_AlterColumn 'T_SRC_APPLYENTRY', 'FREQDESCRIBE', 'NVARCHAR(512)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_SCORE' AND KSQL_COL_NAME IN ('FISVALID')) 
 ALTER TABLE T_SRC_SCORE ADD (FISVALID CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_SCORE' AND KSQL_COL_NAME IN ('FDESCRIPTION')) 
 ALTER TABLE T_SRC_SCORE ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_SCORE' AND KSQL_COL_NAME IN ('FMINVALUE')) 
 ALTER TABLE T_SRC_SCORE ADD (FMINVALUE DECIMAL(23,10) DEFAULT 0 NOT NULL );
 EXEC p_AlterColumn 'T_SRC_PURLISTENTRY', 'FNOTE', 'NVARCHAR(512)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PURLISTENTRY' AND KSQL_COL_NAME IN ('FEXRATETABLE')) 
 ALTER TABLE T_SRC_PURLISTENTRY ADD (FEXRATETABLE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PURLISTENTRY' AND KSQL_COL_NAME IN ('FEXRATEDATE')) 
 ALTER TABLE T_SRC_PURLISTENTRY ADD (FEXRATEDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PURLISTENTRY' AND KSQL_COL_NAME IN ('FEXRATE')) 
 ALTER TABLE T_SRC_PURLISTENTRY ADD (FEXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PURLISTENTRY' AND KSQL_COL_NAME IN ('FQUOTATION')) 
 ALTER TABLE T_SRC_PURLISTENTRY ADD (FQUOTATION CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_ASSESSCONFIG' AND KSQL_COL_NAME IN ('FQFILTER')) 
 ALTER TABLE T_SRC_ASSESSCONFIG ADD (FQFILTER NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_ASSESSCONFIG' AND KSQL_COL_NAME IN ('FQFILTER_TAG')) 
 ALTER TABLE T_SRC_ASSESSCONFIG ADD (FQFILTER_TAG NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_SCOREDETAIL' AND KSQL_COL_NAME IN ('FISFITTED')) 
 ALTER TABLE T_SRC_SCOREDETAIL ADD (FISFITTED CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_VIE_DETAIL' AND KSQL_COL_NAME IN ('FEXRATETABLE')) 
 ALTER TABLE T_SRC_VIE_DETAIL ADD (FEXRATETABLE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_VIE_DETAIL' AND KSQL_COL_NAME IN ('FEXRATEDATE')) 
 ALTER TABLE T_SRC_VIE_DETAIL ADD (FEXRATEDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_VIE_DETAIL' AND KSQL_COL_NAME IN ('FEXRATE')) 
 ALTER TABLE T_SRC_VIE_DETAIL ADD (FEXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_VIE_DETAIL' AND KSQL_COL_NAME IN ('FQUOTATION')) 
 ALTER TABLE T_SRC_VIE_DETAIL ADD (FQUOTATION CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_BIDCHANGE' AND KSQL_COL_NAME IN ('FCHANGESOURCE')) 
 ALTER TABLE T_SRC_BIDCHANGE ADD (FCHANGESOURCE CHAR(1) DEFAULT '3' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_BIDCHANGE' AND KSQL_COL_NAME IN ('FAPPLYID')) 
 ALTER TABLE T_SRC_BIDCHANGE ADD (FAPPLYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_BIDCHANGE' AND KSQL_COL_NAME IN ('FDEMANDID')) 
 ALTER TABLE T_SRC_BIDCHANGE ADD (FDEMANDID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_R' AND KSQL_COL_NAME IN ('FSUPPLIERTYPE')) 
 ALTER TABLE T_SRC_PROJECT_R ADD (FSUPPLIERTYPE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_R' AND KSQL_COL_NAME IN ('FAPTITUDETYPE')) 
 ALTER TABLE T_SRC_PROJECT_R ADD (FAPTITUDETYPE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_R' AND KSQL_COL_NAME IN ('FSUBMITTERID')) 
 ALTER TABLE T_SRC_PROJECT_R ADD (FSUBMITTERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_R' AND KSQL_COL_NAME IN ('FSUBMITDATE')) 
 ALTER TABLE T_SRC_PROJECT_R ADD (FSUBMITDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_R' AND KSQL_COL_NAME IN ('FUNSUBMITTERID')) 
 ALTER TABLE T_SRC_PROJECT_R ADD (FUNSUBMITTERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_R' AND KSQL_COL_NAME IN ('FUNSUBMITDATE')) 
 ALTER TABLE T_SRC_PROJECT_R ADD (FUNSUBMITDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_R' AND KSQL_COL_NAME IN ('FUNAUDITDATE')) 
 ALTER TABLE T_SRC_PROJECT_R ADD (FUNAUDITDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_R' AND KSQL_COL_NAME IN ('FUNAUDITORID')) 
 ALTER TABLE T_SRC_PROJECT_R ADD (FUNAUDITORID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_R' AND KSQL_COL_NAME IN ('FLASTUPDATEUSERID')) 
 ALTER TABLE T_SRC_PROJECT_R ADD (FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_R' AND KSQL_COL_NAME IN ('FLASTUPDATETIME')) 
 ALTER TABLE T_SRC_PROJECT_R ADD (FLASTUPDATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_ENROLLSUPPLIER' AND KSQL_COL_NAME IN ('FISAPTITUDE')) 
 ALTER TABLE T_SRC_ENROLLSUPPLIER ADD (FISAPTITUDE CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_ENROLLSUPPLIER' AND KSQL_COL_NAME IN ('FAPTITUDENOTE')) 
 ALTER TABLE T_SRC_ENROLLSUPPLIER ADD (FAPTITUDENOTE NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INVITESUPPLIER' AND KSQL_COL_NAME IN ('FISAPTITUDE')) 
 ALTER TABLE T_SRC_INVITESUPPLIER ADD (FISAPTITUDE CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INVITESUPPLIER' AND KSQL_COL_NAME IN ('FAPTITUDENOTE')) 
 ALTER TABLE T_SRC_INVITESUPPLIER ADD (FAPTITUDENOTE NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INVITESUPPLIER_TEMP' AND KSQL_COL_NAME IN ('FISAPTITUDE')) 
 ALTER TABLE T_SRC_INVITESUPPLIER_TEMP ADD (FISAPTITUDE CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INVITESUPPLIER_TEMP' AND KSQL_COL_NAME IN ('FAPTITUDENOTE')) 
 ALTER TABLE T_SRC_INVITESUPPLIER_TEMP ADD (FAPTITUDENOTE NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_MEMBERENTRY' AND KSQL_COL_NAME IN ('FFINISHDATE')) 
 ALTER TABLE T_SRC_MEMBERENTRY ADD (FFINISHDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INDEX' AND KSQL_COL_NAME IN ('FISFITTED')) 
 ALTER TABLE T_SRC_INDEX ADD (FISFITTED CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INDEX' AND KSQL_COL_NAME IN ('FVALUETYPE')) 
 ALTER TABLE T_SRC_INDEX ADD (FVALUETYPE CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INDEX' AND KSQL_COL_NAME IN ('FBIZOBJECT')) 
 ALTER TABLE T_SRC_INDEX ADD (FBIZOBJECT VARCHAR(36) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INDEX' AND KSQL_COL_NAME IN ('FVALUEFIELD')) 
 ALTER TABLE T_SRC_INDEX ADD (FVALUEFIELD VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INDEX' AND KSQL_COL_NAME IN ('FFILTERTYPE')) 
 ALTER TABLE T_SRC_INDEX ADD (FFILTERTYPE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INDEX' AND KSQL_COL_NAME IN ('FKEYFIELD')) 
 ALTER TABLE T_SRC_INDEX ADD (FKEYFIELD VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INDEX' AND KSQL_COL_NAME IN ('FPENTITYKEY')) 
 ALTER TABLE T_SRC_INDEX ADD (FPENTITYKEY VARCHAR(36) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INDEX' AND KSQL_COL_NAME IN ('FPKEYFIELD')) 
 ALTER TABLE T_SRC_INDEX ADD (FPKEYFIELD VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INDEX' AND KSQL_COL_NAME IN ('FEXTFILTERID')) 
 ALTER TABLE T_SRC_INDEX ADD (FEXTFILTERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INDEX' AND KSQL_COL_NAME IN ('FEXTPLUGIN')) 
 ALTER TABLE T_SRC_INDEX ADD (FEXTPLUGIN VARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INDEX' AND KSQL_COL_NAME IN ('FCONDITION')) 
 ALTER TABLE T_SRC_INDEX ADD (FCONDITION VARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INDEX' AND KSQL_COL_NAME IN ('FCONDITION_TAG')) 
 ALTER TABLE T_SRC_INDEX ADD (FCONDITION_TAG NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INDEX' AND KSQL_COL_NAME IN ('FORDERBY')) 
 ALTER TABLE T_SRC_INDEX ADD (FORDERBY VARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INDEX' AND KSQL_COL_NAME IN ('FDATEFIELD')) 
 ALTER TABLE T_SRC_INDEX ADD (FDATEFIELD VARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_INDEX' AND KSQL_COL_NAME IN ('FMAXSCORE')) 
 ALTER TABLE T_SRC_INDEX ADD (FMAXSCORE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_SCHEME' AND KSQL_COL_NAME IN ('FSUMSCORE')) 
 ALTER TABLE T_SRC_SCHEME ADD (FSUMSCORE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_SCHEME' AND KSQL_COL_NAME IN ('FSCHEMETYPE')) 
 ALTER TABLE T_SRC_SCHEME ADD (FSCHEMETYPE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_SCHEME' AND KSQL_COL_NAME IN ('FMATCHFIELD')) 
 ALTER TABLE T_SRC_SCHEME ADD (FMATCHFIELD INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_SCHEMEINDEX' AND KSQL_COL_NAME IN ('FISFITTED')) 
 ALTER TABLE T_SRC_SCHEMEINDEX ADD (FISFITTED CHAR(1) DEFAULT '0' NOT NULL );
 EXEC p_AlterColumn 'T_SRC_CONTRACTENTRY', 'FNOTE', 'NVARCHAR(512)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_CONTRACTENTRY_A' AND KSQL_COL_NAME IN ('FEXRATETABLE')) 
 ALTER TABLE T_SRC_CONTRACTENTRY_A ADD (FEXRATETABLE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_CONTRACTENTRY_A' AND KSQL_COL_NAME IN ('FEXRATEDATE')) 
 ALTER TABLE T_SRC_CONTRACTENTRY_A ADD (FEXRATEDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_CONTRACTENTRY_A' AND KSQL_COL_NAME IN ('FEXRATE')) 
 ALTER TABLE T_SRC_CONTRACTENTRY_A ADD (FEXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_CONTRACTENTRY_A' AND KSQL_COL_NAME IN ('FQUOTATION')) 
 ALTER TABLE T_SRC_CONTRACTENTRY_A ADD (FQUOTATION CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_CONTRACTENTRY_A' AND KSQL_COL_NAME IN ('FISNEW')) 
 ALTER TABLE T_SRC_CONTRACTENTRY_A ADD (FISNEW CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_DEMANDQTYCHG') 
 CREATE TABLE T_SRC_DEMANDQTYCHG (
FID BIGINT DEFAULT 0 NOT NULL,
FPARENTID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITYKEY VARCHAR(50) DEFAULT ' ' NOT NULL,
FPENTITYKEY VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_DEMANDQTYCHGENTRY') 
 CREATE TABLE T_SRC_DEMANDQTYCHGENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNOTE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FPREQTY DECIMAL(23,10) DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_DEMANDQTYCHGENTRY' AND KSQL_COL_NAME IN ('FPREQTY')) 
 ALTER TABLE T_SRC_DEMANDQTYCHGENTRY ADD (FPREQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_MATERIALEND') 
 CREATE TABLE T_SRC_MATERIALEND (
FID BIGINT DEFAULT 0 NOT NULL,
FPARENTID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITYKEY VARCHAR(50) DEFAULT ' ' NOT NULL,
FPENTITYKEY VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_MATERIALENDENTRY') 
 CREATE TABLE T_SRC_MATERIALENDENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPURLISTID BIGINT DEFAULT 0 NOT NULL,
FISSOURCE CHAR(1) DEFAULT '1' NOT NULL,
FSRCTYPEID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FBIDNAME NVARCHAR(80) DEFAULT ' ' NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNOTE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_RULEENTRY') 
 CREATE TABLE T_SRC_RULEENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPACKAGEID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FPURLISTID BIGINT DEFAULT 0 NOT NULL,
FWINERQTY INT DEFAULT 0 NOT NULL,
FORDERRATIO01 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERRATIO02 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERRATIO04 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERRATIO03 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERRATIO05 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERRATIO06 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERRATIO07 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERRATIO08 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERRATIO09 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERRATIO10 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORDERRATIO DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSURPLUSRATIO CHAR(1) DEFAULT '1' NOT NULL,
FALTERQTY INT DEFAULT 0 NOT NULL,
FTRAINQTY INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_APTITUDERESULT') 
 CREATE TABLE T_SRC_APTITUDERESULT (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSCORETASKID BIGINT DEFAULT 0 NOT NULL,
FINPUTSCORE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNOTE NVARCHAR(100) DEFAULT ' ' NOT NULL,
FISAPTITUDE CHAR(1) DEFAULT '1' NOT NULL,
FAPTITUDENOTE NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_APTITUDECONFIG') 
 CREATE TABLE T_SRC_APTITUDECONFIG (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPACKAGEID BIGINT DEFAULT 0 NOT NULL,
FINDEXTYPEID BIGINT DEFAULT 0 NOT NULL,
FSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FWEIGHT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNOTE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FENTRYSTATUS CHAR(1) DEFAULT 'A' NOT NULL,
FTPLNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FEXPERTCOUNT INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_APTITUDEUSER') 
 CREATE TABLE T_SRC_APTITUDEUSER (
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_APTITUDESUPPLIER') 
 CREATE TABLE T_SRC_APTITUDESUPPLIER (
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_SCHEMESOURCETYPE') 
 CREATE TABLE T_SRC_SCHEMESOURCETYPE (
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_SCHEMESOURCEFLOW') 
 CREATE TABLE T_SRC_SCHEMESOURCEFLOW (
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_SUPPLIERANALY') 
 CREATE TABLE T_SRC_SUPPLIERANALY (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLSTATUS CHAR(1) DEFAULT 'A' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL,
FLASTUPDATETIME DATETIME,
FBILLNO VARCHAR(30) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FTEMPLATE BIGINT DEFAULT 0 NOT NULL,
FPARENTID VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_SUPANALYHEAD') 
 CREATE TABLE T_SRC_SUPANALYHEAD (
FID BIGINT DEFAULT 0 NOT NULL,
FPARENTID VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITYKEY VARCHAR(50) DEFAULT ' ' NOT NULL,
FPENTITYKEY VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_SUPANALYSUPPLIER') 
 CREATE TABLE T_SRC_SUPANALYSUPPLIER (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FNOTE NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_SUPANALYDETAIL') 
 CREATE TABLE T_SRC_SUPANALYDETAIL (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FNOTE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FINDEXID BIGINT DEFAULT 0 NOT NULL,
FTXTVALUE NVARCHAR(510) DEFAULT ' ' NOT NULL,
FVALUE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSCORE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBILLID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FVALUETYPE CHAR(1) DEFAULT '0' NOT NULL
);


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



/**End C:\PDM_UPGRADE\PDM1\SRC_table.sql **/
