SpiritOfLennon
IS-IT--Management
Hi,
I'm trying to write a trigger that calls a VB6 program. I've got about this far
create TRIGGER scheme.trigger
ON owner.dbo.table
before INSERT, DELETE
AS
begin
declare @ni int, @nd int
declare @cmd varchar (8000)
select @ni = count(*) from Inserted
select @nd = count(*) from Deleted
-- DELETE
if @ni > @nd
SET @cmd = 'prwo del'
exec master.dbo.xp_cmdshell @cmd
--INSERT
if @ni < @nd
SET @cmd = 'prwo ins'
exec master.dbo.xp_cmdshell @cmd
END
GO
However I need to pass the details of the records affected to the VB6 program. I'm guessing that I should set up a loop that plows through the records in Deleted and Inserted, however I'm not sure how to do this. Here's my questions
1) Is there a logical way to move through the records in turn and pass them to the external program?
2) Is there a way to actually pass the rows through to the VB6 code?
3) Would the VB6 code have access to the tables Deleted and Inserted and be able to pick up the relevant data itself?
Excuse the dumb questions but I generally work with Oracle but a customer has asked me to migrate an Oracle application I have into SQL server. Any help would be greatly appreciated.
Oh and I don't want to code all my logic directly into the triggers for security reasons.
Thanks
SOL
I'm trying to write a trigger that calls a VB6 program. I've got about this far
create TRIGGER scheme.trigger
ON owner.dbo.table
before INSERT, DELETE
AS
begin
declare @ni int, @nd int
declare @cmd varchar (8000)
select @ni = count(*) from Inserted
select @nd = count(*) from Deleted
-- DELETE
if @ni > @nd
SET @cmd = 'prwo del'
exec master.dbo.xp_cmdshell @cmd
--INSERT
if @ni < @nd
SET @cmd = 'prwo ins'
exec master.dbo.xp_cmdshell @cmd
END
GO
However I need to pass the details of the records affected to the VB6 program. I'm guessing that I should set up a loop that plows through the records in Deleted and Inserted, however I'm not sure how to do this. Here's my questions
1) Is there a logical way to move through the records in turn and pass them to the external program?
2) Is there a way to actually pass the rows through to the VB6 code?
3) Would the VB6 code have access to the tables Deleted and Inserted and be able to pick up the relevant data itself?
Excuse the dumb questions but I generally work with Oracle but a customer has asked me to migrate an Oracle application I have into SQL server. Any help would be greatly appreciated.
Oh and I don't want to code all my logic directly into the triggers for security reasons.
Thanks
SOL