| Author | Message | 
		
		  | Saadat | 
			  
				|  Posted: Mon May 16, 2005 5:34 am    Post subject: best way to store XML message in DB2 VARCHAR? |   |  | 
		
		  | Newbie
 
 
 Joined: 16 May 2005Posts: 5
 Location: IBM Greenock, UK
 
 | 
			  
				| Dear all, What is the best way to store XML message in DB2 VARCHAR column using WBIMB v5?
 
 Sample message in input Q
 ----------------------------------
 
 <Message>
 
 <header_1>a</header_1>
 <header_2>b</header_2>
 <header_n>c</header_n>
 <doc>
 <field_1>x</field_1>
 <field_2>y</field_2>
 <field_n>z</field_n>
 </doc>
 
 </Message>
 
 I would like to store above message including XML tags in DB2 VARCAHR colum as string.
 
 Required sample message in DB2 VARCHAR column
 -------------------------------------------------------------
 "<Message>
 
 <header_1>a</header_1>
 <header_2>b</header_2>
 <header_n>c</header_n>
 <doc>
 <field_1>x</field_1>
 <field_2>y</field_2>
 <field_n>z</field_n>
 </doc>
 
 </Message>"
 
 Your assistance would be much appreciated.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | jefflowrey | 
			  
				|  Posted: Mon May 16, 2005 5:49 am    Post subject: |   |  | 
		
		  | Grand Poobah
 
 
 Joined: 16 Oct 2002Posts: 19981
 
 
 | 
			  
				| You want to search for 'ASBITSTREAM', or 'XML to BLOB'. _________________
 I am *not* the model of the modern major general.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | CHF | 
			  
				|  Posted: Mon May 16, 2005 6:10 am    Post subject: |   |  | 
		
		  |  Master
 
 
 Joined: 16 Dec 2003Posts: 297
 
 
 | 
			  
				| DECLARE msgBlob BLOB; 
 SET msgBlob = ASBITSTREAM(InputRoot.XML.Envelope.Body.logDta
 OPTIONS FolderBitStream);
 _________________
 CHF
  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Saadat | 
			  
				|  Posted: Mon May 16, 2005 6:29 am    Post subject: |   |  | 
		
		  | Newbie
 
 
 Joined: 16 May 2005Posts: 5
 Location: IBM Greenock, UK
 
 | 
			  
				| Many thanks guys, found the solution under ASBITSTREAM. |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Saadat | 
			  
				|  Posted: Tue May 17, 2005 1:56 am    Post subject: |   |  | 
		
		  | Newbie
 
 
 Joined: 16 May 2005Posts: 5
 Location: IBM Greenock, UK
 
 | 
			  
				| For the benefit of other folks here is the piece of code which i used to solve my  problem. ----------------------------------
 DECLARE MSG_BLOB BLOB;
 DECLARE MSG_DATA CHAR;
 
 SET MSG_BLOB = ASBITSTREAM(InputRoot.XML OPTIONS RootBitStream);
 SET MSG_DATA = CAST( MSG_BLOB AS CHAR CCSID InputRoot.MQMD.CodedCharSetId ENCODING InputRoot.MQMD.Encoding);
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  |  |