handle mySQL unique constraint error and remove row

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
swiftinitpvtltd
Posts: 370
Joined: Sat Apr 28, 2018 3:33 am
Location: India
Contact:

handle mySQL unique constraint error and remove row

Post by swiftinitpvtltd »

I have a bulk edit grid with multiple dropdown. I also have mysql unique constraint(safest way to handle duplicate).
Now once aware IM throws unique constraint error for duplicate as user selected same drop downs for product and customer and date for example(unique key set for product and customer and date) how do I remove a row after error is thrown? Is there way in aware to handle mysql error and then handle it to remove row or customize that popup message that came from db?
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: handle mySQL unique constraint error and remove row

Post by PointsWell »

swiftinitpvtltd wrote:I have a bulk edit grid with multiple dropdown. I also have mysql unique constraint(safest way to handle duplicate).
Now once aware IM throws unique constraint error for duplicate as user selected same drop downs for product and customer and date for example(unique key set for product and customer and date) how do I remove a row after error is thrown? Is there way in aware to handle mysql error and then handle it to remove row or customize that popup message that came from db?
IS there a reason why you haven't used a business rule to check uniqueness? That would handle AIM duplicates.

IF EXISTS BO WHERE BO.attributeToBeChecked=ThisBO.attributeToBeChecked AND BO.ID <> ThisBO.ID THEN REPORT ERROR'This record exists already. Duplicates are not allowed'

Prevents it being written to the database and you don't have to trap MySQL errors.
swiftinitpvtltd
Posts: 370
Joined: Sat Apr 28, 2018 3:33 am
Location: India
Contact:

Re: handle mySQL unique constraint error and remove row

Post by swiftinitpvtltd »

Thanks for asking.
IF EXISTS BO WHERE BO.attributeToBeChecked=ThisBO.attributeToBeChecked AND BO.ID <> ThisBO.ID THEN REPORT ERROR'This record exists already. Duplicates are not allowed'
This somehow not working properly in Bulk edit with multiple dropdowns. It's because of this and that BO issue.
Once validated if you change the dropdown it still again invalidates may be because of this and that...
Post Reply