Analitcs

Pesquisar no conteúdo do blog.atlabs.com.br

quinta-feira, 10 de novembro de 2016

Delphi - Firedac - Processando Comandos em diversos bancos de dados diferentes - Preprocessing Command Text (FireDAC)

Reações: 
Retirado de:

http://docwiki.embarcadero.com/RADStudio/Berlin/en/Preprocessing_Command_Text_(FireDAC)


SQL Dialect Abstraction

If the application needs to support multiple DBMSs, it must be aware that their SQL dialects may be different. FireDAC escape sequences allow you to write SQL dialect-independent SQL commands.
For example, the function to convert string to upper case is different in MySQL, Oracle, and Microsoft SQL Server. But the following command works on any DBMS:
SELECT {ucase(Name)} FROM MyTable
Note that with SQLite, you need to add the FireDAC.Stan.ExprFuncs unit to your "uses" clause. In more complex cases, parts of the command or even the full command must be written differently. Then, the FireDAC conditional escape sequence helps:
{IF Oracle} SELECT * FROM OracleTab {fi}
For example:
{iif (Oracle, TO_CHAR, MSSQL, CONVERT)}          -> ‘TO_CHAR’ ON Oracle ANDCONVERTON SQL Server.
{iif (&v1, Me, &v2, You, We)}                   -> ‘Me’ IF &v1 has nonempty VALUE, ‘you’ IF &v2 has nonempty VALUE, otherwise ‘We’.
{IF Oracle} TO_CHAR {fi} {IF MSSQL} CONVERT {fi} -> TO_CHAR ON Oracle AND CONVERT ON SQL Server.
{IF &v1} Me {fi} {IF &v2} You {fi} -> ‘Me’ IF &v1 has nonempty VALUE + ‘you’ IF &v2 has nonempty VALUE.{
IF MSSQL} SELECT * FROM MSSQLTab {fi}

Nenhum comentário:

Postar um comentário

Observação: somente um membro deste blog pode postar um comentário.

Max Gehringer