XMLCAST in SQLJ applications
Before you can use XMLCAST to cast a host variable to the XML data type in an SQLJ application, you need to cast the host variable to the corresponding SQL data type.
Example: The following code demonstrates a situation
in which it is necessary to cast a String host variable to an SQL
character type, such as VARCHAR, before you use XMLCAST to cast the
value to the XML data type.
String xmlresult = null;
String varchar_hv = "San Jose";
…
#sql [con] {SELECT XMLCAST(CAST(:varchar_hv AS VARCHAR(32)) AS XML) INTO
:xmlresult FROM SYSIBM.SYSDUMMY1};