diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MySQL/Plugins/DeleteResources.sql	Thu Jul 04 07:44:39 2024 +0200
@@ -0,0 +1,23 @@
+DROP PROCEDURE IF EXISTS DeleteResources;
+
+CREATE PROCEDURE DeleteResources(
+    IN p_id BIGINT
+)
+BEGIN
+    DECLARE v_internalId BIGINT@
+    DECLARE done INT DEFAULT FALSE@
+	DECLARE cur1 CURSOR FOR
+		SELECT internalId FROM DeletedResources@
+	DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = TRUE@
+	set done=FALSE@	
+
+	OPEN cur1@
+	REPEAT
+		FETCH cur1 INTO v_internalId@
+		IF NOT done THEN
+		DELETE FROM Resources WHERE internalId=v_internalId@
+		END IF@
+	UNTIL done END REPEAT@
+	CLOSE cur1@
+
+END;
\ No newline at end of file