× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Alan,

SQL REPLACE is easier if the data already exists. %replace will only
replace one occurrence at a time, so you would have to run the routine
in a loop.

With RPG -
Dow %scan('""':strValue) > 0;
%replace('"':strValue:%scan('""':strValue):2);
Enddo;
strValue = %trim(strValue);

With SQL -
UPDATE tableName SET strValue = RTRIM(REPLACE(strValue, '""', '"'))

Tom Armbruster

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Alan Shore
Sent: Friday, January 18, 2008 1:24 PM
To: RPG programming on the AS400 / iSeries
Subject: %replace question

Hi everyone
my name is Alan, and I am a person who has Friday afternoon brain freeze
(In unison : "Hi, Alan")
I have some data that contains pairs of double-quotes ("") that need to
be
replaced with single quote (" - with 2 characters being replaced with 1
so
that the rest of the data is moved to the left.
Now the data field may contain a number of pairs of these double quotes
(but never 2 pairs together - for example ""STREET"" that needs to be
replaced with "STREET" - left adjusted
My head is stuck on using %replace - is this correct, or should I be
using
something else?

Thanks in advance



Alan Shore

NBTY, Inc
(631) 244-2000 ext. 5019
AShore@xxxxxxxx
"If you're going through Hell, keep going" - Winston Churchill

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.