1: function wp_migrate_slide
2: (v_presentation_id IN wp_presentations.presentation_id%TYPE,
3: v_slide_id IN wp_slides.slide_id%TYPE)
4: return wp_slides.slide_id%TYPE is
5: latest_checkpoint wp_checkpoints.checkpoint%TYPE;
6: should_migrate integer;
7: new_slide_id integer;
8: begin
9: select max(checkpoint) into latest_checkpoint
10: from wp_checkpoints
11: where presentation_id = v_presentation_id;
12: select count(*) into should_migrate
13: from wp_slides
14: where slide_id = v_slide_id
15: and min_checkpoint < (select max(checkpoint) from wp_checkpoints where presentation_id = v_presentation_id)
16: and max_checkpoint is null;
17: if should_migrate > 0 then
18: select wp_ids.nextval into new_slide_id from dual;
19: update wp_slides
20: set max_checkpoint = latest_checkpoint
21: where slide_id = v_slide_id;
22: insert into wp_slides(slide_id, presentation_id, modification_date, sort_key, min_checkpoint, include_in_outline_p, context_break_after_p,
23: title, preamble, bullet_items, postamble, original_slide_id)
24: select new_slide_id, presentation_id, modification_date, sort_key, latest_checkpoint, include_in_outline_p, context_break_after_p,
25: title, preamble, bullet_items, postamble, nvl(original_slide_id, slide_id)
26: from wp_slides
27: where slide_id = v_slide_id;
28: insert into wp_attachments(attach_id, slide_id, attachment, file_size, file_name, mime_type, display)
29: select wp_ids.nextval, new_slide_id, attachment, file_size, file_name, mime_type, display
30: from wp_attachments
31: where slide_id = v_slide_id;
32: return new_slide_id;
33: else
34: return v_slide_id;
35: end if;
36: end;
|