[Solved] Database Errror handling
Posted
#1
(In Topic #1387)
Enthusiast

Could someone please point me in the correct direction so I can sort my issue out.
My Issue is I am not sure how I handle errors coming from the database (example would be duplicate record inserts)
At the moment i am importing some data from a customer into a MySQL database and I have a few duplicated files but I can not figure out
how I can send the duplicated barcode number to another file and then move onto the next import
I known it is a duplicate as MySQL database has the primary set on the barcode and this is also set to not allow duplicate information
I would like to know if it is possible to capture this error and handle it gracefully and not have my entire app crash.
Kind regards to you all
Andy
Posted
Expert

<LIST>
- <LI>Read each record in</LI>
<LIST>
- <LI>Check it for an existing duplicate. (with the provided subroutine)</LI>
<LIST>
- <LI>On Exit then:
<LIST>- <LI>Update Duplicate Counter</LI>
<LIST>- <LI>Write the duplicate record to a log file.</LI>
<LIST>
- <LI>NOT exit then add new record</LI>
The program flow would flow would be to check for a duplicate record by passing the input barcode to the subroutine.
If it returns zero then update you new record.
If it is non-zero then increment your duplicate counter and write to a log file to review later as required.
Process the next record or end.
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Enthusiast

Quincunxian said
This will depend on how many records you process. I've made the subroutine as brief as possible but it will have an effect on performance, but essentially:
<LIST></LIST>
- <LI>Read each record in</LI>
<LIST></LIST>
- <LI>Check it for an existing duplicate. (with the provided subroutine)</LI>
<LIST></LIST>
- <LI>On Exit then:
<LIST></LIST>
- <LI>Update Duplicate Counter</LI>
<LIST></LIST></LI>
- <LI>Write the duplicate record to a log file.</LI>
<LIST></LIST>
- <LI>NOT exit then add new record</LI>
The program flow would flow would be to check for a duplicate record by passing the input barcode to the subroutine.
If it returns zero then update you new record.
If it is non-zero then increment your duplicate counter and write to a log file to review later as required.
Process the next record or end.
Hi Quincunxian,
Thank For this subroutine I have added it to my import functions and it has worked a treat.
1 guest and 0 members have just viewed this.



