C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Triggers


Posted Date: 28 Aug 2008      Total Responses: 6

Posted By: narendra       Member Level: Silver     Points: 1


hi friends plz help me

What is trigger,how many types of trigers,what is the use of triggers
plz explain types one by one







Responses

Author: UltimateRengan    28 Aug 2008Member Level: DiamondRating:     Points: 6
SQL create trigger statement provides a way for the database management system to actively controls and monitor and manage the group of table when ever an update the data or delete the data or insert the data in that time performed.
Trigger excuted each time an sql insert,update,delete operation is performed.

create trigger tri_update on Emp
for update
as
begin
if update(EmpID)
begin
print'not update here'
rollback transaction
end
end

update Emp set EmpID='jj' where UserName='mahagr'
-------
output:
------
not update here
Msg 3609, Level 16, State 1, Line 1
The transaction ended in the trigger. The batch has been aborted.



Author: Legend     29 Aug 2008Member Level: SilverRating:     Points: 6
What is TRIGGER?

In a DBMS, a trigger is a SQL procedure that initiates an action (i.e., fires an action) when an event (INSERT, DELETE or UPDATE) occurs. Since triggers are event-driven specialized procedures, they are stored in and managed by the DBMS. A trigger cannot be called or executed; the DBMS automatically fires the trigger as a result of a data modification to the associated table. Triggers are used to maintain the referential integrity of data by changing the data in a systematic fashion.
Each trigger is attached to a single, specified table in the database.

Triggers can be viewed as similar to stored procedures in that both consist of procedural logic that is stored at the database level. Stored procedures, however, are not event-drive and are not attached to a specific table as triggers are. Stored procedures are explicitly executed by invoking a CALL to the procedure while triggers are implicitly executed. In addition, triggers can also execute stored procedures.

A trigger can also contain INSERT, UPDATE and DELETE logic within itself, so when the trigger is fired because of data modification it can also cause another data modification, thereby firing another trigger. A trigger that contains data modification logic within itself is called a nested trigger.






Author: Legend     29 Aug 2008Member Level: SilverRating:     Points: 6
1.TYPES OF TRIGGER

Trigger types refer to the trigger status (ACTIVE or INACTIVE), the trigger position (BEFORE or AFTER) and the operation type (INSERT or UPDATE or DELETE).

They are specified following the definition of the table or view name, and before the trigger body.



2.Types of trigger
The three different types of trigger found in the trigger table are defined as follows:


static trigger
the icon or window background is clicked or double-clicked without moving the mouse

dynamic trigger
the icon is dragged and dropped onto another icon or window background

hold trigger
the mouse button is held down on an icon or window background


1.Static triggers
Clicking once is called ``single-clicking''. Clicking twice in quick succession, without moving the mouse pointer, is called ``double-clicking'' or ``activating''. Single and double clicks are referred to as ``static'' triggers because the mouse does not move during the action.

To make the rules as portable as possible, the static triggers are pre-defined with names as follows:


select
single-click on an icon picture

alt_select
single-click on an icon picture with mouse button 2

rename
single-click on an icon title

alt_rename
single-click on an icon title with mouse button 2

activate
double-click on an icon

alt_activate
double-click on an icon with mouse button 2

deselect
single-click on a window background

report
double-click on a window background

alt_report
double-click on a window background with mouse button 2

s*
matches any static trigger

2.Dynamic triggers
The action of dragging one or more icons and dropping them onto another icon is called a ``dynamic'' trigger, to contrast it with a static trigger. This is also sometimes referred to as a ``drag'' trigger.

The dynamic triggers are pre-defined as follows:


drop
drop one or more icons on an icon or window background

alt_drop
drop one or more icons on an icon or window background with mouse button 2

d*
matches any drag trigger


3.Hold triggers
``Hold'' triggers activate an icon or directory window when the user presses one of the mouse buttons and holds it down without moving the pointer.

The hold triggers are pre-defined as follows:


menu
hold mouse button 3 on an icon picture or title

popup_menu
hold mouse button 3 on a window background

h*
matches any hold trigger



Thanks ,
Is my Response helpful to you?



Author: http://venkattechnicalblog.blogspot.com/    31 Aug 2008Member Level: DiamondRating:     Points: 3

Check this URL,

http://www.sqlteam.com/article/an-introduction-to-triggers-part-i

Regards,
Venkatesan Prabu .J
http://venkattechnicalblog.blogspot.com/


Author: Bunty    03 Sep 2008Member Level: DiamondRating:     Points: 6
Hi,

A trigger is a block of code that constitutes a set of T-SQL statements that are activated in response to certain actions or conditions.

A trigger can also be interpreted as a special kind of stored procedure that is executed whenever an action,such as data modification,takes place.

A Trigger is fired whenever data in the underlying table is affected by any of the Data Manipulation Language (DML) statements -INSERT,UPDATE,OR DELETE.

Triggers help in maintaining consistent,reliable,and correct data in tables.They enable the performance of complex actions and cascade these actions to other dependent tables.

Thanks and Regards
S.S.Bajoria



Author: suresh kumar    06 Sep 2008Member Level: BronzeRating:     Points: 4
hi....
triggers are special type of stored procedures that are defined to excute automatically in place or after data modifications.they can be excuted on the the insert ,delete and update triggering actions
there two diff type of triggers they are
1.instead of triggers
2.after triggers




Post Reply
You must Sign In to post a response.
Next : Auto Incremet in SQL
Previous : candidate Key
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

teleconferencing service

Contact Us    Privacy Policy    Terms Of Use