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. Database & SysAdmin
  3. Database
  4. Skeptical about Trigger!

Skeptical about Trigger!

Scheduled Pinned Locked Moved Database
databasehelpquestion
12 Posts 5 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.
  • T Offline
    T Offline
    Thiru6
    wrote on last edited by
    #1

    Dude's, want to insert the values in one table(say bookingtable), the remaining seats column in another table must be suitably updated. Trying to concept using of Triggers. Can I go with the following way? but my table is not updated. Pls help on this. CREATE TRIGGER Trgupdtsts ON Table_FB2 FOR INSERT AS DECLARE @FNo INT, @DOJRNY DATETIME, @RMNGSTS INT SELECT @FNO = i.FNO, @DOJRNY = i.DOJRNY FROM inserted i; set @RMNGSTS = ("need to insert logic here?")--'Record Inserted' INSERT INTO TBL_FSTS (FNO , DOJRNY , RMNGSTS) VALUES (@FNO , @DOJRNY , @RMNGSTS) --select @RMNGSTS from inserted

    G M 2 Replies Last reply
    0
    • T Thiru6

      Dude's, want to insert the values in one table(say bookingtable), the remaining seats column in another table must be suitably updated. Trying to concept using of Triggers. Can I go with the following way? but my table is not updated. Pls help on this. CREATE TRIGGER Trgupdtsts ON Table_FB2 FOR INSERT AS DECLARE @FNo INT, @DOJRNY DATETIME, @RMNGSTS INT SELECT @FNO = i.FNO, @DOJRNY = i.DOJRNY FROM inserted i; set @RMNGSTS = ("need to insert logic here?")--'Record Inserted' INSERT INTO TBL_FSTS (FNO , DOJRNY , RMNGSTS) VALUES (@FNO , @DOJRNY , @RMNGSTS) --select @RMNGSTS from inserted

      G Offline
      G Offline
      gvprabu
      wrote on last edited by
      #2

      What is the logic for finding @RMNGSTS Values?

      T 1 Reply Last reply
      0
      • T Thiru6

        Dude's, want to insert the values in one table(say bookingtable), the remaining seats column in another table must be suitably updated. Trying to concept using of Triggers. Can I go with the following way? but my table is not updated. Pls help on this. CREATE TRIGGER Trgupdtsts ON Table_FB2 FOR INSERT AS DECLARE @FNo INT, @DOJRNY DATETIME, @RMNGSTS INT SELECT @FNO = i.FNO, @DOJRNY = i.DOJRNY FROM inserted i; set @RMNGSTS = ("need to insert logic here?")--'Record Inserted' INSERT INTO TBL_FSTS (FNO , DOJRNY , RMNGSTS) VALUES (@FNO , @DOJRNY , @RMNGSTS) --select @RMNGSTS from inserted

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        Another one with a crappy design, available seats should be an enquiry on the Bookingtable! while using a trigger spit may fix this issue the design should be fixed to remove the need for a trigger spit

        Never underestimate the power of human stupidity RAH

        J T 2 Replies Last reply
        0
        • M Mycroft Holmes

          Another one with a crappy design, available seats should be an enquiry on the Bookingtable! while using a trigger spit may fix this issue the design should be fixed to remove the need for a trigger spit

          Never underestimate the power of human stupidity RAH

          J Offline
          J Offline
          Jorgen Andersson
          wrote on last edited by
          #4

          One could get the opinion that you don't like triggers spit :laugh:

          "The ones who care enough to do it right care too much to compromise." Matthew Faithfull

          M 1 Reply Last reply
          0
          • J Jorgen Andersson

            One could get the opinion that you don't like triggers spit :laugh:

            "The ones who care enough to do it right care too much to compromise." Matthew Faithfull

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            One of my earliest sql jobs was to track down a bug, it was in a trigger spit and it took me ages to find the bloody thing, that was over 25 years ago and I have not forgiven them their sins!

            Never underestimate the power of human stupidity RAH

            J 1 Reply Last reply
            0
            • M Mycroft Holmes

              One of my earliest sql jobs was to track down a bug, it was in a trigger spit and it took me ages to find the bloody thing, that was over 25 years ago and I have not forgiven them their sins!

              Never underestimate the power of human stupidity RAH

              J Offline
              J Offline
              Jorgen Andersson
              wrote on last edited by
              #6

              I don't like them either, I'm considering triggers and distinct as a sign that there is something wrong in the design and query respectively. Cannot always be without them, but I try hard.

              "The ones who care enough to do it right care too much to compromise." Matthew Faithfull

              1 Reply Last reply
              0
              • G gvprabu

                What is the logic for finding @RMNGSTS Values?

                T Offline
                T Offline
                Thiru6
                wrote on last edited by
                #7

                Hi prabu, Want to update the Remaining seats in the another table. So I used @RMNGSTS as variable. How to frame the entire queries? Is the above is correct?

                G 1 Reply Last reply
                0
                • M Mycroft Holmes

                  Another one with a crappy design, available seats should be an enquiry on the Bookingtable! while using a trigger spit may fix this issue the design should be fixed to remove the need for a trigger spit

                  Never underestimate the power of human stupidity RAH

                  T Offline
                  T Offline
                  Thiru6
                  wrote on last edited by
                  #8

                  Friends,, Atlast what is the exact solution? Everybody posting ur concerns, but I want answer:)

                  G 1 Reply Last reply
                  0
                  • T Thiru6

                    Hi prabu, Want to update the Remaining seats in the another table. So I used @RMNGSTS as variable. How to frame the entire queries? Is the above is correct?

                    G Offline
                    G Offline
                    gvprabu
                    wrote on last edited by
                    #9

                    Hi, You need to insert same details to another table right, Use same Same logic. No need to assign a values in variable.

                    T 1 Reply Last reply
                    0
                    • G gvprabu

                      Hi, You need to insert same details to another table right, Use same Same logic. No need to assign a values in variable.

                      T Offline
                      T Offline
                      Thiru6
                      wrote on last edited by
                      #10

                      dude, didnt get your logic. Kindly send me the codes.

                      1 Reply Last reply
                      0
                      • T Thiru6

                        Friends,, Atlast what is the exact solution? Everybody posting ur concerns, but I want answer:)

                        G Offline
                        G Offline
                        GuyThiebaut
                        wrote on last edited by
                        #11

                        Create a stored procedure. Pass the update information into the stored procedure via parameters then update the relevant tables via the stored procedure. I would tend to agree with Mycroft spit that triggers can hide things from you when you are trying to debug a problem later on.

                        “That which can be asserted without evidence, can be dismissed without evidence.”

                        ― Christopher Hitchens

                        J 1 Reply Last reply
                        0
                        • G GuyThiebaut

                          Create a stored procedure. Pass the update information into the stored procedure via parameters then update the relevant tables via the stored procedure. I would tend to agree with Mycroft spit that triggers can hide things from you when you are trying to debug a problem later on.

                          “That which can be asserted without evidence, can be dismissed without evidence.”

                          ― Christopher Hitchens

                          J Offline
                          J Offline
                          Jorgen Andersson
                          wrote on last edited by
                          #12

                          One could get the impression that you don't like Mycroft. :laugh:

                          "The ones who care enough to do it right care too much to compromise." Matthew Faithfull

                          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