I've done this, and it works fine.  You use xp_cmdshell to call cfml.exe.
Here's an example:

ALTER  TRIGGER myTrigger ON dbo.myTable
FOR INSERT
AS

DECLARE @s_SQL varchar(5000), @ClientId as int

SELECT @ClientId = ClientId
FROM Inserted

SET @s_SQL = 'master..xp_cmdshell ''C:\CFBatch\myCommandFile.cmd '
SET @s_SQL = @s_SQL + CAST(@ClientId AS varchar) + ''' ,no_output'

Exec(@s_SQL)

When this is executed, it runs a batch file, called myCommandFile.cmd, which
is in a directory on the server.  Here's what's in myCommandFile.cmd:

SET QUERY_STRING=ClientId=%1
SET CF_TEMPLATE_PATH=C:\CFBatch\myCFTemplate.cfm
C:\CFUSION\BIN\CFML.EXE

This routine allows me to call a ColdFusion Template from within SQL Server
(could be a trigger or a stored procedure), and pass it a parameter (in this
case, the ClientId) that is coming from SQL Server.

As I said, it seems to work well, but in this scenario you need to have CF
and SS on the same machine.  I'm sure you could find a way to do it if they
weren't, but I didn't have to worry about that, so I haven't tried it yet.

Hope that gives you some ideas,
Bob

-----Original Message-----
From: Tony Schreiber [mailto:[EMAIL PROTECTED]]
Sent: April 26, 2001 1:17 PM
To: CF-Talk
Subject: CF Triggers?


Has anyone thought of a way to fire off processing of a CF template from a
database event? Just like a regular DB Triggering a Stored Procedure, but
instead calling a CF template? What can regular triggers do?


Tony Schreiber, Senior Partner                  Man and Machine, Limited
mailto:[EMAIL PROTECTED]                   http://www.technocraft.com

http://www.simplemessageboard.com ___Free Forum Software for Cold Fusion
http://www.is300.net ___________The Enthusiast's Home of the Lexus IS300
http://www.digitacamera.com ______________DigitA Camera Scripts and Tips
http://www.linklabexchange.com _____________Miata Link ECU Data Exchange
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to