Private Sub DupIDCheck()
On Error GoTo ErrorDupIDCheckGeneric
Dim lcSQLString As String
' ADO variables
Dim lcnnDupIDCheck As ADODB.Connection
Dim lcmdDupIDCheck As ADODB.Command
Dim lrsDupIDCheck As ADODB.Recordset
' Other variables
Dim lcQueryText As String
Dim llngDupIDCount As Long
' Initialize variables
Set lcnnDupIDCheck = New ADODB.Connection
Set lcmdDupIDCheck = New ADODB.Command
' Use the SAM to get the read-only claims string
lcSQLString = SAMInterface("ClaimsMonitor", "SQLRaw"
If lcSQLString <> "" Then
' This means a good connection string was returned here
' Connect to SQL
lcnnDupIDCheck.ConnectionString = lcSQLString
On Error GoTo ErrorDupIDCheckOpenConnect
lcnnDupIDCheck.Open
On Error GoTo ErrorDupIDCheckGeneric
' Execute the queries
Set lcmdDupIDCheck.ActiveConnection = lcnnDupIDCheck
lcQueryText = SAMInterface("ClaimsMonitor", "CCAPBRRSQueryText"
If lcQueryText <> "" Then
' This means the query text was populated with something
lcmdDupIDCheck.CommandText = lcQueryText
On Error GoTo ErrorDupIDCheckExecute
Set lrsDupIDCheck = lcmdDupIDCheck.Execute
On Error GoTo ErrorDupIDCheckGeneric
' Examine the results
???? The CCAPBRRSQueryText is query looks like this:
SELECT GIS_ID FROM CCAPBRRS GROUP BY GIS_ID HAVING COUNT(GIS_ID) > 1
Why lrsDupIDCheck.RecordCount is always -1 even when there is a dupid? What am I doing wrong? There must be something missing here.... Thanks for your help.
If lrsDupIDCheck.RecordCount > 0 Then
AlertInterface -6001, "There are duplicate REG_ID on CCAPBRRS table. "
End If
Else
' The SQL query text was empty
Log "The CCAPBRRS query text was empty"
End If
lcQueryText = SAMInterface("ClaimsMonitor", "CCAPBRDIQueryText"
If lcQueryText <> "" Then
' This means the query text was populated with something
lcmdDupIDCheck.CommandText = lcQueryText
On Error GoTo ErrorDupIDCheckExecute
Set lrsDupIDCheck = lcmdDupIDCheck.Execute
On Error GoTo ErrorDupIDCheckGeneric
' Examine the results
If lrsDupIDCheck.RecordCount >= 0 Then
AlertInterface -6001, "There are duplicate REG_ID on CCAPBRDI table. "
End If
Else
' The SQL query text was empty
Log "The CCAPBRDI query text was empty"
End If
On Error GoTo ErrorDupIDCheckGeneric
Dim lcSQLString As String
' ADO variables
Dim lcnnDupIDCheck As ADODB.Connection
Dim lcmdDupIDCheck As ADODB.Command
Dim lrsDupIDCheck As ADODB.Recordset
' Other variables
Dim lcQueryText As String
Dim llngDupIDCount As Long
' Initialize variables
Set lcnnDupIDCheck = New ADODB.Connection
Set lcmdDupIDCheck = New ADODB.Command
' Use the SAM to get the read-only claims string
lcSQLString = SAMInterface("ClaimsMonitor", "SQLRaw"
If lcSQLString <> "" Then
' This means a good connection string was returned here
' Connect to SQL
lcnnDupIDCheck.ConnectionString = lcSQLString
On Error GoTo ErrorDupIDCheckOpenConnect
lcnnDupIDCheck.Open
On Error GoTo ErrorDupIDCheckGeneric
' Execute the queries
Set lcmdDupIDCheck.ActiveConnection = lcnnDupIDCheck
lcQueryText = SAMInterface("ClaimsMonitor", "CCAPBRRSQueryText"
If lcQueryText <> "" Then
' This means the query text was populated with something
lcmdDupIDCheck.CommandText = lcQueryText
On Error GoTo ErrorDupIDCheckExecute
Set lrsDupIDCheck = lcmdDupIDCheck.Execute
On Error GoTo ErrorDupIDCheckGeneric
' Examine the results
???? The CCAPBRRSQueryText is query looks like this:
SELECT GIS_ID FROM CCAPBRRS GROUP BY GIS_ID HAVING COUNT(GIS_ID) > 1
Why lrsDupIDCheck.RecordCount is always -1 even when there is a dupid? What am I doing wrong? There must be something missing here.... Thanks for your help.
If lrsDupIDCheck.RecordCount > 0 Then
AlertInterface -6001, "There are duplicate REG_ID on CCAPBRRS table. "
End If
Else
' The SQL query text was empty
Log "The CCAPBRRS query text was empty"
End If
lcQueryText = SAMInterface("ClaimsMonitor", "CCAPBRDIQueryText"
If lcQueryText <> "" Then
' This means the query text was populated with something
lcmdDupIDCheck.CommandText = lcQueryText
On Error GoTo ErrorDupIDCheckExecute
Set lrsDupIDCheck = lcmdDupIDCheck.Execute
On Error GoTo ErrorDupIDCheckGeneric
' Examine the results
If lrsDupIDCheck.RecordCount >= 0 Then
AlertInterface -6001, "There are duplicate REG_ID on CCAPBRDI table. "
End If
Else
' The SQL query text was empty
Log "The CCAPBRDI query text was empty"
End If