whow to capture SQL errors in Coldfusion
Posted on 2014-11-06
I have a bunch of queries which insert data into my SQL server and sometimes I get a duplicate record which
throws an error like this
Error Executing Database Query.[Macromedia][SQLServer JDBC Driver][SQLServer]Violation of PRIMARY KEY constraint 'PK_tbl_CNR_D'. Cannot insert duplicate key in object 'dbo.tbl_CNR_D'. The duplicate key value is (C2491035056, 01, 1428310095, ). The specific sequence of files included or processed is: C:\inetpub\wwwroot\parse.cfm, line: 452
how can I capture this in my code and act accordingly ?
I want to avoid to have to fire of a query to see if recordcount GT 0 to avoid this