Dear folks,
   The database system I am working with here uses the caret, "^", as in
"SELECT ^Select^ AS ^AS^ FROM ^FROM^ WHERE ^Where^ = 1"
and this is why JDBC has the method DatabaseMetaData.getIdentifierQuoteString().
So, is JDBC ugly because it is Java or because it is SQL or both?
Thank you Carsten for such an illustrative example. I will have to share it
with all my co-workers here.
   Carsten Haese wrote:

On Tue, 2007-08-07 at 21:37 -0400, Carsten Haese wrote:
[...] The standard way (at least as far as
Informix understands it) is not to quote table/column names at all and
let the parser worry about determining whether the word it's looking at
is the name of a thing or a keyword. And worry it will, if you are
insane enough to write queries like "select select as as from from where
where = 1", which is valid SQL given the right schema, and it's the
reason why writing a standards compliant SQL parser is a pain in the
neck.

Here's proof that this insane query really works, as long as you take my
word for it that this transcript isn't doctored:

Python 2.5 (r25:51908, Oct 28 2006, 12:26:14) [GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import informixdb
conn = informixdb.connect("ifxtest")
cur = conn.cursor()
cur.execute("create temp table from (select int, where int)")
-1
cur.execute("insert into from values(1,1)")
1
cur.execute("insert into from values(2,2)")
1
cur.execute("select select as as from from where where = 1")
cur.fetchall()
[(1,)]


   Thank you all,
   Art Protin

_______________________________________________
DB-SIG maillist  -  DB-SIG@python.org
http://mail.python.org/mailman/listinfo/db-sig

Reply via email to