ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Sqlrpgle xmlelement

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

  • Sqlrpgle xmlelement

    Hello,
    not sure if this is the correct place for my question.. i think it is a mix between sql and rpg.
    In a SQLRPGLE PGM i want to build a xml, which i want to store in the database later.
    When i call the XMLELEMENT function staticly everything is fine. But when i call this function with a variable definded in rpg type of char or varchar, i have the feeling i ran into some translation problems or i don't know...

    In my SQLRPGLE i do something like this:
    exec sql
    values(xmlelement(name "MyVal", :MyVal)) into :MyXmlString;

    The value of MyXmlString contains a well formed xml element but the value is not what i put in there, but i think it could be bit data (the string test transformed to 48Xi40A=).

    Does anyone know how to deal with this? Or worked with the sql xml functions in a sqlrpgle program?
    Worst solutions for me would be, that i have to code all the variable with sqltype keyword as clob, but i want to walk around this, because in my opinion it get's to much code and it is not so nice to read, therefore i could also concat strings to build xml...

    Hope someone can give me a hint.

    Thanks in advance for any help.

    Greetings Manuel


  • #2
    I have not bothered to use the SQL XML features because the syntax is very cumbersome, its much easier for me to build the XML in the RPG program with regular string concatenation.

    But... in case it's helpful, I noticed that the example you gave (48Xi40A=) is a base64 encoded representation of the string 'TEST ' (with a blank at the end) in EBCDIC. Is it possible that the way you're doing this is intended to produce a base64 encoded string?

    Comment


    • #3
      Yes i agree, the string concatenation to build the XML is also a good way. And after some testing, i will even build the XML based on strings.
      Your hint about the base64 was very good, because my field in the database is declared as XML.
      So now i have declared a VARUCS2 in my RPG for holding the whole XML Document and inserting this in my database table.

      Thanks for your help!



      Comment

      Working...
      X