CREATE PROCEDURE addadult
@lastname shortstring,
@firstname shortstring,
@middleinitial letter = NULL,
@street shortstring = NULL,
@city shortstring = NULL,
@state statecode = NULL,
@zip zipcode = NULL,
@phone_no phonenumber = NULL
AS
DECLARE @member_no member_no
IF @middleinitial = NULL OR
@street = NULL OR
@city = NULL OR
@state = NULL OR
@zip = NULL OR
@phone_no = NULL
BEGIN
PRINT " "
PRINT " Please reenter this Adult Member."
PRINT " You must provide Last name, First name, Middle initial, "
PRINT " Street, City, State, Zip, and Phone number."
PRINT " "
RETURN
END
BEGIN TRANSACTION
SELECT @member_no = (SELECT max(member_no) FROM member HOLDLOCK) + 1
INSERT member
( member_no, lastname, firstname, middleinitial, photograph)
VALUES
(@member_no, @lastname, @firstname, @middleinitial, NULL )
IF @@error <> 0
BEGIN
ROLLBACK TRAN
RETURN
END
INSERT adult
( member_no, street, city, state, zip, phone_no, expr_date)
VALUES
(@member_no, @street, @city, @state, @zip, @phone_no, dateadd(year,1,getdate()) )
IF @@error != 0
BEGIN
ROLLBACK TRAN
RETURN
END
PRINT " "
PRINT " *** Adult Member added *** "
PRINT " "
COMMIT TRANSACTION
GO