Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Design and Architecture
  4. How this can be done in Atomic way?

How this can be done in Atomic way?

Scheduled Pinned Locked Moved Design and Architecture
databasequestion
11 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    paresh_joe
    wrote on last edited by
    #1

    Class A { B bsObject; public void FunctionOfClassA() { bsObject.FunctionOfClassB() } } Class B { public void FunctionOfClassB() { } } I have my program structure as shown above. I want a way to apply atomicity to this. I mean if Class B's data write worked fine but Class A's calculations failed then want to rollback the data write. i want it all succeed or rollback. One way i can think of is to create a DB ptr and begin transaction just before call to FunctionOfClassB() and pass it as a parameter. so in this FunctionOfClassB will use same db ptr to write data. And it would also be possible in FunctionOfClassA() to check if calculations went ok then commit or rollback. My requirement is to not to make any change in parameter list or not to provide a new method with new parameter. Class A { B bsObject; public void FunctionOfClassA() { bsObject.FunctionOfClassB() // some calculations // Here I want to decide whether to commit or rollback } } Class B { public void FunctionOfClassB() { // here i want to begin a transaction // some data writing. } } Can anyone give an high level summary how this could be possible?

    L C 2 Replies Last reply
    0
    • P paresh_joe

      Class A { B bsObject; public void FunctionOfClassA() { bsObject.FunctionOfClassB() } } Class B { public void FunctionOfClassB() { } } I have my program structure as shown above. I want a way to apply atomicity to this. I mean if Class B's data write worked fine but Class A's calculations failed then want to rollback the data write. i want it all succeed or rollback. One way i can think of is to create a DB ptr and begin transaction just before call to FunctionOfClassB() and pass it as a parameter. so in this FunctionOfClassB will use same db ptr to write data. And it would also be possible in FunctionOfClassA() to check if calculations went ok then commit or rollback. My requirement is to not to make any change in parameter list or not to provide a new method with new parameter. Class A { B bsObject; public void FunctionOfClassA() { bsObject.FunctionOfClassB() // some calculations // Here I want to decide whether to commit or rollback } } Class B { public void FunctionOfClassB() { // here i want to begin a transaction // some data writing. } } Can anyone give an high level summary how this could be possible?

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      paresh_joe wrote:

      I want a way to apply atomicity to this.

      this? The code you posted has no data, there are no write operations, therefore nothing to roll forwards or backwards, even sideways. :rolleyes:

      led mike

      1 Reply Last reply
      0
      • P paresh_joe

        Class A { B bsObject; public void FunctionOfClassA() { bsObject.FunctionOfClassB() } } Class B { public void FunctionOfClassB() { } } I have my program structure as shown above. I want a way to apply atomicity to this. I mean if Class B's data write worked fine but Class A's calculations failed then want to rollback the data write. i want it all succeed or rollback. One way i can think of is to create a DB ptr and begin transaction just before call to FunctionOfClassB() and pass it as a parameter. so in this FunctionOfClassB will use same db ptr to write data. And it would also be possible in FunctionOfClassA() to check if calculations went ok then commit or rollback. My requirement is to not to make any change in parameter list or not to provide a new method with new parameter. Class A { B bsObject; public void FunctionOfClassA() { bsObject.FunctionOfClassB() // some calculations // Here I want to decide whether to commit or rollback } } Class B { public void FunctionOfClassB() { // here i want to begin a transaction // some data writing. } } Can anyone give an high level summary how this could be possible?

        C Offline
        C Offline
        CodingYoshi
        wrote on last edited by
        #3

        paresh_joe wrote:

        My requirement is to not to make any change in parameter list or not to provide a new method with new parameter.

        If so as above, then how can you (down below) pass the pointer since your function accepts no parameters in your skeleton class.

        paresh_joe wrote:

        One way i can think of is to create a DB ptr and begin transaction just before call to FunctionOfClassB() and pass it as a parameter.

        Please reword.

        P S 2 Replies Last reply
        0
        • C CodingYoshi

          paresh_joe wrote:

          My requirement is to not to make any change in parameter list or not to provide a new method with new parameter.

          If so as above, then how can you (down below) pass the pointer since your function accepts no parameters in your skeleton class.

          paresh_joe wrote:

          One way i can think of is to create a DB ptr and begin transaction just before call to FunctionOfClassB() and pass it as a parameter.

          Please reword.

          P Offline
          P Offline
          paresh_joe
          wrote on last edited by
          #4

          I meant to say that only solution come to my mind is to pass DB parameter to function which is not possible. I want some other way in which this can be implemented.

          C S 2 Replies Last reply
          0
          • P paresh_joe

            I meant to say that only solution come to my mind is to pass DB parameter to function which is not possible. I want some other way in which this can be implemented.

            C Offline
            C Offline
            CodingYoshi
            wrote on last edited by
            #5

            Can the server function throw an exception if transaction is not completed? Yes, then you can handle it in the client and do whatever you need to. Another approach is, if you can, to introduce two events in the server method which can be raised when the server method either completes or fails. This event will have one parameter derived from the EventArgs class (if using .NET) and it can contain information about what happened during the transaction--what failed and what passed. What do you think?

            S 1 Reply Last reply
            0
            • C CodingYoshi

              paresh_joe wrote:

              My requirement is to not to make any change in parameter list or not to provide a new method with new parameter.

              If so as above, then how can you (down below) pass the pointer since your function accepts no parameters in your skeleton class.

              paresh_joe wrote:

              One way i can think of is to create a DB ptr and begin transaction just before call to FunctionOfClassB() and pass it as a parameter.

              Please reword.

              S Offline
              S Offline
              samdevloper
              wrote on last edited by
              #6

              Hi sumit here

              1 Reply Last reply
              0
              • P paresh_joe

                I meant to say that only solution come to my mind is to pass DB parameter to function which is not possible. I want some other way in which this can be implemented.

                S Offline
                S Offline
                samdevloper
                wrote on last edited by
                #7

                Hello sam here

                S 1 Reply Last reply
                0
                • C CodingYoshi

                  Can the server function throw an exception if transaction is not completed? Yes, then you can handle it in the client and do whatever you need to. Another approach is, if you can, to introduce two events in the server method which can be raised when the server method either completes or fails. This event will have one parameter derived from the EventArgs class (if using .NET) and it can contain information about what happened during the transaction--what failed and what passed. What do you think?

                  S Offline
                  S Offline
                  samdevloper
                  wrote on last edited by
                  #8

                  I REALLY DONT KNOW.........PLS HELP

                  C 1 Reply Last reply
                  0
                  • S samdevloper

                    Hello sam here

                    S Offline
                    S Offline
                    samdevloper
                    wrote on last edited by
                    #9

                    test today

                    S 1 Reply Last reply
                    0
                    • S samdevloper

                      test today

                      S Offline
                      S Offline
                      samdevloper
                      wrote on last edited by
                      #10

                      tesst 5 min

                      1 Reply Last reply
                      0
                      • S samdevloper

                        I REALLY DONT KNOW.........PLS HELP

                        C Offline
                        C Offline
                        CodingYoshi
                        wrote on last edited by
                        #11

                        I don't understand what you are asking. You are back after a long time! Can you be more clear about your question?

                        CodingYoshi Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups