我真的在这里挣扎。我在VBA中构建一个查询,以链接到Oracle内部和Access内部的几个表。我需要确保我上传到Oracle的内容匹配Access数据库中的内容。
我有:
如果源字段2为空,我想忽略它而不加入它。我这样做的最好方法是尝试使用Nz并替换为SourceField1。
strSQL = "INSERT INTO ERROR_TABLE (ORACLE_FIELD, TRANSFORM_FIELD) SELECT " & MatchValues!ORACLE_TABLE_NAME & "." & MatchValues!FieldName & ", " & MatchValues!TRANSFORM_TABLE_NAME & "." & MatchValues!FieldName
strSQL = strSQL & " FROM " & MatchValues!TRANSFORM_TABLE_NAME & " INNER JOIN " & MatchValues!xfTableName
strSQL = strSQL & " ON " & MatchValues!TRANSFORM_TABLE_NAME & "." & MatchValues!SourceField1 & " = " & MatchValues!xfTableName & "." & MatchValues!ReferenceField1 & ""
strSQL = strSQL & " AND " & MatchValues!TRANSFORM_TABLE_NAME & ".Nz(" & MatchValues!SourceField2 & "," & MatchValues!SourceField1 & ") = " & MatchValues!xfTableName & ".Nz(" & MatchValues!ReferenceField2 & "," & MatchValues!ReferenceField1 & ")"
strSQL = strSQL & " INNER JOIN " & MatchValues!ORACLE_TABLE_NAME & " ON (" & MatchValues!xfTableName
strSQL = strSQL & ".KEYVAL = " & MatchValues!ORACLE_TABLE_NAME & ".KEYVAL)"
strSQL = strSQL & " WHERE (" & MatchValues!TRANSFORM_TABLE_NAME & "." & MatchValues!FieldName
strSQL = strSQL & " <> " & MatchValues!ORACLE_TABLE_NAME & "." & MatchValues!FieldName & ")"
这给了我这个:
INSERT INTO ERROR_TABLE(ORACLE_FIELD,TRANSFORM_FIELD)SELECT UNI73MART1_DCappl.DECSN,tbluniDCappl.DECSN FROM tbluniDCappl INNER JOIN XF_DC_ref ON tbluniDCappl.REFVAL = XF_DC_ref.REFVAL AND tbluniDCappl.Nz(,REFVAL)= XF_DC_ref.Nz(,REFVAL)INNER JOIN UNI73MART1_DCappl ON(XF_DC_ref.KEYVAL = UNI73MART1_DCappl.KEYVAL)WHERE(tbluniDCappl.DECSN&lt;&gt; UNI73MART1_DCappl.DECSN)