Substring in CL on iSeries

750 pts.
Tags:
AS 400
iSeries
I have a 150 character field. I need to check each character for a quote. If it should find one I want to replace it with a blank space or just delete the quote. Is there a way to "walk the field" searching for a quote using substringing?


Software/Hardware used:
V7R1M0
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

use the SQL function to do it

/Free
    Exec SQL   Set :MyText = Replace(:MyText, :Old, :New);
/End-Free

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • TheRealRaven
    Simplest is probably a DOFOR-loop:
    dcl   &i           *int
    
    dofor       &i from( 1 ) to( 150 )
       if ( %sst( &string &i 1 ) *eq &quote )  do
          /* Change quote */
       enddo
    enddo
    A couple other common possibilities exist, but DOFOR is probably best.
    34,465 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: