Write me a generic SQL statement(s) that sets path_id = 331000 for a creature with guid = 33100 without first checking if there is a creature_addon entry for that guid that may have mount, bytes1, bytes2 and emote fields set with values that we want to preserve.
Here’s how you would do it if the tables were normalized properly:
UPDATE creature SET path_id = 331000 WHERE guid = 33100;
Using replace would be a better way to go. Catching an exception on the delete is pretty ugly.
The point I was trying to make is that the sql statements you have to make with the current tables are a lot more complicated than if the tables were normalized properly.
SET @GUID = 33100;
SET @MOUNT =(select mount from creature_addon where guid=@GUID);
SET @BYTES1 =(select bytes1 from creature_addon where guid=@GUID);
SET @BYTES2 =(select bytes2 from creature_addon where guid=@GUID);
SET @EMOTE =(select emote from creature_addon where guid=@GUID);
SET @AURAS =(select auras from creature_addon where guid=@GUID);
REPLACE INTO creature_addon
SET path_id = @GUID*100, guid = @GUID, mount = @MOUNT, bytes1 = @BYTES1, bytes2 = @BYTES2, emote = @EMOTE, auras = @AURAS;
ITS cool or not ?? /emoticons/default_smile.png Damn we have to set ISNULL or COALESCE when is null value cause it will make an error and I don’t know how to do this.
baric, I am with you. I makes absolutely no sense to have the _addon tables. Way back when, it made sense due to the fact that not all creatures needed those fields, and it was a waste of DB space. That is still true, but the small gain you get just isn’t worth it anymore.
In large relational databases, it makes sense to break things out into as many tables as possible if there would be a lot of NULL values, TDB isn’t a large database…
Long ago, I said a lot of tables need to be combined for ease of use, and was told that they were done that way because that is how they are sent in the packets to and from the sever, as if the code to send packets can’t pull out just the info it needs to send from a larger set of fields… if this thinking always won out, we might still have the player blob… shudders