Skip to content

Commit 3929eb4

Browse files
authored
Add procedure to retrieve recipes by status with pagination (#26)
1 parent 1b97ff1 commit 3929eb4

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

procedures/get/recipe.sql

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,26 @@ BEGIN
192192
);
193193
END //
194194

195+
-- Procedure for retrieving recipes by status with pagination
196+
CREATE OR REPLACE PROCEDURE get_recipes_by_status_paginated(
197+
IN p_status_name INT,
198+
IN p_limit INT,
199+
IN p_offset INT,
200+
IN p_language_iso_code CHAR(2)
201+
)
202+
BEGIN
203+
DECLARE v_status_id INT;
204+
SELECT status_id INTO v_status_id
205+
FROM recipe_status
206+
WHERE status_name = p_status_name;
207+
IF v_status_id IS NULL THEN
208+
v_status_id = 1; -- Default to 'draft' (status_id = 1) if the status name is not found
209+
END IF;
210+
211+
CALL get_recipes_paginated(
212+
'AND r.recipe_status = ?',
213+
p_limit, p_offset, p_language_iso_code, NULL, NULL, NULL, v_status_id
214+
);
215+
END //
216+
195217
DELIMITER ;

0 commit comments

Comments
 (0)