
CREATE OR REPLACE PROCEDURE tcg.public.USP_Error_Clear (
      a_guid UUID
)
LANGUAGE plpgsql
AS $$
DECLARE
	v_guid UUID;
BEGIN

	v_guid := a_guid::UUID;

    DELETE
    FROM tcg.public.Error ERROR
    WHERE ERROR.guid = v_guid
    ;

    COMMIT;
	
END;
$$;


-- Call it with:
DO $$
DECLARE
    v_guid UUID := CAST('1d7a1ade-daf4-4736-946e-a3e8a2097c07' AS UUID);
BEGIN
	-- v_guid := gen_random_uuid();

    CALL tcg.public.USP_Error_Clear (
		  a_guid := v_guid
	);

END;
$$;

SELECT *
-- DELETE
FROM tcg.public.Error ERROR
LEFT JOIN tcg.public.Error_Type ERROR_TYPE ON ERROR.error_type_id = ERROR_TYPE.error_type_id
;
