Catching database errors (e.g duplicate key)

batvink 14 Feb, 2016
Hi,

I want to confirm this is the correct process, before I implement it. It is possible for my users to enter values in a form that will result in a duplicate record in the database. (I have an auto-increment field, but field 'name' must also be unique).

This will produce an SQL error when the form is submitted. I need to catch this error. My process will be:

[list]Press submit
Perform a database read based on name field (to an external database)
If found, generate an error and run the event loop.
If not found, continue
Perform a database save.
[/list]

Thanks for any confirmation or alternative process to do this.
GreyHead 15 Feb, 2016
Hi batvink,

Yes, that looks correct.

Bob
batvink 16 Feb, 2016
Thanks🙂
This topic is locked and no more replies can be posted.