[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [cobalt-developers] OT ? Interbase - how to have auto email when db date value is current date



Todd,

On Thu, 2003-03-06 at 14:17, Todd Kirk wrote:
> 
> 
> So you don't recommend the use of a trigger or stored procedure or
> similar? The idea is that if he program is not run then the email would
> never be sent.

You really do not want to use triggers for external purposes in a db.
Triggers should be used for internal data integrity, checks,
calculations, and just about anything that can all be done within the db
itself.

For example if you have a table with customers in it, and an invoice
table. You may want a trigger to extract the customer information out of
the customer table and insert it into the invoice table.

That way you can create an invoice using only a customer #, and the
information never has to leave the db. Much faster than extracting the
customer information, and reinserting into the db.
 
> The client needs to receive the email whether they login to their web
> application or not. Hence my thinking that the db has to trigger and
> send the email....not some ASP page that may not be visited and
> therefore run. Is my logic correct here?

What is going to fire the trigger? Triggers only fire on insert, update
or delete. So if you are not doing any, then a trigger will never be
fired. So how were you expecting to call the trigger?

With cron, you can execute the program when ever you want it to be
executed.

Then if needed you can use a trigger to assist in manipulating the data.

However a trigger should almost never have any effect or control on
things outside of the db itself.

For that you should use UDF's. However I strongly agree Johnathan that
business logic in the data-tier is not a good idea. Unless like I
mentioned above the data needs to be manipulated without leaving the
database.

Which you are not doing.

-- 
Sincerely,
William L. Thomson Jr.
Support Group
Obsidian-Studios Inc.
439 Amber Way
Petaluma, Ca. 94952
Phone  707.766.9509
Fax    707.766.8989
http://www.obsidian-studios.com