ox-it / ords

Automatically exported from code.google.com/p/ords
0 stars 0 forks source link

SQL query page doesn't always divide queries into clauses correctly #710

Open MerielP opened 9 years ago

MerielP commented 9 years ago

I've just constructed an SQL query that works perfectly when typed in the query box at the bottom of the query builder page. However, when I paste it into the SQL query page and try to run it, I get an error message.

The query in question was this one:

SELECT "tblarticles"."title" AS "Title",(EXTRACT (YEAR FROM CURRENT_DATE))-"tblarticles"."year" AS "Years since publication" FROM "tblarticles"

It should produce a list of all article titles from tblarticles, each followed by the number of years since they were published (worked out by subtracting the publication year from the current year).

When pasted into the SQL query page, ORDS attempts its usual clever trick of splitting the query into separate clauses. However, it doesn't do this very well - the second FROM confuses it, and everything that appears between the two FROMs appears in both the SELECT and the FROM boxes.

If one deletes the duplicated portion of the query, leaving just the table name in the FROM box, it then works.