
// Infos detaillees sur un user pour une case : nom, alliance, embleme d'alliance, id du maitre (=alliance)


CREATE FUNCTION getinfoscase(INTEGER) RETURNS infoscase AS '


DECLARE res infosCase%rowtype;
DECLARE res2 infosCase%rowtype;

BEGIN
	SELECT INTO res user_login, user_guild_name, user_guild_emblem, user_guild_master_id FROM users WHERE user_id=$1;

	IF (res.masterId = $1) THEN
		RETURN res;
	ELSE
		SELECT INTO res2 user_login, user_guild_name, user_guild_emblem, user_guild_master_id FROM users WHERE user_id=res.masterId;
		res2.login = res.login;
		RETURN res2;
	END IF;
END;


END; '
LANGUAGE plpgsql;





CREATE TYPE infosCase AS ( 
	login CHARACTER VARYING,
	guildName CHARACTER VARYING,
	guildEmblem CHARACTER VARYING,
	masterId INTEGER )
	
	
	