-- =============================================

-- GetAccounts Procedure

-- Retrieves records from the Account table

-- =============================================

CREATE PROCEDURE GetAccounts

AS

      SELECT AccountID, CustomerName, Balance

      FROM Account

 

-- =============================================

-- GetAccountByID Procedure

-- Retrieves a single record from the Account

-- table using the AccountID, which is passed
-- as a parameter to the Stored Procedure

-- =============================================

CREATE PROCEDURE GetAccountByID

      @theID int

 

AS

      SELECT AccountID, CustomerName, Balance

      FROM Account

      WHERE AccountID = @theID

 

-- =============================================

-- MakeDeposit Procedure

-- Updates the Balance for a record in the
-- Account table using the AccountID, which is

-- passed as a parameter to the Stored Procedure

-- =============================================

CREATE PROCEDURE MakeDeposit

      @theID int,

      @theAmount float

     

AS

      UPDATE Account

      SET Balance = Balance + @theAmount

      WHERE AccountID = @theID

 

-- =============================================

-- MakeWithdrawal

-- Updates the Balance for a record in the
-- Account table using the AccountID, which is

-- passed as a parameter to the Stored Procedure

-- =============================================

CERATE PROCEDURE MakeWithdrawal

      @theID int,

      @theAmount float

     

AS

      UPDATE Account

      SET Balance = Balance - @theAmount

      WHERE AccountID = @theID