Rule to validate SQL syntaxis
Hi! We have received a request to create a new rule on CachéQuality to identify when a developer uses double quotes (" ") within any SQL statement.
We have been asked many times about SQL validation rules, and we would like to open a debate to allow everyone discuss what would you like to be checked on a SQL statement.
Current examples are for basic situations:
- Using SQL.Statement class:
Set stmt = ##CLASS(%SQL.Statement).%New()
Set query = "Select Val1, Val2 FROM Table WHERE Val1=""SomeCondition"""
- Using embedded SQL
&SQL(SELECT Val1, Val2
INTO :val1, :val2
FROM Table
WHERE Val1="SomeCondition")
- Ideally these should be :
Set stmt = ##CLASS(%SQL.Statement).%New()
Set query = "Select Val1, Val2 FROM Table WHERE Val1='SomeCondition'"
&SQL(SELECT Val1, Val2
INTO :val1, :val2
FROM Table
WHERE Val1='SomeCondition')
All your feedback/explanations/requests are welcome!!