Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting unwanted characters in a field 1

Status
Not open for further replies.

shmo

IS-IT--Management
Nov 25, 2002
18
US
Hello ISQL people,

This is probably an easy one but I'm finding it difficult since I am not too great at ISQL. I have a field that contains phone numbers and want to delete the ( ) -.

ex.. (212)555-1212 needs to be 2125551212

I can do this in T-SQL
as
update stage_guest
set phone = replace(phone,'(','')
go
update stage_guest
set phone = replace(phone,')','')
go
update stage_guest
set phone = replace(phone,'-','')
go

Anyone have an ISQL (Interbase 5.5) method?
I would appreciate any assistance, Thanks!
 
See the UDF keyword ;-)).
Download and install the 'free UDF library' or 'rFunc UDF library'. You can find in both package enhanced string functions like replace.
 
Thanks otto! I had run a perl script at interbase to get my results since I had a time frame involved.
I tried the UDF's on some other test data and suprisngly they work pretty good on data manipulation. Great advice, Thanks! I didn't know that existed...

FYI for the PERL:

use DBI;
use dbd::eek:dbc;

$dbh = DBI->connect("dbi:ODBC:sourcedb", "username", "password");
#phones
#select (id,phone) from guest
$sth = $dbh->prepare("select id,phone from guest");
$sth->execute();


while (@row = $sth->fetchrow_array)
{
if ($row[1] =~ /-/ or $row[1] =~ /\(/ or $row[1] =~ /\)/)
{
print "@row\n";
$del = $row[1];
$del =~ s/-//g;
$del =~ s/\(//g;
$del =~ s/\)//g;
print "$del\n";
$update = $dbh->prepare("update guest set phone = \"$del\" where id = $row[0]");
$update->execute;
}
}

#update guest
#set phone = $del where id = $row[0]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top