camper/deploy/edit_surroundings_highlight...

26 lines
880 B
PL/PgSQL

-- Deploy camper:edit_surroundings_highlight to pg
-- requires: roles
-- requires: schema_camper
-- requires: surroundings_highlight
begin;
set search_path to camper, public;
create or replace function edit_surroundings_highlight(highlight_id integer, media_id integer, name text, description text) returns integer as
$$
update surroundings_highlight
set media_id = coalesce(edit_surroundings_highlight.media_id, surroundings_highlight.media_id)
, name = edit_surroundings_highlight.name
, description = xmlparse(content edit_surroundings_highlight.description)
where surroundings_highlight_id = highlight_id
returning surroundings_highlight_id;
$$
language sql
;
revoke execute on function edit_surroundings_highlight(integer, integer, text, text) from public;
grant execute on function edit_surroundings_highlight(integer, integer, text, text) to admin;
commit;