Page 1 of 1

Any generic query builder available?

Posted: Mon 11 May 2015 12:47
by Marius2
At the moment we have a lot of simple but hardcoded queries that need rewriting because of the introduction of mysql (reserved words and the need for the backtick/quotes or simple for adjusting the top/first/limit or 'emulating' *ci_ai collation on db's that dont fully
support a collation system like postgreSQL). It would be so much more elegant than hardcoded queries.

Before trying to build such ourselves (which would be a rather big undertaking) are there any SQL builders/toolboxes available that (partly) take care of writing SQL statements at runtime for multiple database systems and taking into account the optional schema and
escaping/quoting system of that particular database?

I know UniDac does not contain a query builder (runtime), but perhaps somebody knows something that is suitable for our needs (instead of building from scratch)?


BTW; We are running Delphi XE, with the following databases: Firebird, MsSql, MySql and PostgreSQL (and perhaps Oracle in a far future)

Thanks,
Marius

Re: Any generic query builder available?

Posted: Mon 11 May 2015 19:06
by Marius2
Sigh, solved after finally catching up reading on my unidac help documents (yeah yeah, RTFM, i know). Its a bit more typing but completely worthwhile in the long end..

/*--http://www.devart.com/unidac/docs/#unisql.htm*/

select
{if InterBase} first 1 {ENDIF}
{if PostgreSQL} top 1 {ENDIF}
{if SQL Server} top 1 {ENDIF}

{fn YEAR("date_in")} as date_inyear,
{fn MONTH("date_in")} as date_inmonth,
{fn DAY("date_in")} as date_inday

from "action"

{if MySql} limit 1 {ENDIF}

Re: Any generic query builder available?

Posted: Tue 12 May 2015 13:06
by ViktorV
It is a pleasure to see that you have found the answers in our documentation. Please contact us if you have any questions regarding UniDAC.