No announcement yet.

To avoid the "run on-update statement"

  • Filter
  • Time
  • Show
Clear All
new posts

  • To avoid the "run on-update statement"

    The channel that I am implementing reads and writes in databases (with some transformations).

    If some mistake happened in the transformation, I would like to avoid the execution of the "On-Update SQL".

    Is it possible to avoid it somehow?.


  • #2
    Re:To avoid the "run on-update statement"

    Yes, but not in this way.

    If you want to use a conditional update sentence, do it at the transformer, and don't use any update sentence at the source


    • #3
      Re:To avoid the "run on-update statement"


      For what I deal, the command "On-Update" would make it empty and execute it in the transformer.

      Some example?


      • #4
        Re:To avoid the "run on-update statement"

        Por cierto, a este paso si pasas por Valencia te debo una ronda...


        • #5
          Re:To avoid the "run on-update statement"

          I've attached an example.

          The on-update checkbox is set to "No". The update sentence is at the source transformer, and is only executed when the condition is true. You can use this code both at the source or the transformer.

          Of course, this way is less efficient than using the on-update sentence.

          Y gracias, tomo nota de la ronda. no_on_update.xml (5267 bytes)


          • #6
            Re:To avoid the "run on-update statement"

            Thank you for the example, but my idea is to force a mistake somehow in order that it does not execute the "run on-update statement".

            It is the same thing that when it was executing a command SQL and it was giving mistake.

            What I want is to be able to do it but with the code javascript.

            Have I managed to explain?


            • #7
              Re:To avoid the "run on-update statement"

              I'm sorry, but the on-update statement will be executed allways.

              The only way is to controll its execution at a destination or into a Transformer, as it's shown in the example I've send you.

              But, if what you want is to controll SQL exceptions, then it's possible using the JS catching instuctions:



              • #8
                Hi all,

                I've one question regarding this topic: what happens if the message gets undelivered by any reason? For instance: an expection in the transformer, the recipient host is offline, there is a network problem ...

                The On-Update statement gets executed regardless of the result of the success of the message?

                In my environment, I would need the statement only to be executed when everything works out fine. What would be the best way to do this? Maybe by adding a Database Destination?

                Many thanks !


                • #9
                  You can have a channel behaving as described below if you use a DB Reader and process the message using several destinations.

                  Define a DBWriter destination to simulate the "run on update" only if the previous steps ran ok.


                  • #10
                    Ok, I'm on it.

                    Is it possible to set a destination so it gets executed only in case the result from the previous destination was SUCCESS? I cannot figure out how to do that ...

                    Many thanks for your support !!



                    • #11
                      Ok, I think I found it .... it just seems to be necessary to activate "Synchronize channel".

                      Many thanks anyway for the great support !!!



                      • #12
                        put a JS Writer or a DB Writer with JS enabled and use some code like:

                        // 1.- ver el estado de la ejecuciĆ³n de dest.
                        dest1_status = responseMap.get('dest1').getStatus().toString();
                        // name of the previous destination

                        if (dest1_status == "SUCCESS") {
                        // the previous destination was OK
                        else {
                        // some exception thrown from "dest1".




                        • #13
                          dgilperez: Synchronize option (AFAIK) is used to force Mirth to execute each destination in order. Without "synchronize" option enabled, you cannot use postprocessor (because this script is executed when all the destinations are done), and cannot use the code posted below (because you don't know if a destination is yet executed when evaluating the current destination)


                          • #14
                            I was wondering if the destinations are executed in order, just by putting the DBWriter the last one it was done, because if the previous failed the DBWriter was not going to execute ....

                            ... but anyway we can be double sure with your suggestion, activating Syncro and using and adaptation of the code you posted. It's working for me now.

                            Many thanks !!!