Product consist of at least 1 or more articles. Nummer consist of 3-parts separated by dots (always). The one which always appears is always with .1 at the end (main article). For all articles belongs to product their vater is always the main article.
Example product consist of main article and additionally with combinations
Nummer Vater 12.1001.1 (main article) 12.1001.1 12.1001.2 (combination) 12.1001.1 12.1001.8L (combination) 12.1001.1
Example of 3 products below:
Nummer Vater 12.1001.1 12.1001.1 12.1001.2L 12.1001.1 03.999.1 03.999.1 12.1001.10R 12.1001.1 03.999.3 03.999.1 786.2892.1 786.2892.1 786.2892.4 786.2892.1
I want to give user possibility to select one article (main article) and change second part of it. The change should be reflected to entire product articles and their vaters. According to our example let’s assume user wants to change article:
03.999.1 999 --> 1001
this means at the end only those records should be changed as below:
03.1001.1 03.1001.1 03.1001.3 03.1001.1
My current sql presents like this and seems its working. Could you tell me whether it’s really fine and do not ovverwrite something else?:
Values i pass to query are:
oldNummer = 03.999.1 newNummer = 03.1001.1 oldNummerWithout1 = 03.999. newNummerWithout1 = 03.1001. UPDATE temp SET Nummer = replace(Nummer, @oldNummerWithout1, @newNummerWithout1), Vater = replace(Vater, @oldNummer, @newNummer) WHERE Vater = @oldNummer", transaction.Connection)
Have lot products in db and want to be sure this is really just enough. Awaiting your feedback as an answer.