473,387 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

need example for Triggers

donilourdu
hi I am doni

I need example for tigger in MySQL database.

looking for replies

with regards,
doni
Jan 12 '07 #1
4 4147
ronverdonk
4,258 Expert 4TB
In assume you do not mean TIGGERS but TRIGGERS?
What have you done to get the info from the standard MySQL documentation?That shows samples. See Triggers

You also do not specify for what situation you'd need it. Do we have to guess?

Ronald :cool:
Jan 12 '07 #2
In assume you do not mean TIGGERS but TRIGGERS?
What have you done to get the info from the standard MySQL documentation?That shows samples. See Triggers

You also do not specify for what situation you'd need it. Do we have to guess?

Ronald :cool:
thank you for reply
well Ronald I already know that site. But It cant be clear for me. Could you give me a simple example
Jan 12 '07 #3
ronverdonk
4,258 Expert 4TB
Okay, this is a simple example.
Assume: each time a row is inserted in table MyTable you want to log that event by adding a row to LogTable.
Expand|Select|Wrap|Line Numbers
  1. CREATE TRIGGER logit AFTER INSERT ON MyTable
  2. FOR EACH ROW 
  3. BEGIN
  4.   INSERT INTO LogTable (timestamp, message)
  5.   VALUES(NOW(), 'row added to MyTable');
  6. END;
  7.  
A good article with samples is shown at the OnLamp site at MySQL Triggers tryout

Ronald :cool:
Jan 12 '07 #4
[thank you Very much Ronald for your example.
It realy helpful for me.

with regards,
Doni

Okay, this is a simple example.
Assume: each time a row is inserted in table MyTable you want to log that event by adding a row to LogTable.
Expand|Select|Wrap|Line Numbers
  1. CREATE TRIGGER logit AFTER INSERT ON MyTable
  2. FOR EACH ROW 
  3. BEGIN
  4.   INSERT INTO LogTable (timestamp, message)
  5.   VALUES(NOW(), 'row added to MyTable');
  6. END;
  7.  
A good article with samples is shown at the OnLamp site at MySQL Triggers tryout

Ronald :cool:
Jan 13 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Mark Flippin | last post by:
I'm just starting to use triggers in my databases and find the support in Enterpise Manager lacking. Using Enterprise Manager and Query Analyzer you can maintain the triggers, but it's...
11
by: William Payne | last post by:
Ok, in my program I have a std::list<Document*>, where Document is one of my own classes. I need to go through this list and check each item if it's ready for deletion. If it's not, skip to...
4
by: stacdab | last post by:
We have a partitioned view with 4 underlying tables. The view and each of the underlying tables are in seperate databases on the same server. Inserts and deletes on the view work fine. We then...
7
by: Lucio Chiessi | last post by:
Hi for all on this... I'm using MS SQL Server 7.0 SP4 in some customers to store some data from an aplication developed by me. I created an trigger to run on update. When I run an update...
0
by: Dave Sisk | last post by:
Hi Folks: I've got this scenario: User table/file....external triggers declared for *AFTER *INSERT, *AFTER *UPDATE, and *BEFORE *DELETE. The 3 external triggers call a SQLRPG ILE stub...
106
by: xtra | last post by:
Hi Folk I have about 1000 procedures in my project. Many, many of them are along the lines of function myfuntion () as boolean on error goto er '- Dim Dbs as dao.database Dim Rst as...
0
by: Bruno Lavoie | last post by:
Hello, i'm etablishing a naming convention for a new project under postgresql. For tables, sequences, views, that's ok! I used good naming conventions for this in the past and i'll keep these...
4
by: Lucky | last post by:
hi guys! Currently i'm facing a bit odd situation. i cant modify my code so i have to make changes in SQL Server. the problem is, i've modified one table by adding new column and now i want...
1
by: nDaKota | last post by:
I am current converting PowerBuilder to C#. Now I'm having problem on triggers. I understand what a triggers does. The problem is what happens if a trigger is being triggered? Example: I execute a...
0
debasisdas
by: debasisdas | last post by:
trigger sample code Ex#10 ======================= INSTEAD OF TRIGGER ---------------------------------------- create or replace trigger mytrig instead of delete or insert or update on eview...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.