answersLogoWhite

0


Best Answer
Yes, you can very definitely use transactions within a trigger in one of two common ways;

1. As with any other use of transactions - to ensure a collection of commands within the trigger are executed in a repeatable way in the event of failure.

2. To 'undo' the process that caused the trigger to fire. For example, the trigger might be doing some additional integrity checks and issuing a rollback to undo the initiating update/delete.

---------

AnswerCome to think of it, I have never seen a commit on triggers. Triggers as you know are a last line defense based on an action that was carried out by an insert,update or delete. Hence, since the trigger exists on the server, and is only fired if one of the above conditions are executed then it seems pointless to use a commit in the trigger. Also commit goes along nicely with transactions where you begin the transaction and if all is well then you issue a commit, else if the transaction fails, then you issue a rollback.
User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can you use a commit statement within a database trigger?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What can a SQL UPDATE statement allow one to do within a table?

A SQL UPDATE statement allows the user to update existing records in a database table. For example, it could be used to update a customer's address, or a the price of a product.


Is it possible to perform a calculation within a database?

Yes you can. You can create queries that do calculations. You can write code for programs to do calculations in a database. Doing calculations is a significant element of what you do with a database, so yes you can do them within a database.


What happens when a rollback statement exicuted inside a trigger?

You would have to have an "if" statement that says" IF an error occurs and the field is not updated (your code would be specific) then "rollback". You would want to name the section so you can rollback by name to be specific. If you did a generic rollback, all operations within the trigger would be rolled back--even the successful ones. If you put rollback statements within triggers, you need to make sure your logic is flawless and all bases are covered. You would want to test the trigger for the results you expect.


Differentiate DATA from a database?

A database is a collection of data. Data represents items that are stored within the database.


A quert is a question you ask about the data stored in a database?

A "query" is usually a programmatic statement that is understand by a DBMS(Database management system) that understands how to access and manipulate data within a database. The primary operations of a query are referred to as CRUD(Create, Read, Update, Delete) and the main programming language for writing queries is ANSI SQL.


Relationship between a database and a table?

A table is contained within the database and consists of columns and rows. A table is meant to store data and, in relational databases, are related to other tables within the same database.


What is a connection within the data in a database?

relationship


A form that is inserted within another form?

Wether in docuement form or a database form within a database data input form a form within another form is called a sub form


What is the difference between database file and datafile?

Datafile is a group of files in each table space in an Oracle database. Database files are all files that are found within the database.


What is database table and filter?

Filters-filters look for specific information within a database regarding a subject.


What is international database?

An internal database is a Computerized collections of information obtained from data sources within the company.


What is an internal database?

An internal database is a Computerized collections of information obtained from data sources within the company.