Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread How to juse "call" in a trigger?
Fri, Mar 7 2008 11:29 AMPermanent Link

"Uli Becker"
I am learning how to use triggers now. In the manual I found this sample:

-- SendMail procedure with which group to
-- send the email to along with the new
-- value of the Notes column for the customer
-- being updated
CREATE TRIGGER "NotesUpdate" AFTER UPDATE OF "Notes"
ON "Customer"
BEGIN
CALL SendEmail('CustomerReps',NEWROW.Notes);
END

I don't understand the type of the SendMail procedure. Where and how have I
to define it?

Thanks. Uli

Mon, Mar 10 2008 3:51 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< I don't understand the type of the SendMail procedure. Where and how have
I to define it? >>

You would just define it as a stored procedure in the same database.  Then
you can CALL it from any other function, stored procedure, or trigger.

--
Tim Young
Elevate Software
www.elevatesoft.com

Mon, Mar 10 2008 4:20 PMPermanent Link

Uli Becker
Tim,
>
> You would just define it as a stored procedure in the same database.  Then
> you can CALL it from any other function, stored procedure, or trigger.
>

I am sorry - I don't understand that: I cannot place any code in a
stored procedure: so: how does the SendMail-procedure e.g. look like?

Uli
Tue, Mar 11 2008 4:42 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< I am sorry - I don't understand that: I cannot place any code in a stored
procedure: so: how does the SendMail-procedure e.g. look like? >>

You can define a stored procedure as external:

http://www.elevatesoft.com/scripts/manual.dll?action=mantopic&id=edb1sql&category=10&topic=162

The EXTERNAL NAME clause specifies that you want to use an external module
instead of an SQL/PSM body, and the name is the same as an existing external
module:

http://www.elevatesoft.com/scripts/manual.dll?action=mantopic&id=edb1sql&category=0&topic=13

You can create an external module very easily by doing the following in
Delphi 5:

File/New
Select the ElevateDB tab
Double-click on the ElevateDB External Module icon

This will generate an empty template application for creating an external
module that can contain any number of external procedures, including
something like the SendMail procedure.  And, this is all native Delphi code
instead of SQL/PSM, which is ideal for situations where you need to
interface with external hardware or libraries.

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Mar 11 2008 5:26 PMPermanent Link

Uli Becker
Tim,

<<
You can define a stored procedure as external:

http://www.elevatesoft.com/scripts/manual.dll?action=mantopic&id=edb1sql&category=10&topic=162
>>

Thank you. That sounds great! I'll check that tomorrow.

Regards Uli

Wed, Mar 12 2008 3:54 AMPermanent Link

Uli Becker
Tim,

I created a small "Hello World" dll and a Stored Procedure that calls
this dll.
That works fine and is tested by executing the SP.

Now I created a trigger like this:

 EXECUTE IMMEDIATE
'CREATE TRIGGER "PatientenUpdate" AFTER UPDATE OF "Name" ON "Patienten"
 BEGIN
 CALL ExecuteMyDLL;
 END
';

The Column Name in the table Patienten should be handled on any changes.
Unfortunately there doesn't happen anything when changing the value of
Name. Did I miss anything?

Uli
Wed, Mar 12 2008 3:34 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< The Column Name in the table Patienten should be handled on any changes.
Unfortunately there doesn't happen anything when changing the value of
Name. Did I miss anything? >>

No, it's a bug.   The issue is that the modification flag for the column is
getting reset prior to the AfterUpdate trigger being executed.  IOW, it will
work if you define the trigger as a *before* update trigger.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image