--
-- pa_photos_f/1
--
create or replace function pa_photos_f(
  p_new pa_photosi
) returns void as $$

             declare
               v_revision_id integer;
             begin

               select content_revision__new(
                                     p_new.title,
                                     p_new.description,
                                     p_new.publish_date,
                                     p_new.mime_type,
                                     p_new.nls_language,
                                     case when p_new.text is null 
                                              then p_new.data 
                                              else p_new.text
                                           end,
                                     content_symlink__resolve(p_new.item_id),
                                     p_new.revision_id,
                                     now(),
                                     p_new.creation_user, 
                                     p_new.creation_ip,
                                     null,                    -- content_length
                                     p_new.object_package_id
                ) into v_revision_id;
                insert into pa_photos ( pa_photo_id, camera_model, story, caption, user_filename, date_taken, flash, exposure_time, aperture, focus_distance, metering, sha256, photographer ) values (v_revision_id, p_new.camera_model, p_new.story, p_new.caption, p_new.user_filename, p_new.date_taken, p_new.flash, p_new.exposure_time, p_new.aperture, p_new.focus_distance, p_new.metering, p_new.sha256, p_new.photographer);
    
   return;
   end;$$ language plpgsql;