Question on expression format

Which is correct? PI_NO is a REF to to a table where PI_NO is the key with a number type. I know that is not the best to use for a key but the admin will always control this and it will only be changed at the data source.

OR([PI_NO]=1,[PI_NO]=2,[PI_NO]=3,[PI_NO]=4)

OR([PI_NO]=“1”,[PI_NO]=“2”,[PI_NO]=“3”,[PI_NO]=“4”)

Are they interchangeable? Are “” only needed if the data type was text?

Solved Solved
0 4 157
1 ACCEPTED SOLUTION

Steve
Platinum 4
Platinum 4

Strictly speaking, within expressions, quotes are needed only to ensure the value isn’t misinterpreted as a keyword or special character, so 1 and "1" should be equivalent. To ensure textual values are always interpreted as such, I strongly recommend always quoting textual values. Likewise, temporal values contain special characters that would be misinterpreted, so should also be quoted. Numeric values are unlikely to be misinterpreted, so I don’t recommend quotes for them. Essentially, any raw value that isn’t numeric should be quoted.

View solution in original post

4 REPLIES 4

Steve
Platinum 4
Platinum 4

Strictly speaking, within expressions, quotes are needed only to ensure the value isn’t misinterpreted as a keyword or special character, so 1 and "1" should be equivalent. To ensure textual values are always interpreted as such, I strongly recommend always quoting textual values. Likewise, temporal values contain special characters that would be misinterpreted, so should also be quoted. Numeric values are unlikely to be misinterpreted, so I don’t recommend quotes for them. Essentially, any raw value that isn’t numeric should be quoted.

Steve
Platinum 4
Platinum 4

Oh, and more efficient:

IN([PI_NO], {1, 2, 3, 4})

Great. Thanks for all the info.

Bahbus
New Member

As @Steve already stated.

I never put quotes around my numerical values. Unless I explicitly am making them a part of some other text.

Top Labels in this Space