Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Chan Kok Kiet
  Where is Chan Kok Kiet?
 Kuala Lumpur
 Malaysia
 Chan Kok Kiet
 To: Goo Koo
  Where is Goo Koo?
 
 Thailand
 Goo Koo
 Tags
Subject: RE: How to email from a update trigger in a table
Thread ID: 33641 Message ID: 33644 # Views: 2 # Ratings: 0
Version: Visual FoxPro 8 Category: Databases, Tables and SQL Server
Date: Monday, December 01, 2003 11:55:33 AM         
   


Hi,
It is very simple.
1. Create a function/procedure as stored procedure in database
- Modify Database
- Right click and select edit stored procedure
- Type/Paste your code to email
PROCEDURE Email
*-- Email ...
EDPROC
- Save and Close stored procedure

2. Create trigger for particular table
Visually
- Open table
- Modify Struc
- Go to table tab, key in your function name in update trigger column.
Programmatically
- CREATE TRIGGER ON TableName
FOR INSERT | UPDATE | DELETE AS myFunc()

Done.

Note: your funtion should RETURN .T., if not VFP will indicate trigger fail, and will not save records.

However, if you place your email code in trigger, it will definitely slower down your update process. My suggestion is, have a table to store information for email to be sent. Insert a record to a table from update trigger. On the other hand, create a timer object to check for "incomplete" periodly, mark a flag on table once the email request sent.

HTH

> Dear Friends,
>
> Nice to meet you again after 2 months of absence.
>
> I want to let my program automatically send email when a field in a table is updated. It is better to create a trigger for update in table designer?
> Could you please tell me how to create the trigger and its exact code and where to put the code?
>
> Great Thanks.


I am not the most powerful man in this world.
I am not the worst man in this world either.
I just as same as all of you.
I still need to learn from my mistakes...

ENTIRE THREAD

How to email from a update trigger in a table Posted by Goo Koo @ 12/1/2003 10:56:41 AM
RE: How to email from a update trigger in a table Posted by Chan Kok Kiet @ 12/1/2003 11:55:33 AM