-
Notifications
You must be signed in to change notification settings - Fork 24
/
10_fraction.sql
82 lines (67 loc) · 1.48 KB
/
10_fraction.sql
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
81
82
use lin2world
go
ALTER TABLE [user_data] ADD
fraction_id int NOT NULL DEFAULT 0,
fraction_points int NOT NULL DEFAULT 0,
fraction_timestamp int NOT NULL DEFAULT 0
go
CREATE PROCEDURE lin_UpdateUserFraction
(
@charId as INT,
@fractionId as INT,
@fractionPoints as INT,
@fractionTimestamp as INT
)
AS
SET NOCOUNT ON;
BEGIN
UPDATE [user_data] SET [fraction_id] = @fractionId, [fraction_points] = @fractionPoints, [fraction_timestamp] = @fractionTimestamp WHERE [char_id] = @charId
END
go
CREATE PROCEDURE lin_LoadUserFraction
(
@charId as INT
)
AS
SET NOCOUNT ON;
BEGIN
SELECT [fraction_id], [fraction_points], [fraction_timestamp] FROM [user_data] where [char_id] = @charId
END
go
CREATE TABLE FractionData
(
[fraction_id] int NOT NULL DEFAULT 0,
[points] int NOT NULL DEFAULT 0,
[online_members] int NOT NULL DEFAULT 0
)
go
CREATE PROCEDURE lin_LoadFractionData
(
@fractionId as INT
)
AS
SET NOCOUNT ON;
BEGIN
SELECT [points] FROM [FractionData] WHERE [fraction_id] = @fractionId
END
go
CREATE PROCEDURE lin_SaveFractionData
(
@fractionId as INT,
@points as INT,
@onlineMembers as INT
)
AS
SET NOCOUNT ON;
BEGIN
--Add/Update fraction
IF EXISTS(SELECT * FROM [FractionData] WHERE [fraction_id] = @fractionId)
BEGIN
UPDATE [FractionData] SET [points] = @points, [online_members] = @onlineMembers WHERE [fraction_id] = @fractionId
END
ELSE
BEGIN
INSERT INTO [FractionData] ([fraction_id], [points], [online_members]) VALUES (@fractionId, @points, @onlineMembers)
END
END
go