Via Cà Matta 2 - Peschiera Borromeo (MI)
+39 02 00704272
info@synaptica.info

Firebird SQL “REPLACE” tips

Digital solution partner

Firebird SQL “REPLACE” tips

Managing the “&” character with Firebird’s string manipulation functions sometimes may not yield the expected results.

The documentation for Firebird’s official “REPLACE” function: https://firebirdsql.org/refdocs/langrefupd25-intfunc-replace.html

For example, if we were to make the classic replacement “>” with “>” with an update, it would be normal to write:

If this syntax does not produce the expected results, you can circumvent it by using the character code corresponding to “&” which in the ASCII table corresponds to the decimal code: 38

In many SQL syntaxes, the “&” character used within the replace function is utilized as a symbol to make the “Replace” function behave slightly differently than expected.

On the other hand, if we wanted to replace “<BR>” with the corresponding “\n\r” or for Delphi lovers #10#13, we could perform the following string: