Toad World® Forums

Using Reserved Words in Where Condition

TDP 5.0
When using Query Builder and the filtering criteria contains a SQL reserved word, this can cause problems with formatting the SQL.

Example:
Goal is to return information where NAME = 'Power Stop'. When entering this criteria either by keying in Power Stop, or by using the drop-down list option, TDP will interpret the 'Power' part of the criteria as a SQL reserved word for the POWER function and TDP will not encapsulate the criteria with single quotes. Note also how TDP formats the Power as POWER.

SELECT INVENTORY_BRAND.NAME,
INVENTORY_BRAND.BRAND_ID,
INVENTORY_BRAND.FLAG_STATUS
FROM INVENTORY_BRAND INVENTORY_BRAND
WHERE (INVENTORY_BRAND.NAME = POWER Stop)

Running this SQL will fail and return an error. The workaround is to return to the where criteria and encapsulate the criteria in single quotes and in this particular case to correct POWER to Power.

SELECT INVENTORY_BRAND.NAME,
INVENTORY_BRAND.BRAND_ID,
INVENTORY_BRAND.FLAG_STATUS
FROM DW_ORDER.INVENTORY_BRAND INVENTORY_BRAND
WHERE (INVENTORY_BRAND.NAME = 'Power Stop')

This does not occur when keying or selecting other multi-word criteria, seems to only occur when a reserved/key word is involved. Example: criteria of AFE Power will also cause an error.

Since the workaround is simple, I would categorize this as a minor bug.

I entered QAT-15042 for this issue.