Subject | Re: Replace character in Firebird |
---|---|
Author | Milan Babuskov |
Post date | 2007-05-24T13:56:26Z |
--- nikoskapa wrote:
/* replace A with B */
update table1
set field1 = substrlen(field1, 1, strpos(field1, 'A') - 1) || 'B' ||
substr(field1, strpos(field1, 'A')+1, strlen(field1))
where field1 containing 'A';
Repeat that while you have A's. Now, that's the most inefficient way.
You can also do it in a stored procedure or execute block, or you can
use STR_REPLACE udf from rFunc library:
http://rfunc.sourceforge.net/
like this:
update table1 set field1 = str_replace(field1, 'A', 'B');
--
Milan Babuskov
http://www.guacosoft.com
http://www.flamerobin.org
> How to replace a specific character e.g. 'a' with another character inWell, perhaps something like this:
> a firebird fieldtable using an update sql script?
/* replace A with B */
update table1
set field1 = substrlen(field1, 1, strpos(field1, 'A') - 1) || 'B' ||
substr(field1, strpos(field1, 'A')+1, strlen(field1))
where field1 containing 'A';
Repeat that while you have A's. Now, that's the most inefficient way.
You can also do it in a stored procedure or execute block, or you can
use STR_REPLACE udf from rFunc library:
http://rfunc.sourceforge.net/
like this:
update table1 set field1 = str_replace(field1, 'A', 'B');
--
Milan Babuskov
http://www.guacosoft.com
http://www.flamerobin.org