EGL Development User Group

EGL Development User Group

EGL Development User Group

The EGL Development User Group is dedicated to sharing news, knowledge, and insights regarding the EGL language and Business Developer product. Consisting of IBMers, HCL, and users, this community collaborates to advance the EGL ecosystem.

 View Only
Expand all | Collapse all

XML column update using XMLMODiFY (or anything else)

  • 1.  XML column update using XMLMODiFY (or anything else)

    Posted Sun March 05, 2017 02:14 AM

    Hi EGL professionals,

     

    I'm trying to update and XML type column from EGL on Mainframe and DB2 11. I'm using an UPDATE SQL with XMLMODIFY which is working well from SQL script (QMF, DataStudio)

    UPDATE LOGT SET LOGXML =    XMLMODIFY('insert node $log/text as last into /nlslog',       XMLPARSE(DOCUMENT '<text>my log 1</text>') as "log")WHERE ID=75;

    I tried to implement it in EGL, like this (and many other ways)

    function LOGTEXT(LOGTEXT string)        LOGXMLSTR String;                LOGXMLSTR = "UPDATE LOGT";        LOGXMLSTR = LOGXMLSTR + " SET LOGXML =";        LOGXMLSTR = LOGXMLSTR + " XMLMODIFY('insert node $log/text as last into /nlslog', XMLPARSE(DOCUMENT '<text>my log 1</text>') as \"log\"),";        LOGXMLSTR = LOGXMLSTR + " RUNID = '0002'";        LOGXMLSTR = LOGXMLSTR + " WHERE ID = ?";        try            prepare MYSQLSTATEMENT from LOGXMLSTR;                execute MYSQLSTATEMENT using LOGT.ID;                        //            execute #sql{//                UPDATE LOGT//                SET LOGXML =//                    XMLMODIFY('insert node $log as last into /nlslog', XMLPARSE(DOCUMENT '<text>my log 1</text>') as "log")//                WHERE ID = :LOGT.ID//            }//            for NLSLOGT;                onException            LOGERROR();        end    end

     

    I also tried the query several ways in SQL it's working, but not in EGL:

    XMLMODIFY('insert node $log as last into /nlslog', XMLPARSE(DOCUMENT '<logg><text>my log 1</text></logg>') as "log")
    XMLMODIFY('insert node $log/text as last into /nlslog', XMLPARSE(DOCUMENT '<?xml version=\"1.0\" encoding=\"IBM037\"?><logg><text>my log 1</text></logg>') as "log")

    Unfortunatelly we are not able to run Stored Procedures

     

    Please help!

     

     

    SzabóZoltán


  • 2.  Re: XML column update using XMLMODiFY (or anything else)

    Posted Tue March 21, 2017 06:15 AM

    Not any idea?

    SzabóZoltán


  • 3.  Re: XML column update using XMLMODiFY (or anything else)

    Posted Mon April 24, 2017 08:34 AM

    Is this an EGL cobolGen situation or javaGen? 

    I don't see any information in your text about what is going wrong. Are you getting an error somewhere? What are the details of the error?

    Jeff.Douglas


  • 4.  Re: XML column update using XMLMODiFY (or anything else)

    Posted Mon April 24, 2017 10:03 AM

    Sorry,

     

    I forgot to update this. The problem caused by the $ sign. When the code was run on the MVS it was changed to something else in EBCDIC.

    so, the solution is:

     dollar char(1);dollar = strLib.intAsChar(103);logXMLStr string;    logXMLStr = "UPDATE LLFT.NLSLOGT";    logXMLStr = logXMLStr + " SET LOGXML =";    logXMLStr = logXMLStr + " XMLMODIFY('insert node " + dollar +            "logelement as last into /nlslog" + actualPath +            "', XMLPARSE(DOCUMENT '<" + logBlockName + " time=\"" +            dateTimeLib.currentTimeStamp() + "\">" + logBlockTxt + "</" +            logBlockName + ">') as \"logelement\")";    logXMLStr = logXMLStr + " WHERE ID = ?";    try        prepare logBlocKSQL from logXMLStr;        execute logBlockSQL using NLSLOGT.ID;    onException        LOGERROR();    end
    SzabóZoltán