Subject |
Re: Replacing a substring |
From |
Mervyn Bick <invalid@invalid.invalid> |
Date |
Mon, 24 Jul 2023 10:43:21 +0200 |
Newsgroups |
dbase.getting-started |
On 2023/07/23 21:08, Charlie wrote:
> I am wondering how to change text like LI10000 TO LH0000?
I assume LH0000 is a typo and should have been LH10000. If I'm wrong
the code below will need adjusting.
>
> I have tried this:
> USE MASTER.DBF
> REPLACE substr(part_no,1,2) with "LH" for mfg = "LIONEL H O SCALE"
>
> But come back with error 'expecting with'
>
> Also the field part_no is indexed. Will I need to re-index the table if I can get this done?
>
> Thanks much for any help
REPLACE needs an actual fieldname followed by WITH and then the complete
replacement value.
The indexes will all be updated automatically but the replacement will
be faster if you include REINDEX in the command especially with a large
table. This will do a complete reindex at the end instead of updating
the indexes after every replacement.
The correct syntax is
REPLACE part_no with 'LH'+substr(part_no,3) for mfg = "LIONEL H O SCALE"
REINDEX
(There may be line wrap. The command needs to be all on one line.)
This will change LI10000 to LH10000.
Mervyn
|
|