update_category.sql (1374B)
1 -- 2 -- This file is part of TALER 3 -- Copyright (C) 2025 Taler Systems SA 4 -- 5 -- TALER is free software; you can redistribute it and/or modify it under the 6 -- terms of the GNU General Public License as published by the Free Software 7 -- Foundation; either version 3, or (at your option) any later version. 8 -- 9 -- TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 -- A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 -- 13 -- You should have received a copy of the GNU General Public License along with 14 -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 -- 16 17 DROP FUNCTION IF EXISTS merchant_do_update_category; 18 CREATE FUNCTION merchant_do_update_category ( 19 IN in_category_serial INT8, 20 IN in_category_name TEXT, 21 IN in_category_name_i18n JSONB, 22 OUT out_conflict BOOL, 23 OUT out_not_found BOOL) 24 LANGUAGE plpgsql 25 AS $$ 26 BEGIN 27 28 BEGIN 29 UPDATE merchant_categories SET 30 category_name=in_category_name 31 ,category_name_i18n=in_category_name_i18n 32 WHERE category_serial=in_category_serial; 33 out_not_found = NOT FOUND; 34 out_conflict = FALSE; 35 RETURN; 36 EXCEPTION 37 -- category_name already used by another category 38 WHEN unique_violation 39 THEN 40 out_not_found = FALSE; 41 out_conflict = TRUE; 42 RETURN; 43 END; 44 45 END $$;