sunil.bablani
April 25th, 2009, 03:06 AM
i ve these two tables, i am working on sql server 2005
create table loan_details
(
l_ac_no int identity(100001,1) ,
cust_name char(30), cust_address varchar(80), occupation char(30),
phone bigint, income money, loan_date datetime, loan_amt money, duration int,
chq_no char(20), chq_amt money , rem_amt money ,
roi float, intr_amt money
)
create table installment_details
(
tr_id int identity(1,1) primary key,
l_ac_no int,
cust_name char(30), instalment money, no_of_mts int,
interest money, date_interest datetime
)
now i ve created a trigger :
create trigger trginsertinst on installment_details
for insert
as
update installment_details set interest = instalment * roi /100
from installment_details join loan_details on
installment_details.l_ac_no = loan_details.l_ac_no
update loan_details set rem_amt = rem_amt - instalment, duration = duration - no_of_mts,
intr_amt = intr_amt - interest
from loan_details join inserted
on loan_details.l_ac_no = inserted.l_ac_no
here the problem is intr_amt doesn't gets updated and turns into null.
can u please suggest me something.
can u please help me ?
create table loan_details
(
l_ac_no int identity(100001,1) ,
cust_name char(30), cust_address varchar(80), occupation char(30),
phone bigint, income money, loan_date datetime, loan_amt money, duration int,
chq_no char(20), chq_amt money , rem_amt money ,
roi float, intr_amt money
)
create table installment_details
(
tr_id int identity(1,1) primary key,
l_ac_no int,
cust_name char(30), instalment money, no_of_mts int,
interest money, date_interest datetime
)
now i ve created a trigger :
create trigger trginsertinst on installment_details
for insert
as
update installment_details set interest = instalment * roi /100
from installment_details join loan_details on
installment_details.l_ac_no = loan_details.l_ac_no
update loan_details set rem_amt = rem_amt - instalment, duration = duration - no_of_mts,
intr_amt = intr_amt - interest
from loan_details join inserted
on loan_details.l_ac_no = inserted.l_ac_no
here the problem is intr_amt doesn't gets updated and turns into null.
can u please suggest me something.
can u please help me ?