If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Stored Procedure trigger help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-16-07, 03:28
nalza nalza is offline
Registered User
 
Join Date: Jan 2007
Posts: 1
Stored Procedure trigger help

I have 3 relational tables:

Boat - Boatname,sailNo(PK),
Cook - MemberNo(PK),name,SailNo(FK)
ClubCompetition - CompID(PK),endtime,SailNo(FK)

Boat may or may not have a cook and can enter 1 or more ClubCompetition
how do i create stored procedure with trigger so that i can update
only the tables with user supply input(let say table Boat and ClubCompetition only)
MemberNo is an autogenerateid so whenever i execute the procedure the cook table will be filled with
an ID and SailNo(foreignkey for table Boat)

CREATE PROCEDURE InsSamples
@BoatName varchar(150),
@MemberNo varchar(150),
@name varchar(150),
@endtime datetime
@Whatever
AS
Begin
Set NoCount on
Insert Boat(BoatName)
Values(@Boatname)

Insert into Cook
(MemberNo,name,SailNo)
Values
(@MemberNo,@name,scope_identity())

Insert into ClubCompetition
(CompID,endtime,SailNo)
Values
(@CompID,endtime,scope_identity())

---------------------------------------------------------------------
i tried to test this logic but it doesn't work out .
if MemberNo.Cook IS NOT NULL then
Insert into Cook
(MemberNo,name,SailNo)
Values
(@MemberNo,@name,scope_identity())
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On