field table transaksi : no_faktur, jumlah, quantity
field table history: no_faktur, total (yg merupakan jumlah*quantity)
CREATE TRIGGER triggerUpdate
ON tTransaksi
FOR Update
AS
declare @faktur varchar(50),
@nilai decimal
declare csUpdate cursor for
select a.no_faktur,a.qty * a.jumlah from inserted a
inner join deleted b on a.no_faktur=b.no_faktur
open csupdate
fetch csupdate into @faktur,@nilai
while not @@fetch_status=0
begin
update thistory set [EMAIL PROTECTED] where [EMAIL PROTECTED]
fetch csupdate into @faktur,@nilai
end
close csupdate
deallocate csupdate
Salam
Ronald Irawan
Pt. Sanghiang Perkasa
Gd. Graha Kirana Lt.5
Jl Yos Sudarso Kav.88
Jakarta
| "Fountain Melody"
<[EMAIL PROTECTED]>
Sent by: [email protected] 20/06/2005 10:26 AM
|
|
Halo Pak Ronald,
Yang mau diupdate yang field total.
trigger updatenya seperti ini:
CREATE TRIGGER triggerTest
ON tTransaksi
FOR INSERT
AS
if exists(select * from inserted)
begin
insert into tHistory
select no_faktur, qty*jumlah from inserted
end
go
----- Original Message -----
From: Ronald Irawan
To: [email protected]
Sent: Monday, June 20, 2005 10:27 AM
Subject: Re: [Programmer-VB] Trigger Update
Yg mau di Update yg mana ?
atau coba copykan script trigger insert anda di sini...
Salam
Ronald Irawan
Pt. Sanghiang Perkasa
Gd. Graha Kirana Lt.5
Jl Yos Sudarso Kav.88
Jakarta
| "Fountain Melody"
<[EMAIL PROTECTED]>
Sent by: [email protected] 20/06/2005 10:14 AM
|
|
Halo semua rekan programer,
Saya sedang develop sebuah aplikasi dengan database MS SQL 2000.
Saya punya dua table, yang pertama table transaksi, dan yang kedua table history.
Supaya simple, anggap aja :
field table transaksi : no_faktur, jumlah, quantity
field table history: no_faktur, total (yg merupakan jumlah*quantity)
Saya sudah menciptakan suatu trigger untuk insert dan delete, sehingga kedua table tersebut selalu sinkron, tapi saya tidak menemukan cara trigger untuk update, ada yang bisa bantu memberikan solusinya?
sebelumnya saya ucapkan terimakasih.
Untuk keluar dari millis ini, kirim email kosong ke:
[EMAIL PROTECTED]
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/Programmer-VB/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Untuk keluar dari millis ini, kirim email kosong ke:
[EMAIL PROTECTED]
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.7.8/22 - Release Date: 06/17/2005
Untuk keluar dari millis ini, kirim email kosong ke:
[EMAIL PROTECTED]
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/Programmer-VB/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Untuk keluar dari millis ini, kirim email kosong ke:
[EMAIL PROTECTED]
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/Programmer-VB/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
