-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStored_procedure_example
More file actions
30 lines (29 loc) · 953 Bytes
/
Copy pathStored_procedure_example
File metadata and controls
30 lines (29 loc) · 953 Bytes
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
DROP PROCEDURE IF Exists get_filteredTickets_New;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `get_filteredTickets_New`(
IN `pTicketId` INT,
IN `pDisplayName` VARCHAR(255),
IN `pStartDate` DATE,
IN `pEndDate` DATE,
IN `pSkip` INT,
IN `pLimit` INT
)
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
SELECT * FROM tickets WHERE
CASE
when (pTicketId > 0) then
tickets.ticketId = pTicketId
when pDisplayName <> '' AND pStartDate = 0 and pEndDate = 0 then
tickets.content like CONCAT ('%', pDisplayName, '%')
when pStartDate > 0 AND pEndDate > 0 then
DATE(createdAt) >= pStartDate AND DATE(createdAt) <= pEndDate
when pDisplayName <> '' AND pStartDate > 0 and pEndDate > 0 then
tickets.content like CONCAT ('%', pDisplayName, '%') AND DATE(createdAt) >= pStartDate AND DATE(createdAt) <= pEndDate
END
limit pSkip,pLimit;
END$$