Deploy Data Standards Check Tool v1.34_20221215

When running a standard check using VARCHAR(MAX) in MS-SQL Server, I get a "type mismatch" error. Distribute data standard inspection tool v1.34_20221215 that solved this error.

Data standard inspection tool_2.1. Screen composition, 2.2. Standard inspection function – Productivity Skill (prodskill.com)

The following comments were posted to this post:

데이터 표준점검 도구 버그 내용 댓글
Data Standards Check Tool Bug Content Comments

1. Phenomenon

When attempting to standard-check attributes of VARCHAR(MAX) format in Data Standard-Check Tool v1.33,

데이터 표준점검 도구 v1.33에서 VARCHAR(MAX) 형식의 속성 표준 점검 시도
Attempting attribute standard checking of VARCHAR(MAX) format in Data Standard Checking Tool v1.33

As in “A runtime error '13' has occurred: Type mismatch.” An error occurs.

"'13' 런타임 오류가 발생하였습니다.: 형식이 일치하지 않습니다." 오류 발생
“A runtime error '13' has occurred: type mismatch.” error occurred

2. Cause

Assuming that the length specified in the Data Type of the property is an integer type (eg, 10, 100, etc.), a value is assigned to an integer type variable in the VBA code. “MAX” is an error that occurs because it is not an integer type.

Below is the Load procedure source of CStdDomainDic class. The error occurs on line 19 of the code.

'CStdDomainDic
Public Sub Load(aBaseRange As Range)
    Dim oStdDomain As CStdDomain
    Dim lRow As Long

    '목록에 아무 값이 없는 경우 exit
    If Trim(aBaseRange.Offset(1, 0)) = "" Then Exit Sub

    Dim vRngArr As Variant
    vRngArr = Range(aBaseRange, aBaseRange.End(xlDown)).Resize(, 8).Value2 '읽는 범위: 8개 컬럼

    For lRow = LBound(vRngArr) To UBound(vRngArr)
        Set oStdDomain = New CStdDomain
        With oStdDomain
            .m_s도메인분류명 = vRngArr(lRow, 1)
            .m_s도메인논리명 = vRngArr(lRow, 2)
            .m_s도메인물리명 = vRngArr(lRow, 3)
            .m_s도메인설명 = vRngArr(lRow, 4)
            .m_s데이터타입명 = vRngArr(lRow, 5)
            .m_i길이 = vRngArr(lRow, 6)  '<-- 여기에서 오류 발생
            .m_i정도 = vRngArr(lRow, 7)
            .m_s데이터타입길이명 = vRngArr(lRow, 8)
            '.m_s데이터타입길이명 = GetDataTypeStr(.m_s데이터타입명, .m_i길이, .m_i정도)
        End With

        Me.Add oStdDomain
    Next lRow
...
End Sub

3. Measures

As follows, the length value was changed to be assigned to other variables according to the data format, and the length of m_s, a character type variable, was used to compare the data length.

'CStdDomainDic
Public Sub Load(aBaseRange As Range)
    Dim oStdDomain As CStdDomain
    Dim lRow As Long

    '목록에 아무 값이 없는 경우 exit
    If Trim(aBaseRange.Offset(1, 0)) = "" Then Exit Sub

    Dim vRngArr As Variant
    vRngArr = Range(aBaseRange, aBaseRange.End(xlDown)).Resize(, 8).Value2 '읽는 범위: 8개 컬럼

    For lRow = LBound(vRngArr) To UBound(vRngArr)
        Set oStdDomain = New CStdDomain
        With oStdDomain
            .m_s도메인분류명 = vRngArr(lRow, 1)
            .m_s도메인논리명 = vRngArr(lRow, 2)
            .m_s도메인물리명 = vRngArr(lRow, 3)
            .m_s도메인설명 = vRngArr(lRow, 4)
            .m_s데이터타입명 = vRngArr(lRow, 5)
            If TypeName(vRngArr(lRow, 6)) = "String" Then '<-- 데이터 형식에 따라서 다른 변수에 길이 값 할당
                .m_s길이 = CStr(vRngArr(lRow, 6))
            Else
                .m_i길이 = vRngArr(lRow, 6)
            End If
            .m_i정도 = vRngArr(lRow, 7)
            .m_s데이터타입길이명 = vRngArr(lRow, 8)
            '.m_s데이터타입길이명 = GetDataTypeStr(.m_s데이터타입명, .m_i길이, .m_i정도)
        End With

        Me.Add oStdDomain
    Next lRow
...
End Sub

The code used to compare the data length of m_s length, a character type variable, is as follows. Lines 13 to 18 are the added codes.

'CStdDomainDic
'두 Domain의 TypeSize 비교결과 return
'aDomainAtt: 비교기준 Domain (속성지정 Type/Size)
'aDomainTgt: 비교대상 Domain (용어 또는 속성분류어 Type/Size)
Public Function GetCompareResult(aCompareType As String, _
            aDomainAtt As CStdDomain, aDomainTgt As CStdDomain) As String
    Dim sResult As String
    sResult = aCompareType + " Type/Size 비교 결과"
    If aDomainAtt.m_s데이터타입명 <> aDomainTgt.m_s데이터타입명 Then
        sResult = sResult + vbLf + "타입 불일치"
    End If
    
    If aDomainAtt.IsStringLength Or aDomainTgt.IsStringLength Then
        If UCase(aDomainAtt.m_s길이) <> UCase(aDomainTgt.m_s길이) Then
            sResult = sResult + vbLf + "길이 불일치"
        Else
            sResult = aCompareType + " Type/Size 일치"
        End If
    ElseIf aDomainAtt.m_i길이 <> aDomainTgt.m_i길이 Then
        sResult = sResult + vbLf + "길이 불일치"
        If aDomainAtt.m_i길이 > aDomainTgt.m_i길이 Then '속성의 Size가 더 큰 경우(도메인 추가 또는 속성 size 조정)
            sResult = sResult + "(감소! 도메인 추가 또는 속성 Size 조정 필요)"
        ElseIf aDomainAtt.m_i길이 < aDomainTgt.m_i길이 Then '비교 대상 Domain Size가 더 큰 경우(대부분은 문제없음)
            sResult = sResult + "(증가 확인)"
        End If
    ElseIf aDomainAtt.m_i정도 <> aDomainTgt.m_i정도 Then
        sResult = sResult + vbLf + "소수점 길이 불일치"
        If aDomainAtt.m_i정도 > aDomainTgt.m_i정도 Then '속성의 Size가 더 큰 경우(도메인 추가 또는 속성 size 조정)
            sResult = sResult + "(감소! 도메인 추가 또는 속성 Size 조정 필요)"
        ElseIf aDomainAtt.m_i정도 < aDomainTgt.m_i정도 Then '비교 대상 Domain Size가 더 큰 경우(대부분은 문제없음)
            sResult = sResult + "(증가 확인)"
        End If
    Else
        sResult = aCompareType + " Type/Size 일치"
    End If
    GetCompareResult = sResult
End Function

The check result is displayed without error as follows.

데이터 표준점검 도구 v1.34에서 VARCHAR(MAX) 형식의 속성 표준 점검 결과
Attribute standard check result of VARCHAR(MAX) format in Data Standard Check Tool v1.34

4. Download Data Standard Check Tool v1.34_20221215

The patch version has been uploaded to github and can be downloaded from the URL below.

https://github.com/DAToolset/ToolsForDataStandard/raw/main/속성%20표준점검%20도구_v1.34_20221215_1.xlsm

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEnglish