Pazyryk
Deity
- Joined
- Jun 13, 2008
- Messages
- 3,584
I hate to nitpick, but this mis-usage is being propagated by many modders here, even very advanced ones. The weird quoting seems to have evolved from Firaxis' pseudo-SQL XML, and it is not at all correct. It's not just an aesthetic issue. Sure, it works. Until it doesn't. And then you will be scratching your head.
Here's an example pasted from a tutorial thread:
Doesn't matter if you can't follow the SELECT statement (these can make my head spin). The problem is that I can't tell what is a table or column and what is a string literal. The compiler is pretty loose so it gets through it (this time), but only due to blind luck. The correct quoting is like this:
It looks neater, doesn't it? But that's not the main problem here. Here are the basic rules for quotes.
It's worth a quick look at the SQlite FAQ if you are going to add much SQL code.
Here's an example pasted from a tutorial thread:
Code:
INSERT INTO "ArtDefine_UnitInfos" ('Type','DamageStates','Formation')
SELECT ("ART_DEF_UNIT_WW1_FIGHTER_GERMANY"), "DamageStates", "Formation"
FROM "ArtDefine_UnitInfos" WHERE (Type = "ART_DEF_UNIT_WW1_FIGHTER");
Doesn't matter if you can't follow the SELECT statement (these can make my head spin). The problem is that I can't tell what is a table or column and what is a string literal. The compiler is pretty loose so it gets through it (this time), but only due to blind luck. The correct quoting is like this:
Code:
INSERT INTO ArtDefine_UnitInfos (Type,DamageStates,Formation)
SELECT ('ART_DEF_UNIT_WW1_FIGHTER_GERMANY'), DamageStates, Formation
FROM ArtDefine_UnitInfos WHERE (Type = 'ART_DEF_UNIT_WW1_FIGHTER');
It looks neater, doesn't it? But that's not the main problem here. Here are the basic rules for quotes.
- Use single-quotes (not double quotes!) around string literals. This is the SQL standard.
- Don't quote table or column names that are already defined. (You would use single quotes in a CREATE TABLE statement because the table and column names are string literals at that time.)
- The purpose of double quotes in SQL is when you want to use a key word as a table or column name (square brackets also do this). For example, I could create a table called "INSERT" and then I would say INSERT INTO "INSERT"... But that would be pretty stupid. Since there is no reason for you to use a reserved keyword for a table or column name, there is no reason for you to ever use a double quote.
It's worth a quick look at the SQlite FAQ if you are going to add much SQL code.