All pastes #939435 Raw Edit

Stuff

public sql v1 · immutable
·published 2008-03-12 08:46 UTC
rendered paste body
                DECLARE pl_dyn CURSOR FOR SELECT id, `start`, `stop`, duration,  or_id FROM v_playlist_record WHERE type='dynamic' ORDER BY start;                                DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;                OPEN pl_dyn;                REPEAT                        FETCH pl_dyn INTO c_id, c_start, c_stop, c_duration, c_or_id;			IF (c_id != g_id) THEN						 SET g_id = c_id;						IF(g_laststop = 0) THEN				SET g_laststop = c_start;			END IF;						IF (g_laststop != c_stop) THEN				UPDATE playlist SET `start` = g_laststop WHERE id = c_id;                          END IF;                        			SET g_laststop = g_laststop + c_duration;						END IF;                UNTIL done                 END REPEAT;