Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 5th, 2004, 03:08 AM
Registered User
 
Join Date: Jul 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How Can I Do This

Hi All
I Have Tow Tables One Main for Main Information And 2 Child For Loan Values
 I Need TRIGGER Do Balance in Loan Table Whene I Insert New REcord In Main
Table
like This



CREATE TRIGGER [monthly_Action _insert] ON monthly_Action
FOR Insert
AS
Declare @NewM Money,
 @NewA Money,
 @NewB Money,
 @NewD Datetime,
 @TheNo bigint

select @TheNo = PensionNo from inserted
select @NewD =P_Date from inserted
select @NewA =Loan_Value from inserted

IF @NewA >0
Begin
SELECT @NewB = BALANCE FROM P_LOAN WHERE L_PENSIONNO= @TheNo
Update P_Loan Set Balance = @NewB-@NewA WHERE L_PENSIONNO= @TheNo
end

Thankes


 
Old July 12th, 2004, 11:33 PM
Authorized User
 
Join Date: Apr 2004
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Based on the snippet you've posted, I'm assuming you are working on SQL Server. Does this trigger fail to compile for you, or does it not do exactly what you want it to do. If the former, please post the error message. If the latter, please explain what functional changes you would like to see.

Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.