Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old January 16th, 2007, 04:34 AM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to AzlanAziz
Default Creating stored procedure with trigger (HOWTO ..)

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())



Similar Threads
Thread Thread Starter Forum Replies Last Post
creating variables in a Stored procedure miamikk SQL Language 1 June 4th, 2007 03:02 AM
Problem creating Stored Procedure vivekshah SQL Server 2000 4 May 28th, 2006 11:33 PM
stored procedure problem with trigger helkayal SQL Server 2000 5 February 22nd, 2005 12:59 AM
creating stored procedure drachx SQL Server 2000 2 October 14th, 2004 08:10 AM
Creating a stored procedure marthaj SQL Server ASP 8 June 10th, 2003 06:08 AM





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