/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\PUR_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_INQUIRYTURNS') 
 CREATE TABLE T_PUR_INQUIRYTURNS (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FTURNS CHAR(1) DEFAULT ' ' NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_INQUIRYTURNSLOG') 
 CREATE TABLE T_PUR_INQUIRYTURNSLOG (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FTURNS CHAR(1) DEFAULT ' ' NOT NULL,
FHANDLERID BIGINT DEFAULT 0 NOT NULL,
FHANDLETIME DATETIME,
FNOTE NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_COMPARENTRY_A' AND KSQL_COL_NAME ='FQUOTE6') 
 ALTER TABLE T_PUR_COMPARENTRY_A ADD (FQUOTE6 DECIMAL(19,6) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_COMPARENTRY_A' AND KSQL_COL_NAME ='FQUOTE7') 
 ALTER TABLE T_PUR_COMPARENTRY_A ADD (FQUOTE7 DECIMAL(19,6) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_COMPARENTRY_A' AND KSQL_COL_NAME ='FQUOTE8') 
 ALTER TABLE T_PUR_COMPARENTRY_A ADD (FQUOTE8 DECIMAL(19,6) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INQUIRY' AND KSQL_COL_NAME ='FTURNS') 
 ALTER TABLE T_PUR_INQUIRY ADD (FTURNS CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INQUIRY' AND KSQL_COL_NAME ='FSUPQUONUM') 
 ALTER TABLE T_PUR_INQUIRY ADD (FSUPQUONUM INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_QUOTE' AND KSQL_COL_NAME ='FTURNS') 
 ALTER TABLE T_PUR_QUOTE ADD (FTURNS CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_COMPARQUOENTRY' AND KSQL_COL_NAME ='FQUOBILLNO') 
 ALTER TABLE T_PUR_COMPARQUOENTRY ADD (FQUOBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL );

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