Simplicty and flexibility!


Changing special characters or a specific string of data in all records.


Started by Bolt-on-Trailers
Search
You will need to Sign In to be able to add or comment on the forum!

Changing special characters or a specific string of data in all records.

Hi all, I was wondering how I would use a procedure to find a single (special) character or a specific string of data and change it to another special character or string without affecting the data before or after. See example below

BEFORE: John Doe À Supervisor

AFTER: John Doe È Supervisor

OR

BEFORE: John Doe SupervisorX in sales

AFTER: John Doe SupervisorZ in sales

This would be like using the Find and Replace function found in other programs like Excel and text editors like K-Edit.

I hope this makes sense. Your help would be greatly appreciated.


Written by Bolt-on-Trailers 30/08/18 at 17:17:50 Dataease [{8}]FIVE

Re:Changing special characters or a specific string of data in all records.

You could use the StringReplace function, possibly in conjunction with other new String functions.


Written by Peter Birney, PB Associates 31/08/18 at 09:46:15 Dataease [{8}]FIVE

Re:Re:Changing special characters or a specific string of data in all records.

DataEase doesn't do "global" search yet so you will need to apply the update to each field (column) you want change. It is however quite straightforward.

You can do an "intelligent" fix or a brute force fix. 

The "intelligent" one will be something like this.

For YouTable with StringFind(YourField,"X")>0 ;
modify records

YourField := stringreplace(YourField,"X","Y") ;

But to be honest the brute force one will be as effective.

Modify records in your table 
Field1 := StringReplace(Field1,"X","Y") ;
Field2 := StringReplace(Field2,"X","Y") ;
etc
FieldN := StringReplace(FieldN,"X","Y") .


This way you basically update each record and if there is an occurrence of the value you want to change it change it and write it back and if not it just do nothing.

If you are going to change many columns the brute force one is the best.

If you have a global problem in the app there is a trick to do that too.

lets just say it involves using the status table for columns and execdql.

If this is what you need to do, hit us back and we will make a small sample.


Written by DataEase 03/09/18 at 10:58:36 Dataease [{8}]FIVE
DG3_ForumList