TableName | Table the records are in. |
ColumnName | Name of the (text) column to go through. |
FindValue | What to look for. |
ReplaceValue | What to replace it with. |
WhereDict | Optional. Sequence of column name / column value pairs used to form a WHERE clause and do the regsub only on that. |
While you do not have to put the find/replace values in quotes, you do have to put values in the WhereDict in quotes, unless they are targeting a non-text field (e.g. an integer id).
You may also want to take a look at dbcmd function
. Possibly could duplicate this functionality using a stored procedure instead.
Note that the SELECT for this command will target both the given column name and a field called id. It is assumed that the table includes a field called id, which is the primary key.
Check this page for info about how to set up Gen for using database-related commands.
This code: (1) Creates a table and populates it, (2) Does a regsub over a column, (3) Shows how the values in multiple records have changed.
% RunSqlCreate my_table {id {integer primary key} desc text notes text}
% SqlRunEnter my_table {desc 'regsubx1' notes 'regsub_target'}
% SqlRunEnter my_table {desc 'regsubx2' notes 'regsub_target'}
% DbaseRegsub my_table desc x y
% QQ {SELECT desc FROM MyTable WHERE notes = 'regsub_target'}
regsuby1 regsuby2