dman462008
asked on
Find and replaceing characters in a character string.
I am trying to develop a routine in RPG to search a string for double quotes and replace the character with a single quote. I will be doing this for several different variables.
Here you go:
create table deleteme (
avc varchar(30)
)
insert into deleteme
values('this " has " quotes')
select avc
from deleteme
AVC
---
this " has " quotes
update deleteme
set avc = translate(avc, '''', '"')
select avc
from deleteme
AVC
---
this ' has ' quotes
HTH,
DaveSlash
dman462008:
The way to do this will depend on (1) whether the SQL Dev Kit is installed or not, (2) what version/release of RPG you're running, and (3) whether this is RPG IV (ILE) or RPG/400 (OPM).
It _might_ depend on what your programming background is as well. Are you an experienced RPG programmer? Would you prefer binding some C library functions in rather than staying strictly with RPG op-codes? (ILE RPG lets you use the same functions that C can call.)
Can you elaborate?
Tom
The way to do this will depend on (1) whether the SQL Dev Kit is installed or not, (2) what version/release of RPG you're running, and (3) whether this is RPG IV (ILE) or RPG/400 (OPM).
It _might_ depend on what your programming background is as well. Are you an experienced RPG programmer? Would you prefer binding some C library functions in rather than staying strictly with RPG op-codes? (ILE RPG lets you use the same functions that C can call.)
Can you elaborate?
Tom
Hi dman462008,
The RPG solution, sure no problem the XLATE can do that.
See Snippet
Regards,
Murph
The RPG solution, sure no problem the XLATE can do that.
See Snippet
Regards,
Murph
D #FROM C CONST('"')
D #TO C CONST('''')
C #FROM:#TO XLATE #INP #OUT
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
IMHO, the easiest way to do that is to use SQL's "translate" function. You could embed the SQL in your RPG if you like.
Give me a couple minutes, and I'll whip up an example.
-- DaveSlash