Reputation: 1447
I am having trouble with the CASE
statement in this procedure:
DELIMITER //
CREATE PROCEDURE getRowsByHourHalfday(xhour smallint)
BEGIN
SET @twelveless = xhour - 12;
SELECT CASE
WHEN (xhour, > 11) THEN SET @realhour = ( xhour - 12);
ELSE SET @realhour = xhour;
END CASE;
SET @first = @realhour * 60;
SET @next = @first + 59;
SELECT * FROM mydb.halfday WHERE minutepart BETWEEN @first AND @next;
END //
DELIMITER ;
This is the pseudo-code for what I am trying:
if hour > 11 then
set newhour = hour - 12;
set first = newhour * 60;
else
set first = hour * 60;
endif
select * from halfday where minutepart between first and (first + 60);
Upvotes: 0
Views: 633
Reputation: 735
Instead of your SELECT CASE
statement, through to END CASE
, you should have the following:
SET @realhour = CASE WHEN xhour > 11 THEN xhour - 12 ELSE xhour END CASE
Upvotes: 3