/**Begin D:\nextcloud\dev2main2bizline\PDM_UPGRADE\pdm1\kd_1.5.52_im_table.sql.sql **/
 EXEC p_AlterColumn 'T_IM_OTHERINBILLENTRY', 'FENTRYCOMMENT', 'VARCHAR(512)', 'NOT NULL', '0010', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHERINBILLENTRY' AND KSQL_COL_NAME IN ('FOUTINVTYPEID')) 
 ALTER TABLE T_IM_OTHERINBILLENTRY ADD (FOUTINVTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHERINBILLENTRY' AND KSQL_COL_NAME IN ('FOUTINVSTATUSID')) 
 ALTER TABLE T_IM_OTHERINBILLENTRY ADD (FOUTINVSTATUSID BIGINT DEFAULT 0 NOT NULL );
 EXEC p_AlterColumn 'T_IM_OTHEROUTBILLENTRY', 'FENTRYCOMMENT', 'VARCHAR(512)', 'NOT NULL', '0010', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHEROUTBILLENTRY' AND KSQL_COL_NAME IN ('FOUTINVTYPEID')) 
 ALTER TABLE T_IM_OTHEROUTBILLENTRY ADD (FOUTINVTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OTHEROUTBILLENTRY' AND KSQL_COL_NAME IN ('FOUTINVSTATUSID')) 
 ALTER TABLE T_IM_OTHEROUTBILLENTRY ADD (FOUTINVSTATUSID BIGINT DEFAULT 0 NOT NULL );
 EXEC p_AlterColumn 'T_IM_TYPEADJUSTENTRY', 'FENTRYCOMMENT', 'VARCHAR(512)', 'NOT NULL', '0010', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TYPEADJUSTENTRY' AND KSQL_COL_NAME IN ('FOUTINVTYPEID')) 
 ALTER TABLE T_IM_TYPEADJUSTENTRY ADD (FOUTINVTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TYPEADJUSTENTRY' AND KSQL_COL_NAME IN ('FOUTINVSTATUSID')) 
 ALTER TABLE T_IM_TYPEADJUSTENTRY ADD (FOUTINVSTATUSID BIGINT DEFAULT 0 NOT NULL );
 EXEC p_AlterColumn 'T_IM_STATUSADJUSTENTRY', 'FENTRYCOMMENT', 'VARCHAR(512)', 'NOT NULL', '0010', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_STATUSADJUSTENTRY' AND KSQL_COL_NAME IN ('FOUTINVTYPEID')) 
 ALTER TABLE T_IM_STATUSADJUSTENTRY ADD (FOUTINVTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_STATUSADJUSTENTRY' AND KSQL_COL_NAME IN ('FOUTINVSTATUSID')) 
 ALTER TABLE T_IM_STATUSADJUSTENTRY ADD (FOUTINVSTATUSID BIGINT DEFAULT 0 NOT NULL );
 EXEC p_AlterColumn 'T_IM_INITBILLENTRY', 'FENTRYCOMMENT', 'VARCHAR(512)', 'NOT NULL', '0010', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INITBILLENTRY' AND KSQL_COL_NAME IN ('FOUTINVTYPEID')) 
 ALTER TABLE T_IM_INITBILLENTRY ADD (FOUTINVTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_INITBILLENTRY' AND KSQL_COL_NAME IN ('FOUTINVSTATUSID')) 
 ALTER TABLE T_IM_INITBILLENTRY ADD (FOUTINVSTATUSID BIGINT DEFAULT 0 NOT NULL );
 EXEC p_AlterColumn 'T_IM_SALOUTBILLENTRY', 'FENTRYCOMMENT', 'VARCHAR(512)', 'NOT NULL', '0010', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_SALOUTBILLENTRY' AND KSQL_COL_NAME IN ('FOUTINVTYPEID')) 
 ALTER TABLE T_IM_SALOUTBILLENTRY ADD (FOUTINVTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_SALOUTBILLENTRY' AND KSQL_COL_NAME IN ('FOUTINVSTATUSID')) 
 ALTER TABLE T_IM_SALOUTBILLENTRY ADD (FOUTINVSTATUSID BIGINT DEFAULT 0 NOT NULL );
 EXEC p_AlterColumn 'T_IM_PURRECBILLENTRY', 'FENTRYCOMMENT', 'VARCHAR(512)', 'NOT NULL', '0010', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_D' AND KSQL_COL_NAME IN ('FOUTINVTYPEID')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_D ADD (FOUTINVTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_PURRECBILLENTRY_D' AND KSQL_COL_NAME IN ('FOUTINVSTATUSID')) 
 ALTER TABLE T_IM_PURRECBILLENTRY_D ADD (FOUTINVSTATUSID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSOUTBILLENTRY_X' AND KSQL_COL_NAME IN ('FOUTINVTYPEID')) 
 ALTER TABLE T_IM_TRANSOUTBILLENTRY_X ADD (FOUTINVTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSOUTBILLENTRY_X' AND KSQL_COL_NAME IN ('FOUTINVSTATUSID')) 
 ALTER TABLE T_IM_TRANSOUTBILLENTRY_X ADD (FOUTINVSTATUSID BIGINT DEFAULT 0 NOT NULL );
 EXEC p_AlterColumn 'T_IM_DEFICITBILLENTRY', 'FENTRYCOMMENT', 'VARCHAR(512)', 'NOT NULL', '0010', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_DEFICITBILLENTRY' AND KSQL_COL_NAME IN ('FOUTINVTYPEID')) 
 ALTER TABLE T_IM_DEFICITBILLENTRY ADD (FOUTINVTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_DEFICITBILLENTRY' AND KSQL_COL_NAME IN ('FOUTINVSTATUSID')) 
 ALTER TABLE T_IM_DEFICITBILLENTRY ADD (FOUTINVSTATUSID BIGINT DEFAULT 0 NOT NULL );
 EXEC p_AlterColumn 'T_IM_SURPLUSBILLENTRY', 'FENTRYCOMMENT', 'VARCHAR(512)', 'NOT NULL', '0010', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_SURPLUSBILLENTRY' AND KSQL_COL_NAME IN ('FOUTINVTYPEID')) 
 ALTER TABLE T_IM_SURPLUSBILLENTRY ADD (FOUTINVTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_SURPLUSBILLENTRY' AND KSQL_COL_NAME IN ('FOUTINVSTATUSID')) 
 ALTER TABLE T_IM_SURPLUSBILLENTRY ADD (FOUTINVSTATUSID BIGINT DEFAULT 0 NOT NULL );
 EXEC p_AlterColumn 'T_IM_LOTADJUSTENTRY', 'FENTRYCOMMENT', 'VARCHAR(512)', 'NOT NULL', '0010', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_LOTADJUSTENTRY' AND KSQL_COL_NAME IN ('FOUTINVTYPEID')) 
 ALTER TABLE T_IM_LOTADJUSTENTRY ADD (FOUTINVTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_LOTADJUSTENTRY' AND KSQL_COL_NAME IN ('FOUTINVSTATUSID')) 
 ALTER TABLE T_IM_LOTADJUSTENTRY ADD (FOUTINVSTATUSID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSDIRBILLENTRY' AND KSQL_COL_NAME IN ('FOUTINVTYPEID')) 
 ALTER TABLE T_IM_TRANSDIRBILLENTRY ADD (FOUTINVTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_TRANSDIRBILLENTRY' AND KSQL_COL_NAME IN ('FOUTINVSTATUSID')) 
 ALTER TABLE T_IM_TRANSDIRBILLENTRY ADD (FOUTINVSTATUSID BIGINT DEFAULT 0 NOT NULL );

/**End D:\nextcloud\dev2main2bizline\PDM_UPGRADE\pdm1\IM_table.sql **/
