drop procedure if exists sp_ISZLFLKErrorHandler;
CREATE procedure sp_ISZLFLKErrorHandler
(
	"GuidPackage" varchar(36)
)
AS
$BODY$
Declare	_RdsDispPackage varchar(36);
Begin
	_RdsDispPackage := (select RdsDispPackage from AKUZ.T_RDS_DISP_PACKAGE where RdsdispPackageID = "GuidPackage" limit 1);
	--главный пакет
	if coalesce(_RdsDispPackage, '') = ''
	then
		update AKUZ.T_RDS_DISP_PACKAGE
		set PacketStatus = 2
		where RdsdispPackageID = "GuidPackage";
	else
		update AKUZ.T_RDS_DISP_PACKAGE
		set PacketStatus = 4
		where RdsdispPackageID = "GuidPackage";
	end if;
	return;
End;
$BODY$
  LANGUAGE plpgsql;
