-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.sql
More file actions
80 lines (44 loc) · 2.18 KB
/
Copy pathupdate.sql
File metadata and controls
80 lines (44 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/****** Object: StoredProcedure [TeamE].[ChangeRegularAccountType] Script Date: 21-11-2019 16:55:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [TeamE].[ChangeRegularAccountType](@AccountNo char(10),@AccountType varchar(10))
as
begin
---THROWING EXCEPTION IF THE ACCOUNT DOESN'T EXISTS
if NOT EXISTS(SELECT * from TeamE.RegularAccount WHERE AccountNo = @AccountNo) AND (len(@AccountNo) = 10) AND (@AccountNo LIKE '1%')
throw 50001,'Account does not exists',1
---THROWING EXCEPTION IF ACCOUNT No IS NULL OR INVALID
if @AccountNo is null OR (len(@AccountNo) <> 10)
throw 50001,'Invalid Account No',1
---THROWING EXCEPTION IF THE ACCOUNT TYPE ENTERED IS NOT VALID
if @AccountType NOT IN ('SAVINGS','CURRENT')
throw 50001,'Account Type entered is invalid',1
---CHANGING THE ACCOUNT TYPE IF ACCOUNT NO MATCHES
update TeamE.RegularAccount
set AccountType = @AccountType,LastModifiedDateTime = SYSDATETIME() where ((AccountNo = @AccountNo)AND(AccountType IN ('Savings','Current')))
end
GO
/****** Object: StoredProcedure [TeamE].[ChangeRegularAccountBranch] Script Date: 21-11-2019 16:54:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [TeamE].[ChangeRegularAccountBranch](@AccountNo char(10),@Branch varchar(30))
as
begin
---THROWING EXCEPTION IF THE ACCOUNT DOESN'T EXISTS
if NOT EXISTS(SELECT * from TeamE.RegularAccount WHERE AccountNo = @AccountNo) AND (len(@AccountNo) = 10) AND (@AccountNo LIKE '1%')
throw 50001,'Account does not exists',1
---THROWING EXCEPTION IF ACCOUNT No IS NULL OR INVALID
if @AccountNo is null OR (len(@AccountNo) <> 10)
throw 50001,'Invalid Account No',1
---THROWING EXCEPTION IF THE HOME BRANCH ENTERED IS NOT VALID
if @Branch NOT IN ('Mumbai','Delhi','Chennai','Bengaluru')
throw 50001,'Home branch entered is invalid',1
---CHANGING THE HOME BRANCH IF ACCOUNT NO MATCHES
update TeamE.RegularAccount
set Branch = @Branch, LastModifiedDateTime = SYSDATETIME() where ((AccountNo = @AccountNo)AND(Branch IN ('Mumbai','Delhi','Chennai','Bengaluru')))
end
GO