I want check two fields if duplicated or not before insert record, I use custom trigger as shown in addt documentation like that:
<%
'start Trigger_Custom trigger
Function Trigger_Custom (ByRef tNG)
'Trigger that checks if two combined fields are unique
Dim centrl
Dim tel
Dim query
centrl = tNG.getColumnValue("centrlID")
tel = tNG.getColumnValue("phoneNO")
query = "SELECT * FROM phone_services where centrlID = " & KT_escapeForSql(centrl,tNG.getColumnType("centrlID")) & " AND phoneNO = " & KT_escapeForSql(tel,tNG.getColumnType("phoneNO"))
on Error Resume Next
set check_result = tNG.connection.Execute(query)
If Err.Number <>0 Then
Set check_failure = new tNG_error
check_failure.init "Could not access database!", Array(), Array()
Set Trigger_Custom = check_failure
Else
if(check_result.recordCount() <>0 ) Then
Set not_unique = new tNG_error
not_unique.init "A message with the same subject and content already exist. You cannot enter duplicates", Array(), Array()
Set Trigger_Custom = not_unique
else
Set Trigger_Custom = nothing
end if
end if
On Error GoTo 0
End Function
'end Trigger_Custom trigger
%>
But that code returns that error always:
Error:
A message with the same subject and content already exist. You cannot enter duplicates
any hepl please. many thanks.