Procedure for Saving Address Information
/**
-----------------------------------------------------------------------------------------
-- Stored Proc Name:
-- Author :
-- Date Created :
-- Version : 1.0
-- Last Revision :
-- Function :
-- :
-------------------------------------------------------------------------------------------
**/
CREATE PROCEDURE [dbo].[eCspAddressInfoSave]
(
@AddressID INT,
@RefID INT,
@RefType VARCHAR(50),
@Street VARCHAR(50)=Null,
@Location VARCHAR(50)=Null,
@City VARCHAR(50)=Null,
@State INT=0,
@Country INT=0,
@Zip VARCHAR(50)=Null,
@Phone1 VARCHAR(50)=Null,
@Phone2 VARCHAR(50)=Null,
@Fax VARCHAR(50)=Null,
@Email VARCHAR(200)=Null,
@CreatedBy VARCHAR(50)=Null,
@ModifiedBy VARCHAR(50)=Null
)
AS
DECLARE @RECORDCOUNT INT
SET @RECORDCOUNT=0
SELECT @RECORDCOUNT=COUNT(*)
FROM AddressInfo
WHERE AddressID=@AddressID
IF @RECORDCOUNT=0
BEGIN
INSERT INTO AddressInfo (
RefID,
RefType,
Street,
Location,
City,
State,
Country,
Zip,
Phone1,
Phone2,
Fax,
Email,
CreatedBy,
CreatedDate,
ModifiedBy,
ModifiedDate
)
VALUES (
@RefID,
@RefType,
@Street,
@Location,
@City,
@State,
@Country,
@Zip,
@Phone1,
@Phone2,
@Fax,
@Email,
@CreatedBy,
GETDATE() ,
@ModifiedBy,
GETDATE()
)
Select @AddressID=@@Identity
END
ELSE
BEGIN
UPDATE AddressInfo
SET
RefID=@RefID,
RefType=@RefType,
Street=@Street,
Location=@Location,
City=@City,
State=@State,
Country=@Country,
Zip=@Zip,
Phone1=@Phone1,
Phone2=@Phone2,
Fax=@Fax,
Email=@Email,
ModifiedBy=@ModifiedBy,
ModifiedDate=GETDATE()
WHERE AddressID=@AddressID
END
select @AddressID as AddressID
IF @@error!=0
BEGIN
RAISERROR 20001 'eCspAddressInfoSave: Failed Insert/Updae Records Into eCtblAddressInfo'
RETURN(1)
END
RETURN(0)
Monday, July 6, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment