Change specific data based on condition

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
0
down vote

favorite












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.







share|improve this question

























    up vote
    0
    down vote

    favorite












    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.







    share|improve this question





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      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.







      share|improve this question











      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.









      share|improve this question










      share|improve this question




      share|improve this question









      asked Jan 25 at 21:25









      Arie

      1134




      1134

























          active

          oldest

          votes











          Your Answer




          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "196"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f186004%2fchange-specific-data-based-on-condition%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes










           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f186004%2fchange-specific-data-based-on-condition%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Chat program with C++ and SFML

          Function to Return a JSON Like Objects Using VBA Collections and Arrays

          Will my employers contract hold up in court?