« first day (1883 days earlier)      last day (775 days later) » 

12:14 AM
Hi There, I need some help on stored procedure in mysql. I have a table where I update data every day (REPLACE INTO). Every time when I update data I need to validated a field which have tax_id(gst number) and store failed validation data in another table to generate a report. I created a SP which accepts a gst number and returns true or false but how I can do it for each row.I am new to SP.
 
 
15 hours later…
3:31 PM
@JayaVishwakarma Perhaps you want to create a function instead of a procedure? dev.mysql.com/doc/refman/5.7/en/create-procedure.html
Be aware though, that will make for a very slow REPLACE INTO query.
 
 
6 hours later…
9:50 PM
Thanks @TehShrike, yes you are correct, Heidi converted automatically to function when I returned something. purpose of creating this function is to collect data for generating a report every month. I have 7 different thing to do when I update data (eg duplicate, any change and validation on 2 fields and any new data added). I have a backup table created before updating new data to compare for changed, duplicates and any new data which seems fine but I am struggling with adding validation.
 
what do you need to validate?
 
gst number and bank account number
we accept only NZ and AUS
 
@JayaVishwakarma do you need to run any queries in order to validate those numbers?
 
@TehShrike, Yes because they are in a table and I need to store those records in a table which didn't passed validation. I hope this make sense.
 
@JayaVishwakarma ah, then it will be very slow to run the validation for a bunch of rows
There's no way to validate the data when you're inserting it to prevent validating later?
 
9:59 PM
@TehShrike, Ok so better I should use a PHP function instead?
 
@JayaVishwakarma only if you can write it in PHP so that you can validate a bunch of records at once. As long as you're running a query for every individual row you're validating, it will be as slow in PHP (probably slower)
 
 
1 hour later…
11:18 PM
@TehShrike, I don't need to prevent any data from inserting, just need to identify invalid ones and insert in a table to use them later, so will just get them all in ones and check for those in a loop.
 

« first day (1883 days earlier)      last day (775 days later) »