I need to insert into an access database. But skip the row if column dup is already in the table.
What I have so far is this:
<cfoutput query="hours">
<cfquery name="Employee" datasource="test">
INSERT INTO Tbl_Hours_Comments
(ID, ship_num, dup)
values(#hours.id#, #hours.ship#, #hours.dup#)
</cfquery>
</cfoutput>
If I don't make dup a Primary Key. Then it will INSERT duplicates. If I make dup a Primary Key. Then I get an error.
I think I need something like MySQL. ON DUPLICATE KEY UPDATE.
Or maybe dup_val_on_index exception handling like in Oracle.
@Gord Thompson
I tried (Not sure if I'm doing it right):
<cfoutput query="hours">
<cfquery name="Insert_Employee" datasource="trung">
INSERT Tbl_Hours_Comments (ID, ship_num, dup)
values(#hours.id#, #hours.ship#, #hours.dup#)
SELECT ? as dup
FROM( SELECT COUNT(*) as n from Tbl_Hours_Comments) as Dual
WHERE NOT EXISTS
( SELECT *
FROM Tbl_Hours_Comments
WHERE dup = ?
)
</cfquery>
</cfoutput>
But I get [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect .
What are the ? in your select statement?