DROP PROCEDURE IF EXISTS public.sp_UpdateOrgAddressFromGAR;

CREATE PROCEDURE public.sp_UpdateOrgAddressFromGAR
(
	addressid int,
	aoguid uuid default null::uuid,
	houseguid uuid default null::uuid
)
    language plpgsql
as
$$
DECLARE 
    p_addressid int := addressid;
    p_aoguid uuid := aoguid;
    p_houseguid uuid := houseguid;
Begin
	update akuz.t_org_address aa
	set 
		aoguid = Coalesce(p_aoguid,aa.aoguid), 
		houseguid = Coalesce(p_houseguid,aa.houseguid)
	where aa.orgaddressid = p_addressid;
End;
$$;