CFTransaction/CFCatch/CFTry
I have an insert query that parses a large text file into a query object and then loops through it and inserts it into a data table.
However sometimes there are bad values are in the text file...like a text value where a date should be etc. or a nonnumeric value where a numeric should be..... This causes the loo/ insert query to STOP.
If I get all good values I want the data to be inserted and have processing continue.
However If I get a bad value in the file I want all processing to stop and all of the prior inserted rows to be deleted and I want to get an error message emailed to me
How do I do this?
Here is the Cfloop and the insert query below..again the problem is that if I get a bad value I want processing to stop and the data table to rollback to the initial state prior to any processing.....and I want an email alerting me there was an issue ( I know how to use CFMAIL)
<cftransaction>
<cfloop query="stocks">
<CFQUERY name="load_the_data" datasource="abc" >
INSERT INTO portfolios_new (portfolio , portfolio_ID , load_date , ticker , cusip,BC1, BC1_ID , BC2 , BC2_ID , BC3 , BC3_ID, Load_ID)
VALUES ('#Portfolio#'
,'#PORTFOLIOID#','#loadDate#','#Ticker#','#Cusip#','#BC1#','#BC1Id#','#BC2#','#BC2Id#','#BC3#','#BC3Id#', '#next_load_id#' );
</CFQUERY>
</cfloop>
</cftransaction>
