PyTd icon indicating copy to clipboard operation
PyTd copied to clipboard

SQL with escape character for LIKE clause can fail with syntax error

Open ericsun2 opened this issue 7 years ago • 1 comments

As long as escape '!' or escape '\\' is following LIKE clause in ODBC mode, PyTd fails into the following error:

 SELECT DatabaseName, PermSpace, DBKind
 FROM DBC.DatabasesV WHERE DatabaseName LIKE 'DW!_%' escape '!' 

ErrorCode = 3706 ErrorMessage = [42000] [Teradata][ODBC Teradata Driver][Teradata Database](-3706)Syntax error: expected something between the word 'TODO' and ':'.

It looks like a parsing error inside PyTd or ODBC code.

Simply remove the escape '!' part, the query will run (of course with 0 rows returned).

The following alternative works too, but LIKE '%!_test!_' escape '!' should be supported.

 SELECT DatabaseName, PermSpace, DBKind
 FROM DBC.DatabasesV WHERE substr(DatabaseName, 1, 3) = 'DW_' 

ericsun2 avatar May 02 '18 06:05 ericsun2

What version of ODBC driver are you using? I had encountered a similar error #90 when using the new Simba drivers which since has been fixed in the later updates.

padhia avatar Jun 13 '18 18:06 padhia