/**Begin C:\PDM_UPGRADE\PDM1\SRC_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_APPLYENTRY' AND KSQL_COL_NAME IN ('FISCONTROLQTY')) 
 ALTER TABLE T_SRC_APPLYENTRY ADD (FISCONTROLQTY CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_APPLYENTRY' AND KSQL_COL_NAME IN ('FAUXPTYID')) 
 ALTER TABLE T_SRC_APPLYENTRY ADD (FAUXPTYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_APPLYENTRY' AND KSQL_COL_NAME IN ('FMINIORDERQTY')) 
 ALTER TABLE T_SRC_APPLYENTRY ADD (FMINIORDERQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_APPLYENTRY' AND KSQL_COL_NAME IN ('FMINIPACKQTY')) 
 ALTER TABLE T_SRC_APPLYENTRY ADD (FMINIPACKQTY 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 ('FISCONTROLQTY')) 
 ALTER TABLE T_SRC_PURLISTENTRY ADD (FISCONTROLQTY CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PURLISTENTRY' AND KSQL_COL_NAME IN ('FAUXPTYID')) 
 ALTER TABLE T_SRC_PURLISTENTRY ADD (FAUXPTYID 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 ('FVIERATIO')) 
 ALTER TABLE T_SRC_VIE_DETAIL ADD (FVIERATIO 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 ('FVIEDIFFER')) 
 ALTER TABLE T_SRC_VIE_DETAIL ADD (FVIEDIFFER 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 ('FVIEFROM')) 
 ALTER TABLE T_SRC_VIE_DETAIL ADD (FVIEFROM 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 ('FVIETO')) 
 ALTER TABLE T_SRC_VIE_DETAIL ADD (FVIETO DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_NOTYEARINFO' AND KSQL_COL_NAME IN ('FMINIORDERQTY')) 
 ALTER TABLE T_SRC_NOTYEARINFO ADD (FMINIORDERQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_NOTYEARINFO' AND KSQL_COL_NAME IN ('FISCONTROLQTY')) 
 ALTER TABLE T_SRC_NOTYEARINFO ADD (FISCONTROLQTY CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_NOTYEARINFO' AND KSQL_COL_NAME IN ('FAUXPTYID')) 
 ALTER TABLE T_SRC_NOTYEARINFO ADD (FAUXPTYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_NOTYEARINFO' AND KSQL_COL_NAME IN ('FMINIPACKQTY')) 
 ALTER TABLE T_SRC_NOTYEARINFO ADD (FMINIPACKQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_O' AND KSQL_COL_NAME IN ('FMONTHNUM')) 
 ALTER TABLE T_SRC_PROJECT_O ADD (FMONTHNUM INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_O' AND KSQL_COL_NAME IN ('FVIEPATTERN')) 
 ALTER TABLE T_SRC_PROJECT_O ADD (FVIEPATTERN CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PROJECT_Y' AND KSQL_COL_NAME IN ('FISARCHIVED')) 
 ALTER TABLE T_SRC_PROJECT_Y ADD (FISARCHIVED CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_EXPORT' AND KSQL_COL_NAME IN ('FCITYID')) 
 ALTER TABLE T_SRC_EXPORT ADD (FCITYID 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 ('FISCONTROLQTY')) 
 ALTER TABLE T_SRC_CONTRACTENTRY_A ADD (FISCONTROLQTY CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_CONTRACTENTRY_A' AND KSQL_COL_NAME IN ('FMINIORDERQTY')) 
 ALTER TABLE T_SRC_CONTRACTENTRY_A ADD (FMINIORDERQTY 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 ('FAUXPTYID')) 
 ALTER TABLE T_SRC_CONTRACTENTRY_A ADD (FAUXPTYID 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 ('FMINIPACKQTY')) 
 ALTER TABLE T_SRC_CONTRACTENTRY_A ADD (FMINIPACKQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_ARCHIVEFILE' AND KSQL_COL_NAME IN ('FFILEURL')) 
 ALTER TABLE T_SRC_ARCHIVEFILE ADD (FFILEURL NVARCHAR(500) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_EXPORTSUPPLIER') 
 CREATE TABLE T_SRC_EXPORTSUPPLIER (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSUPPLIERNOTE VARCHAR(510) DEFAULT ' ' NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_EXPSCHEMEFIELDS') 
 CREATE TABLE T_SRC_EXPSCHEMEFIELDS (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FQUERYFIELD VARCHAR(50) DEFAULT ' ' NOT NULL,
FVALUEFIELD VARCHAR(50) DEFAULT ' ' NOT NULL,
FFIELDTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FNOTE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FMATCHTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTRYENABLE CHAR(1) DEFAULT '0' NOT NULL,
FQUERYFIELDTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FVALUEFIELDTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_SUPSCHEMEFIELDS') 
 CREATE TABLE T_SRC_SUPSCHEMEFIELDS (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FQUERYFIELD VARCHAR(50) DEFAULT ' ' NOT NULL,
FVALUEFIELD VARCHAR(50) DEFAULT ' ' NOT NULL,
FFIELDTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FFIELDNOTE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FMATCHTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTRYENABLE CHAR(1) DEFAULT '0' NOT NULL,
FQUERYFIELDTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FVALUEFIELDTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL
);



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