이것은 MS Access 데이터베이스와 관련이 있습니다.SQL 변수 - MS 액세스
나는 T-SQL에서 변수를 정의하는 것이 가능하다는 것을 알고 있지만 MS Access에서 어떻게 작동합니까?
아래의 VBA 스크립트와 동일한 방법으로 SQL의 변수에 값을 할당 할 수 있습니까?
strErrorDescription = strErrorDescription & " " & strErrorDescription2 & " " & strErrorDescription3
strTableName = "tblStagingGL_SS04"
strLogTableName = "tblLogGL_SS04"
Set rs = db.OpenRecordset(strTableName)
Set rs2 = db.OpenRecordset(strLogTableName)
rs.MoveFirst
Do Until rs.EOF
'Verifies that the GL_Number only contains numbers
If rs.Fields(2).Value Like "*[!0-9]*" Then
strErrorDescription = "Error on GL_Number"
End If
'Verifies that the Currency is made of 3 numbers only
If Not rs.Fields(6).Value Like "[A-Z][A-Z][A-Z]" Then
strErrorDescription2 = "Error on Currency"
End If
'Verifies that the Rate does not contain letters
If rs.Fields(10).Value Like "*[A-Z]*" Then
strErrorDescription3 = "Error on rate"
End If
strErrorDescription = strErrorDescription & " " & strErrorDescription2 & " " & strErrorDescription3
'If an Error has been caught, create a record with the associated information in the Log table
If strErrorDescription <> " " Then
rs2.AddNew
rs2.Fields(1).Value = rs.Fields(2).Value
rs2.Fields(2) = rs.Fields(7)
rs2.Fields(3) = strErrorDescription
rs2.Update
End If
strErrorDescription = ""
strErrorDescription2 = ""
strErrorDescription3 = ""
rs.MoveNext
Loop
MS Access에 대해 많이 알지는 못하지만이 경우 저장 프로 시저를 사용해야합니다. 또한, 'rs.Fields (6) .Value Like [A-Z] [A-Z] [A-Z]'Then '는 일지 여부에 따라 대문자 만 검사합니다. – HoneyBadger
MS Access에는 저장 프로 시저가 없습니다 ... – ProtoVB
@ProtoVB 저장 프로 시저를 실행하기 위해 Access에서 통과 쿼리를 만들 수 있습니다 –