Вы находитесь на странице: 1из 2

CREATE PROCEDURE RetrieveRequests AS BEGIN SELECT c.CustomerId, c.Address, c.City, c.State, c.Country, c.PhoneNo, c.MobileNo, c.EmailId, c.IsActive, a.

AccTypeId FROM Customers c INNER JOIN Accounts a ON c.CustomerId=a.CustomerId where c.IsActive='Pending'; END EXECUTE RetrieveRequests CREATE PROCEDURE ApproveRequests @custId int AS BEGIN Update Customers SET IsActive='Inactive' where IsActive='Active' AND CustomerId=@custId; Update Customers SET IsActive='Active' where IsActive='Pending' AND CustomerId=@custId; END EXECUTE ApproveRequests 909 CREATE PROCEDURE DisplayAccountCreationRequests AS BEGIN DECLARE @custid int DECLARE @address varchar(100) DECLARE @city varchar(50) DECLARE @state varchar(50) DECLARE @country varchar(50) DECLARE @phonenumber bigint DECLARE @mob bigint DECLARE @email varchar(50) DECLARE @status varchar(50) DECLARE @accountnumber bigint DECLARE @accounttype int DECLARE @balance float DECLARE ccursor CURSOR FOR SELECT c.CustomerId, c.Address, c.City, c.State, c.Country, c.PhoneNo, c.MobileNo, c.EmailId, c.IsActive, a.AccountNo, a.AccTypeId,a.Bala nce FROM Customers c INNER JOIN Accounts a ON c.CustomerId=a.CustomerId where c.IsActive='New'; OPEN ccursor FETCH NEXT FROM ccursor INTO @custid, @address, @city, @state, @country, @phonenumber, @mob,

@email, @status, @accountnumber, @accounttype, @balance WHILE @@FETCH_STATUS=0 BEGIN if @accounttype=3 SELECT ContactName,Website FROM CurrentAccounts WHERE Ac countNo=@accountnumber FETCH NEXT FROM ccursor INTO @custid, @addres s, @city, @state, @country, @phonenumbe r, @mob, @email, @status, @accountnum ber, @accounttyp e, @balance END CLOSE ccursor DEALLOCATE ccursor END EXECUTE DisplayAccountCreationRequests

-------------------------------------------------------------------------------INSERT INTO Transactions VALUES(1,@accountnumber,@transactionamount, ELSE SET @flag='Insufficient Balance' ELSE IF @bal>=@transactionamount UPDATE Accounts SET Balance=Balance-@transactionamount WHERE Acc ountNo=@accountnumber; ELSE SET @flag='Insufficient Balance' PRINT @flag END DECLARE @flago varchar; EXEC CheckMinBalance @accountnumber=1010000, @accounttypename='SavingsRegular', @transactionamount=50000, @flag=@flago OUTPUT;

Вам также может понравиться