camper/deploy/edit_campsite.sql

30 lines
901 B
MySQL
Raw Normal View History

-- Deploy camper:edit_campsite to pg
-- requires: roles
-- requires: schema_camper
-- requires: campsite
begin;
set search_path to camper, public;
drop function edit_campsite(integer, integer, text, boolean);
create or replace function edit_campsite(campsite_id integer, campsite_type integer, new_label text, new_info1 text, new_info2 text, active boolean) returns integer as
$$
update campsite
set label = edit_campsite.new_label
, campsite_type_id = edit_campsite.campsite_type
, info1 = xmlparse(content new_info1)
, info2 = xmlparse(content new_info2)
, active = edit_campsite.active
where campsite_id = edit_campsite.campsite_id
returning campsite_id;
$$
language sql
;
revoke execute on function edit_campsite(integer, integer, text, text, text, boolean) from public;
grant execute on function edit_campsite(integer, integer, text, text, text, boolean) to admin;
commit;