Files
database/migrations/000.428.sql
T
2023-07-07 15:58:41 +02:00

31 lines
917 B
PL/PgSQL

-- PROCEDURE: public.stockproduct_create(text, text, text, integer, integer, integer, integer)
DROP PROCEDURE IF EXISTS public.stockproduct_create;
CREATE OR REPLACE PROCEDURE public.stockproduct_create(
_article_number text,
_name text,
_path text,
_visible integer DEFAULT 0,
_browsable integer DEFAULT 0,
INOUT _product_id integer DEFAULT NULL::integer,
INOUT _stock_id integer DEFAULT NULL::integer)
LANGUAGE 'plpgsql'
AS $BODY$
BEGIN
INSERT INTO "product-products" (path, visible, browsable)
VALUES (_path, _visible, _browsable)
RETURNING productid INTO _product_id;
INSERT INTO "product-products_fields" (productid, fieldid, value)
VALUES
(_product_id, 1, _article_number),
(_product_id, 2, _name);
INSERT INTO stockproducts (product_id, name, in_stock)
VALUES (_product_id, _name, true)
RETURNING id INTO _stock_id;
END;
$BODY$;