SQLite Forum

Alternative for nesting REPLACE()?
Login
Bedsides Simon's good suggestion of writing a custom function, you might consider whether the expected rows would fit in cache, and, if so, a series of separate UPDATE's enclosed in a transaction might be sufficiently speedy.

-- or, a CTE can be used with a table of search/replace strings.

-- or would just formatting a big UPDATE not meet your need?  I imagine a dozen replacements as something like:

<code>
UPDATE myTable SET data =
   REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
   REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
   data,
    CHAR(13),       '~'         )
   ,CHAR(10),       '~'         )
   ,'division',     'unity'     )
   ,'fear',         'serenity'  )
   ,'greed',        'charity'   )
   ,'travesties',   'justice'   )
   ,'suspicion',    'empathy'   )
   ,'depression',   'joy'       )
   ,'hate',         'love'      )
   ,'poverty',      'sharing'   )
   ,'xenophobia',   'friendship')
   ,'copyright',    'blessing'  )
   ;
</code>

Donald