guptateamdevelopersqlbase

Is it possible to replace text by other text in SqlBase?


Is it possible to replace text in a SqlBase? I found there is a @REPLACE function but I see it just replaces using positions in the string:

The following expression returns the value 'RALPH':

@REPLACE('RALF', 3, 1, 'PH')

What I need is to replace a substring by another, In Sql Server it's like this:

This returns 'ABA':

SELECT REPLACE('ABC', 'C', 'A')

Thanks!


Solution

  • Using the literals in your 'ABC' to 'ABA' example....

    Select @REPLACE( 'ABC', @FIND( 'C', 'ABC', 0 ), @LENGTH('C'),  'A' )
    

    Using the literals in your 'RALF' to 'RALPH' example....

    Select @REPLACE( 'RALF', @FIND( 'F', 'RALF', 0 ), @LENGTH('F'),  'PH' )