DB2UpdatableRecord.GetDB2Xml Method

Creates an instance of a DB2Xml object from the column data.

Namespace:
IBM.Data.DB2
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

Syntax


[Visual Basic]
Public Function GetDB2Xml( _
   ByVal i As Integer _
) As IBM.Data.DB2Types.DB2Xml
[C#]
public IBM.Data.DB2Types.DB2Xml GetDB2Xml (int i)
[C++]
public: IBM.Data.DB2Types.DB2Xml GetDB2Xml(
   int i
);
[JScript]
public function GetDB2Xml(
   i : int
) : IBM.Data.DB2Types.DB2Xml;

Parameters

i
The zero-based column ordinal.

Return value

A DB2Xml object representing the GetBytes method returns the XML data in binary format.

Remarks

Avoid using the CHAR() FOR BIT DATA column to hold XML data, because the value stored will be blank padded on the database server. This causes a problem for Db2® for z/OS® or Db2/400 servers, where the pad character is in the EBCDIC code page. If you must use a CHAR() FOR BIT DATA column, you can avoid this problem by using RTIRM() on the XML column in the select list.

When RetrieveXmlInBinaryFormat is set to true, this method will return data in binary XML format.

The following table describes the mapping between the return object data type and the data server data type.
DB2®Type Data Type Db2 Data Type Informix® Data Type
DB2Xml XML  

Example

[Visual Basic, C#] The function in this example prints the contents of an XML column, named DESCRIPTION, from a table called PRODUCT. To retrieve the XML column data, use the DB2DataReader.GetDB2Xml method, and pass the XML data to a DB2Xml object.

[C#] 
public static void ReadXmlColumn(DB2Connection conn)
{
   DB2Xml xmlColValue; 
   String xmlString;
   String cmdSQL = "SELECT DESCRIPTION FROM product WHERE pid='100-101-01'";
   DB2Command cmd = new DB2Command(cmdSQL, conn);
   DB2DataReader reader = cmd.ExecuteReader();
   try
   {
      while (reader.Read())
      {
         xmlColValue = reader.GetDB2Xml(0);
         xmlString = xmlColValue.GetString();
         Console.WriteLine(" {0} \n", xmlString);
      }
   }
   catch(Exception e)
   {
      Console.WriteLine(e.Message);
   }
   finally
   {
      reader.Close();
   }
}