odbc: avoid mistake error retrieve rows from sybase when protocol 5 sybase with reserved words - McKAY brothers, multimedia emulation and support

About McKAY's blog

ads

Post Top Ad

Your Ad Spot

2020/02/23

odbc: avoid mistake error retrieve rows from sybase when protocol 5 sybase with reserved words

When executing SELECT * FROM SYSOPTIONS WHERE "option" LIKE '%key%' the results are different in Freedts ODBC rather than Sysbase ODBC or Central, reasons are simple and how to avoid are showed in this article!
Here were show how to avoid those little mistakes, it's not faults of ODBC freetds (versions 0.81, 0.86, 0.91 or 0.95 that returns 0 rows if you typed bad the sql sentence), here are the reasons and how to correctly make it!
The freedts ODBC are a good made piece of software, reserver keyworks must be used with single ( ) quotes and not with double (") quotes  as SQL standar said! lest get see the problem:


error-freedts-rowscount
if you used "*" event "option" you got the values, and so then the problems here are the reserved keyword option, so i got a workaround by using ` in the query event using " and got results... so but "why" its confused and use the `"` in the querys'? well as in the picture, i see that the very stupid sybase tools use that for reserved keyword i try stupidy to use at the freetds, but that are non-standar way due reserved keywords must be using with single quotes  ` and not double quotes " see the examples output below:
SQL> SELECT "option" FROM master..SYSOPTIONS
+---------+
| 'option'|
+---------+
| option  |
/*.... more results cutted due i pasted in less space....*/
| option  |
+---------+
SQLRowCount returns 151
151 rows fetched
SQL> 
SQL> SELECT `option` FROM SYSOPTIONS WHERE `option` LIKE '%key%'
+---------------------------------------------------------------------------------------------------------------------------------+
| option                                                                                                                          |
+---------------------------------------------------------------------------------------------------------------------------------+
| non_keywords                                                                                                                    |
| reserved_keywords                                                                                                               |
| prevent_article_pkey_update                                                                                                     |
| secure_feature_key                                                                                                              |
+---------------------------------------------------------------------------------------------------------------------------------+
SQLRowCount returns 4
4 rows fetched
SQL>

No hay comentarios.:

Publicar un comentario

no stupid winbuntu users allowed!

Entradas populares

Post Top Ad

Your Ad Spot