×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
Hi Charles,
This seems a very reasonable usecase I think.
Scott Klement has provided examples of how to retrieve the result in an IFS
file with SQLRPGLE, but I cannot find them online right now.
However, here is some code what we we use.
SQL Part:
CREATE OR REPLACE FUNCTION
My_Data_To_Xml_01
(
peMyDataID INTEGER,
peLanguageID CHAR(3)
)
RETURNS CLOB(32000) CCSID 1208
LANGUAGE SQL
READS SQL DATA
NO EXTERNAL ACTION
NOT DETERMINISTIC
DISALLOW PARALLEL
RETURN
(
SELECT XMLSERIALIZE(
XMLELEMENT(
NAME "MyData",
(
SELECT
do XMLretrieval
)
) AS CLOB(32000) CCSID 1208 INCLUDING XMLDECLARATION
)
FROM sysibm.sysdummy1
)
;
RPG Part:
* generic constants and variables
*
d ifsfile s SQLTYPE(CLOB_FILE)
d file_name s 100A varying
*
// parms are temporary overridden for development
d wwMyDataID s 10I 0 inz(1)
d wwLanguageID s 3A inz('eng')
*
/free
// set parameters (part of sqltype structure)
ifsfile_fo = SQFOVR ; // mode create and overwrite
ifsfile_name = '/ifsfolder/ifsoutputfile.xml' ;
ifsfile_nl = %len(%trimr(ifsfile_name)) ;
EXEC SQL
SELECT My_Data_To_Xml_01(:wwMyDataID, :wwLanguageID)
INTO :ifsfile
FROM SYSIBM/SYSDUMMY1 ;
// verify sql state
if SQLstt <> '00000' ;
sendNotifyEmail(wwMyDataID) ;
endif ;
*inlr = *ON ;
return ;
/end-free
Regards,
Arco
2016-04-22 20:02 GMT+02:00 Charles Wilt <charles.wilt@xxxxxxxxx>:
Does this seem like a reasonable use of XML? Or am I asking for trouble?
Do you have links to good references for learning to use the XML
functionality in DB2 for i? I've looked at the SQL reference, and while
useful, I'd like something a bit more together and with more advanced
examples of putting it all together.
Lastly, once I build the XML...how do I get it saved into a text file the
IFS?
As an Amazon Associate we earn from qualifying purchases.