/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\GL_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AI_BASEFIELDMAPENTRY') 
 CREATE TABLE T_AI_BASEFIELDMAPENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FDATATYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FFIELDNAME VARCHAR(100) DEFAULT ' ' NOT NULL,
FFIELDKEY VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FSRCDATAMAPPING0') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FSRCDATAMAPPING0 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FSRCDATAMAPPING1') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FSRCDATAMAPPING1 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FSRCDATAMAPPING2') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FSRCDATAMAPPING2 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FSRCDATAMAPPING3') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FSRCDATAMAPPING3 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FSRCDATAMAPPING4') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FSRCDATAMAPPING4 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FSRCDATAMAPPING5') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FSRCDATAMAPPING5 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FSRCDATAMAPPING6') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FSRCDATAMAPPING6 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FSRCDATAMAPPING7') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FSRCDATAMAPPING7 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FSRCDATAMAPPING8') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FSRCDATAMAPPING8 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FSRCDATAMAPPING9') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FSRCDATAMAPPING9 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FASSISTSOUCE0') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FASSISTSOUCE0 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FASSISTSOUCE1') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FASSISTSOUCE1 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FASSISTSOUCE2') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FASSISTSOUCE2 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FASSISTSOUCE3') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FASSISTSOUCE3 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FASSISTSOUCE4') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FASSISTSOUCE4 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FASSISTSOUCE5') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FASSISTSOUCE5 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FASSISTSOUCE6') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FASSISTSOUCE6 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FASSISTSOUCE7') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FASSISTSOUCE7 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FASSISTSOUCE8') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FASSISTSOUCE8 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FASSISTSOUCE9') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FASSISTSOUCE9 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPINGENTRY' AND KSQL_COL_NAME ='FBDINFOIMPORT') 
 ALTER TABLE T_AI_BASEDATAMAPPINGENTRY ADD (FBDINFOIMPORT VARCHAR(1000) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPING' AND KSQL_COL_NAME ='FFACTORVALUE') 
 ALTER TABLE T_AI_BASEDATAMAPPING ADD (FFACTORVALUE VARCHAR(250) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPING' AND KSQL_COL_NAME ='FFACTORNAME') 
 ALTER TABLE T_AI_BASEDATAMAPPING ADD (FFACTORNAME VARCHAR(250) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPING' AND KSQL_COL_NAME ='FFACTORVALUE_BASE') 
 ALTER TABLE T_AI_BASEDATAMAPPING ADD (FFACTORVALUE_BASE VARCHAR(250) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AI_BASEDATAMAPPING' AND KSQL_COL_NAME ='FFACTORVALUE_ASST') 
 ALTER TABLE T_AI_BASEDATAMAPPING ADD (FFACTORVALUE_ASST VARCHAR(250) DEFAULT ' ' NOT NULL );

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

/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\GL_constraint.sql **/

 EXEC P_ALTERPK 'PK_T_AI_BASEFIELDMAPENTRY', 'T_AI_BASEFIELDMAPENTRY', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_AI_BASEFIELD_FID') CREATE INDEX IDX_AI_BASEFIELD_FID ON T_AI_BASEFIELDMAPENTRY ( FID );



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





