sql - how to replace multiple words at once in postgresql -
to replace multiple words, i'm using looping thru candidates, , replacing 1 one. there better way?
create or replace function "myreplace"(text, _varchar, _varchar) returns "pg_catalog"."text" $body$ declare int; result text; begin result = $1; in 1 .. array_length( $2, 1 ) loop result = replace( result, $2[ ], $3[ ] ); end loop; return result; end $body$ language 'plpgsql';
besides making stable , strict, , switching using pl/perl or c, there isn't optimization can make faster.
Comments
Post a Comment