Announcement

Collapse
No announcement yet.

Manipulate a character in a CLOB variable.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Manipulate a character in a CLOB variable.

    I used JSON_OBJECT to return me many rows of json data.

    The requestor asked me to add a comma between the rows of returned json.

    To return the full data string I used a CLOB variable.

    I populate the clob variable until end of data.

    That leaves me a comma after my last row of JSON. I would like to remove it.
    I am not sure how to accomplish this.
    The last line is my failed attempt.

    This is my first time using a CLOB and JSON_OBJECT.


    dcl-s count int(5:0) inz(1);
    dcl-s returnString sqltype(clob:400000);
    dcl-ds returnData likeds(listData) dim(9999);
    dcl-ds listData Qualified Occurs(9999);
    row varchar(1024);
    end-ds;


    mainList(returnData);

    returnString_data = %trim(returnString_data) + %trimr(returnData(count).row);
    dou returnData(count).row = *blanks;
    count += 1;
    returnString_data = %trim(returnString_data) + ','
    + %trimr(returnData(count).row);
    returnString_len = returnString_len + %len(%trimr(returnData(count).row));
    enddo;
    %subst(returnString_data: returnString_len -1 : 1) = ' ';



    Any help would be appreciated.



  • #2
    This is a duplicate post. Please post follow-ups here: https://code400.com/forum/forum/iser...-clob-variable

    Comment

    Working...
    X