camper/deploy/add_amenity.sql

24 lines
640 B
MySQL
Raw Normal View History

-- Deploy camper:add_amenity to pg
-- requires: roles
-- requires: schema_camper
-- requires: amenity
begin;
set search_path to camper, public;
create or replace function add_amenity(company_id integer, label text, name text, info1 text, info2 text) returns integer as
$$
insert into amenity (company_id, label, name, info1, info2)
values (company_id, label, name, xmlparse(content info1), xmlparse(content info2))
returning amenity_id
;
$$
language sql
;
revoke execute on function add_amenity(integer, text, text, text, text) from public;
grant execute on function add_amenity(integer, text, text, text, text) to admin;
commit;