Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Triggers (How to use parameters ?)

Status
Not open for further replies.

sogibear

Programmer
Jul 4, 2002
45
GB
Hello,

I have two tables tblProgrammeTimeslot and tblProgramme

tblProgrammeTimeslot : ProgID, tSlotID
record e.g ProgID=278, TslotId=2550

tblProgramme : ProgrammeID, Mon, Tue, Wed, Thu, Fri, Sat, Sun
record e.g ProgID=278, Mon=2550, Tue=112,Wed=0,Thu=560,Fri=0,Sat=100,Sun=0

I'm trying to write a trigger on tblProgrammeTimeslot so that when i delete the example record 'ProgID=278, TslotId=2550', the trigger looks up record 278 in tblProgramme and updates Mon=0.

As you cannot use parameters trigger's i have no idea how to do this.


Any help would be greatly appreciated
Thanks
:)
 
As your datamodel is askew, the query becames unnecessay complicated

Code:
creater trigger sbTr1 on tblProgrammeTimeslot for delete 
as
updDate tblProgramme
  set mon = case when mon = d.Tslotid then 0 else mon end,
      tis = case when tis = d.Tslotid then 0 else tis end,
      wed = case when wed = d.Tslotid then 0 else wed end,
      thu = case when thu = d.Tslotid then 0 else thu end,
      fri = case when fri = d.Tslotid then 0 else fri end,
      sat = case when sat = d.Tslotid then 0 else sat end,
      sun = case when sun = d.Tslotid then 0 else sun end
 from tblProgramme, deleted d
 where tblProgramme.ProgrammeID = d.ProgID
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top