from src.db.database import Database
from src.error.exceptions import BatchOperationException
from src.logging.get_logger import get_logger

logger = get_logger('洗替用マスタ作成')


def exec():
    db = Database.get_instance()

    try:
        db.connect()

        logger.debug('処理開始')
        call_v_inst_merge_t_create(db)
        call_inst_merge_t_create(db)
        logger.debug('処理終了')
    except Exception as e:
        raise BatchOperationException(e)
    finally:
        db.disconnect()


def call_v_inst_merge_t_create(db: Database):
    db.execute('CALL src05.v_inst_merge_t_create()')
    return


def call_inst_merge_t_create(db: Database):
    db.execute('CALL src05.inst_merge_t_create()')
    return
