annotate MySQL/Plugins/DeleteResources.sql @ 521:2ab3d45c0b3c large-queries

merge default -> large-queries
author Alain Mazy <am@orthanc.team>
date Thu, 04 Jul 2024 07:44:39 +0200
parents d0dd95ff0662
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
424
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
1 DROP PROCEDURE IF EXISTS DeleteResources;
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
2
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
3 CREATE PROCEDURE DeleteResources(
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
4 IN p_id BIGINT
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
5 )
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
6 BEGIN
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
7 DECLARE v_internalId BIGINT@
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
8 DECLARE done INT DEFAULT FALSE@
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
9 DECLARE cur1 CURSOR FOR
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
10 SELECT internalId FROM DeletedResources@
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
11 DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = TRUE@
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
12 set done=FALSE@
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
13
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
14 OPEN cur1@
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
15 REPEAT
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
16 FETCH cur1 INTO v_internalId@
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
17 IF NOT done THEN
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
18 DELETE FROM Resources WHERE internalId=v_internalId@
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
19 END IF@
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
20 UNTIL done END REPEAT@
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
21 CLOSE cur1@
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
22
95c413106a66 Introduced a procedure to delete resources (to be tested)
Alain Mazy <am@osimis.io>
parents:
diff changeset
23 END;