camper/deploy/edit_amenity.sql

28 lines
767 B
PL/PgSQL

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