Skip to content

Commit a3f2de9

Browse files
committed
New SP to store processing program messages
1 parent e5d2e2d commit a3f2de9

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
-- Example call:
2+
-- CALL upsert_processing_program_message(@id, 56986673,'ERROR','Hello','Something odd is happening');
3+
4+
DELIMITER ;;
5+
6+
CREATE DEFINER=`ispyb_root`@`%` PROCEDURE `upsert_processing_program_message`(
7+
INOUT p_id int(10) unsigned,
8+
p_programId int(10) unsigned,
9+
p_severity varchar(255),
10+
p_message varchar(255),
11+
p_description text
12+
)
13+
MODIFIES SQL DATA
14+
COMMENT 'Inserts or updates existing row in AutoProcProgramMessage.'
15+
BEGIN
16+
IF NOT (p_programId IS NULL) THEN
17+
INSERT INTO AutoProcProgramMessage (autoProcProgramMessageId, autoProcProgramId, severity, message, description)
18+
VALUES (p_id, p_programId, p_severity, p_message, p_description)
19+
ON DUPLICATE KEY UPDATE
20+
autoProcProgramId = IFNULL(p_programId, autoProcProgramId),
21+
severity = IFNULL(p_severity, severity),
22+
message = IFNULL(p_message, message),
23+
description = IFNULL(p_description, description);
24+
25+
IF p_id IS NULL THEN
26+
SET p_id = LAST_INSERT_ID();
27+
END IF;
28+
ELSE
29+
SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=1644, MESSAGE_TEXT='Mandatory argument p_programId is NULL';
30+
END IF;
31+
END;;
32+
33+
DELIMITER ;

0 commit comments

Comments
 (0)