5 Replies Latest reply: Mar 1, 2013 4:27 AM by François Degrelle RSS

    Commit in Trigger

      Hi All,

      Can I use commit inside trigger.If I can, in which scenario it is needed and how can it be used?

      Thanks & Regards,
        • 1. Re: Commit in Trigger
          carlos cortez
          Hello SB2013

          Yes you can use the commit statement inside a trigger.

          I give you two scenarios:

          1- You have a button item in a canvas and in it's trigger WHEN-BUTTON-PRESS you have an insert statement, so you want to save the insertion you must use a commit statement.

          2- You want to overwrite for example a trigger that already has the commit functionality but you want to perform a validation before use the commit statement.

          Hope my explanation helps you :)

          • 2. Re: Commit in Trigger
            Assuming you are talking about Forms triggers and not database triggers...

            It depends on the trigger. If it is just a when-button-pressed trigger on a "Save" or "Commit" button, then yes.

            I wouldn't use a commit after a sql Insert, because doing a commit anywhere in your form commits ALL work done up to that point.
            • 3. Re: Commit in Trigger
              Hi Steve ,
              I am talking about database triggers.I got this question in an interview.This is one part of the question.
              The other part is:
              Can we write DML statements in trigger?If yes then where this statements will be commited?
              Thanks in advance for Your help.

              Thanks & Regards,
              • 4. Re: Commit in Trigger
                Hi Ccortez,

                Thanks for your help. I think you have answered this question by keeping forms trigger in mind.But I have asked about the database trigger.

                Thanks & Regards,
                • 5. Re: Commit in Trigger
                  François Degrelle
                  Wrong forum. This is the Oracle Forms forum.
                  You should ask in the SQL or database forum. (commit cannot be used in a database trigger).