-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsp_tool_set_google_channel.sql
More file actions
39 lines (30 loc) · 1.22 KB
/
sp_tool_set_google_channel.sql
File metadata and controls
39 lines (30 loc) · 1.22 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
drop procedure if exists sp_tool_set_google_channel;
/*
Add an entry to the tl_google_notifications table. Either updates existing record,
or creates a new one if a record with the same channel_id doesn't exist.
p_expiration is expected to be a Unix timestamp.
*/
DELIMITER //
CREATE PROCEDURE sp_tool_set_google_channel
(
IN p_tool_id int,
IN p_resource_id varchar(256),
IN p_channel_token varchar(256),
IN p_channel_id varchar(256),
IN p_expiration int
)
SQL SECURITY DEFINER
BEGIN
main: begin
declare l_expiration timestamp;
set l_expiration = FROM_UNIXTIME(p_expiration);
insert into tl_google_notifications ( channel_id, tool_id, channel_token, resource_id, channel_expiration)
values (p_channel_id, p_tool_id, p_channel_token, p_resource_id, l_expiration)
on duplicate key update
tool_id = values(tool_id),
channel_token = values(channel_token),
resource_id = values(resource_id),
channel_expiration= values(channel_expiration);
end main;
END //
DELIMITER ;