merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

pg_update_product_group.sql (1539B)


      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 SET search_path TO merchant;
     18 
     19 DROP FUNCTION IF EXISTS merchant_do_update_product_group;
     20 CREATE FUNCTION merchant_do_update_product_group (
     21   IN in_instance_id TEXT,
     22   IN in_product_group_serial TEXT,
     23   IN in_name TEXT,
     24   IN in_description TEXT,
     25   OUT out_conflict BOOL,
     26   OUT out_not_found BOOL)
     27 LANGUAGE plpgsql
     28 AS $$
     29 DECLARE
     30   my_merchant_id INT8;
     31 BEGIN
     32 
     33 SELECT merchant_serial
     34   INTO my_merchant_id
     35   FROM merchant_instances
     36   WHERE merchant_id=in_instance_id;
     37 
     38 BEGIN
     39   UPDATE merchant_product_groups SET
     40     product_group_name=in_name
     41    ,product_group_description=in_description
     42    WHERE merchant_serial=my_merchant_id
     43      AND product_group_serial=in_product_group_serial;
     44   out_not_found = NOT FOUND;
     45   out_conflict = FALSE;
     46   RETURN;
     47 EXCEPTION
     48   WHEN unique_violation
     49   THEN
     50     out_conflict = TRUE;
     51     RETURN;
     52 END;
     53 
     54 
     55 END $$;