# -*- coding: utf-8 -*-
from ppms.migration.packet import *

class FixSQLSkript00401(ChangeDTPPacket):
    '''Fix SQL Skript 00401 for MS-SQL Databases'''
    version = 1
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 11989

    def fix(self, runner):
        NEW_VAL = '''UPDATE DT354 SET DI025544='a' where DI025544='a' '''
        sql_procedure_id = '000401'
        sql_counter = '000004' #mssql

        record = self.get_record(343, [sql_counter, sql_procedure_id], [40109])
        record.source_text_clob.set_value(NEW_VAL)
        record.save()
        if not self.verify_value(record, 'source_text_clob', NEW_VAL):
            return self.fail()

        return self.success()
