Character change at - sql position

Asked

Viewed 368 times

0

To replace the third character of a string in Firebird, example: 00028 by 00128, 00029 by 00129... Someone could help me, I tried to see by replace, but I can’t determine the position

1 answer

2


Firebird has the overlay function.

overlay ('00029' placing '1' from 3)

Site with documentation and more examples: overlay

Another example would be to oracle, where it is possible to use a expressão regular.

SELECT regexp_replace('00029','(^.{2})(.{1})(.*)$','\1X\3') FROM dual;

In this case, I put a "X" to mark where the new number should be inserted. The first {2} is the position of the exchange and the {1} is the number of letters to be replaced.

  • Dear thanks Reinaldo, I did not know this function of Firebird, it worked right, vlw

Browser other questions tagged

You are not signed in. Login or sign up in order to post.