1: function wp_previous_slide(
2: v_sort_key IN wp_slides.sort_key%TYPE,
3: v_presentation_id IN wp_slides.presentation_id%TYPE,
4: v_checkpoint IN wp_checkpoints.checkpoint%TYPE
5: )
6: return integer is
7: ret integer;
8: begin
9: if v_checkpoint is null then
10: select slide_id into ret
11: from wp_slides
12: where presentation_id = v_presentation_id
13: and max_checkpoint is null
14: and sort_key = (select max(sort_key) from wp_slides
15: where presentation_id = v_presentation_id
16: and max_checkpoint is null
17: and sort_key < v_sort_key);
18: else
19: select slide_id into ret
20: from wp_historical_sort
21: where presentation_id = v_presentation_id
22: and checkpoint = v_checkpoint
23: and sort_key = (select max(sort_key) from wp_historical_sort
24: where presentation_id = v_presentation_id
25: and checkpoint = v_checkpoint
26: and sort_key < v_sort_key);
27: end if;
28: return ret;
29: end;
|