Question

What is an equivalent to RIGHT() (as in FB2.5) for older versions of firebird (Firebird 2.0) without using UDFs?

Was it helpful?

Solution

Use SUBSTRING and CHARACTER_LENGTH functions. Both internally available as of version FB 2.0:

SELECT
  IIF(CHARACTER_LENGTH(str_field) <= <right_characters_count>,
    str_field,
    SUBSTRING(str_field FROM 
      (CHARACTER_LENGTH(str_field) - <right_characters_count> + 1)))
FROM
  some_table
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top