view MySQL/Plugins/DeleteResources.sql @ 792:048240f671d2

tools/find: filtering against 'LabelsConstraint': 'None' with an empty list of 'Labels' now returns all resources that do not have any labels attached instead of returning all resources
author Alain Mazy <am@orthanc.team>
date Thu, 15 Jan 2026 12:37:25 +0100
parents d0dd95ff0662
children
line wrap: on
line source

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;