DROP PROCEDURE IF EXISTS sp_SetReadedNews;

CREATE PROCEDURE sp_SetReadedNews
(
	"Id" uuid
,	"Type" varchar(20)
)
AS
$BODY$
Begin
	IF "Type" = 'Regular'
	then
		DELETE FROM VCLib.T_NEWS_BOX_LINK_USERS
		WHERE VCLib.T_NEWS_BOX_LINK_USERS.NewsBoxLinkUsersID = "Id";
	ELSE	
		UPDATE AKUZ.T_NEWS_BOX_ALGOM
		SET Readed = '1'
		WHERE NewsBoxID = "Id";
	end if;
End;
$BODY$
  LANGUAGE plpgsql;
--ALTER FUNCTION sp_SetReadedNews(uuid, varchar(20)) OWNER TO postgres;