NAME
DbaseRegsub — Do find/replace on a column of a SQL table.
SYNOPSIS
DbaseRegsub TableName ColumnName FindValue ReplaceValue ?WhereDict?
DESCRIPTION
Return Value
Total number of replacements done.
Arguments
TableNameTable the records are in.
ColumnNameName of the (text) column to go through.
FindValueWhat to look for.
ReplaceValueWhat to replace it with.
WhereDictOptional. Sequence of column name / column value pairs used to form a WHERE clause and do the regsub only on that.
More Info
This command (currently) will only work for columns of type text.

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.


For information regarding exceptions / errors, see here.
EXAMPLES

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
SEE ALSO
regsub
KEYWORDS
sql