How to read CLOB data from oracle database into mashup?

Ratnamala
User offline. Last seen 1 year 21 weeks ago. Offline
Joined: 07/21/2010
Points: 10

I have oracle database and one field with CLOB datatype.

I want to read the CLOB data into my mashup(emml file) and want to use that retrived data in java class.

Does anyone know how to do that?

0
Your rating: None
Mike Bennett
User offline. Last seen 3 weeks 4 days ago. Offline
Joined: 12/09/2009
Points: 53

I've done some testing with a simple scenario, and so far I have not seen any issue with CLOBs coming back. Here are the steps I took. 1- I created a simple table:

CREATE
    TABLE NEWTABLE
    (
        B_ID INTEGER NOT NULL,
        B_DATA CLOB,
        PRIMARY KEY (B_ID)
    )

2- I populated this table with a couple test records:

insert into NEWTABLE (B_ID, B_DATA) values (1, 'Mike');  insert into NEWTABLE (B_ID, B_DATA) values (2, 'SOME RANDOM TEXT'); 

3- I created a simple mashup:

  <mashup xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" 

 

 	 xsi:schemaLocation="http://www.jackbe.com/2008-03-01/EMMLSchema/ ../src/schemas/EMMLSpec.xsd" 
 	 xmlns="http://www.jackbe.com/2008-03-01/EMMLSchema" 
 	 xmlns:macro="http://www.jackbe.com/2008-03-01/EMMLMacro" 
 	 name = "TestClob"> 
  	<output name="result" type="document"/>
  	
 	<datasource driverClassName="oracle.jdbc.OracleDriver"              url="jdbc:oracle:thin:@x.x.x.x:1521:orcl" password="abcde"              username="user" name="myDatasource"/> 
 	<sql name="myDatasource" query="SELECT B_ID, B_DATA from NEWTABLE" outputvariable="result"/>
 	
 	<display variable="result"/>
 	

 

 </mashup>  	   	  	  	  	  	  	  

This gives me the result:


<?xml version="1.0" encoding="UTF-8"?>
<records>
   <record>
      <b_id>1</b_id>
      <b_data>&lt;book&gt;&lt;author&gt;Mike&lt;/author&gt;&lt;title&gt;CAtcher in the Rye&lt;/title&gt;&lt;book&gt;</b_data>
   </record>
   <record>
      <b_id>2</b_id>
      <b_data>SOME RANDOM TEXT</b_data>
   </record>
</records>
Ratnamala
User offline. Last seen 1 year 21 weeks ago. Offline
Joined: 07/21/2010
Points: 10

Thanks Michael.

I tried the same which you mentioned above but still we were facing problem in reading CLOB data.

Now I got solution for this.

I tried conversion function in mashup for eg.

If you want to read description field which is of CLOB type(here it is detailed_decription) then you can write

dbms_lob.substr (  detailed_decription  , 1000, 1 )  as Description

This worked for me.Now I am able to read CLOB description from database.

Thanks a lot for your help.