Blob to Clob XML conversion problem
Hello,
I have a table with a blob column that contains different types of documents (.doc, .pdf, .gif, .xml, etc). The xml documents use UTF-8 encoding and contain some of the multi-byte characters. I'm trying to extract and convert the xml blob content into a clob variable so I can parse it into an xmldom object. The database characterset is WE8ISO8859P1, so the multi-byte characters do not translate well.
Is there any way to directly load/parse binary data into an xmldom object without having it go through the character translation, and have it recogized as utf-8?
Or, is there a way to create and use a clob variable that is in a different characterset than the database characterset?
The database version is 9.2.0.5
Any suggestions greatly appreciated.
Thanks,
Mark
In general the NCLOB data type is used for use. However XMLType does not support NCLOB for various valid technical reasons.
In order for the XMLType based functions to work the database character set must be capable of representing all of the characters in the document. This means that in your case the only way you can process these documents is to convert the database character set to AL32UTF8.
Sorry if this is bad news.
Similar Messages
-
Hi,
1. In the code, CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD has been used
to uplaod the excel sheet data.
2. After upload,its been tried to convert the uploaded data to XML by following
code.
ixml = cl_ixml=>create( ).
xmlDoc = ixml->create_document( ).
streamFactory = ixml->CREATE_STREAM_FACTORY( ).
iStream = streamFactory->CREATE_ISTREAM_STRING( xmlString ).
iXMLParser = iXML->create_parser( stream_factory = streamFactory
istream = iStream
document = xmlDoc ).
iXMLParser->parse( ).
ixmlDocument = xmlDoc.
3. After creation of xmlDoc its trying to get root element from xml doc by
rootnode = if_ixml_document~get_root_element.
its not returning the root element reference to rootnode.
4. In method cl_ixml_document->if_ixml_document~get_root_element, its calling
below statement
system-call ixml
did 954859521
parameters
cl_ixml=>the_iXML
me
name
rval.
and rval has became null reference.
Could anyone help me to resolve this problem.
Thanks & Regards,
Bhuvana.Checking the fdsapi.jar file reveals that the FormattedDataSet class is part of the JAR. Have you included the import statement for the package in your source? For example:
import com.fdsapi.*; -
Result Set - XML conversion - Problem in FormattedDataSet
Hi,
I'm trying to convert the JDBC resultset into a XML file.
I read somewhere that FormattedDataSet interface has many methods that are very useful in converting the resultset to XML.
I downloaded the following files as mentioned in the website:
1. fdsapi.jar
2. jakarta-oro-2.0.8.jar
3. JAMon.jar
Also as mentioned in the website (http://www.fdsapi.com/), I placed these jar files in my classpath. My classpath looks like:
D:\Programs>set classpath
CLASSPATH=D:\XMLConv\Installations\FormattedDataSet\fdsapi.jar;
D:\XMLConv\Installations\FormattedDataSet\jakarta-oro-2.0.8.jar;
D:\XMLConv\Installations\FormattedDataSet\JAMon.jar
But when I executed my program through Command line, I'm getting this error:
a1.java:6: cannot find symbol
symbol : class FormattedDataSet
location: class a1
FormattedDataSet rs = FormattedDataSet.createInstance();
^
a1.java:6: cannot find symbol
symbol : variable FormattedDataSet
location: class a1
FormattedDataSet rs = FormattedDataSet.createInstance();
^
2 errors
I tried running in Eclipse editor(IDE) where I included the above said jar files as External JAR files. But, even there, I'm getting the same error.
Could somebody please let me know how to solve this error.
ThanksChecking the fdsapi.jar file reveals that the FormattedDataSet class is part of the JAR. Have you included the import statement for the package in your source? For example:
import com.fdsapi.*; -
hi all,
i have a table have 2 clounms in my DB (10.2.0.4) one colunm is varchar2 and other one was blob. as per requested from developer team, i changed it from blob to clob. after this conversion, object size is increased from 11mb to 39mb. my point is is it expected behavior ?????? if yes ! can any one pl. explain it.
regards,CREATE TABLE TABLE_CLOB
RECID VARCHAR2(255 BYTE),
XMLRECORD SYS.XMLTYPE
TABLESPACE DATATABLESPACE
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING
ENABLE ROW MOVEMENT;
CREATE UNIQUE INDEX TABLE_CLOB_PK ON TABLE_CLOB
(RECID)
LOGGING
TABLESPACE INDEXTABLESPACE
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
NOPARALLEL;
ALTER TABLE TABLE_CLOB ADD (
CONSTRAINT TABLE_CLOB_PK
PRIMARY KEY
(RECID)
USING INDEX
TABLESPACE INDEXTABLESPACE
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
)); -
Blob to clob conversion when inserting as select?
I have a table with one row that has BLOB column. I would like to copy that row to a different table, with CLOB column data type. I’ve found this discussion (BLOB to CLOB? where some examples of stored procedures to convert blob to clob are used but I am unsure what should I use as input parameter to the blob_to_clob procedures listed in that discussion? Please advice.
Thank you very much for your time.
DanielThe function by Richard Wiener {message:id=9646697} in the thread simply uses the procedure dbms_lob.converttoclob with a set of parameters defined in the function.
At my work we have created a similar function:
CREATE OR REPLACE function blob2clob (p_blob in blob)
return clob
is
v_clob clob;
amount INTEGER;
dest_offset INTEGER;
src_offset INTEGER;
blob_csid NUMBER;
lang_context INTEGER;
warning INTEGER;
begin
dbms_lob.createtemporary (
v_clob,
false,
dbms_lob.session
amount := dbms_lob.lobmaxsize;
dest_offset := 1;
src_offset := 1;
blob_csid := nls_charset_id('AL32UTF8');
lang_context := 0;
dbms_lob.converttoclob(
v_clob,
p_blob,
amount,
dest_offset,
src_offset,
blob_csid,
lang_context,
warning
return v_clob;
end blob2clob;
/Difference here is that Richard uses default charset - we have need for AL32UTF8 charset. You should use whatever is relevant for your case.
The use of either Richards function or the above is simple for your insert as select:
insert into tab_c (clob_col)
select blob_to_clob(blob_col) from tab_b -
Using blob or clob from db as document
I'm changing a working process to fetch an XDP document from a database rather than fetch from resources:// on the Adobe server. The DB2 database field containing the XDP is a clob data type. We were using blob. The services operations are:
- Foundation/JdbcService/Query Single Row this fetches the XDP
- Foundation/SetValue/Execute this converts whatever was fetched into a document variable
- Forms/FormsService/renderPDFForm this merges the document with XML and produces PDF output
I'm unable to write the database field into a variable due to lack of choices. For instance there is no BLOB or CLOB variable type in the list of available types. When using STRING I get the following error:
Caused by: java.io.NotSerializableException: com.ibm.db2.jcc.b.ub
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
at com.adobe.idp.dsc.util.CoercionUtil.toString(CoercionUtil.java:498)
When using XML I get the following error:
Caused by: com.adobe.workflow.WorkflowRuntimeException: Invalid location: /process_data/@clob_XDP_string cannot be stored for action instance: -1
at com.adobe.workflow.pat.service.PATExecutionContextImpl.setProcessDataValue(PATExecutionCo ntextImpl.java:701)
When using OBJECT I get the following error:
Caused by: com.adobe.workflow.WorkflowRuntimeException: Invalid location: /process_data/@clob_XDP_string cannot be stored for action instance: -1
at com.adobe.workflow.pat.service.PATExecutionContextImpl.setProcessDataValue(PATExecutionCo ntextImpl.java:701)Steve,
Going against DB2 doesn't work for me with a document variable type. It gives a coercion error.
I did solve my problem though from the following URL: http://groups.google.com/group/livecycle/browse_thread/thread/6c4b9156b52b71a7
JYates:
You can do this, but you have to use the Execute Script service -- at this time there isn't a deployable component for it.
Use this sort of script in the Execute Script service to read the PDF blob from the database and populate a Document variable.
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.sql.ResultSet;
import javax.sql.DataSource;
import javax.naming.InitialContext;
int processId = patExecContext.getProcessDataIntValue("/process_data/@id");
InitialContext context = new InitialContext();
Connection connection = ((DataSource)context.lookup("java:/IDP_DS")).getConnection();
String queryQuery = "select bigdocument, bigstring from tb_pt_workwithxlobs where process_instance_id = ?";
PreparedStatement queryStatement = connection.prepareStatement(queryQuery);
try {
queryStatement.setInt(1, processId);
ResultSet results = queryStatement.executeQuery();
results.next();
java.sql.Blob documentBlob = results.getBlob(1);
com.adobe.idp.Document document = new com.adobe.idp.Document(documentBlob.getBinaryStream());
patExecContext.setProcessDataValue("/process_data/@NewBigDocument",document);
java.sql.Clob stringClob = results.getClob(2);
patExecContext.setProcessDataValue("/process_data/@NewBigString",stringClob.getSubString( 1L,(int)stringClob.length()));
catch(Exception ex) {
ex.printStackTrace();
queryStatement.close();
connection.close(); -
BLOB and CLOB data in BI Publisher
Hello,
I have an XML file with blob and clob data in it. I am using BI desktop publisher to load the xml file and create the rtf template. I am getting the following error:
ConfFile: C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\Template Builder for Word\config\xdoconfig.xml
Font Dir: C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\Template Builder for Word\fonts
Run XDO Start
Template: C:\work\employee.rtf
RTFProcessor setLocale: en-us
FOProcessor setData: C:\work\employee.xml
FOProcessor setLocale: en-us
Do i need to install anything or am i missing any configuration to read the blob and clob? Please advise
thanksCheck this out, hopefully it'll help you
http://oraclebizint.wordpress.com/2007/11/12/oracle-bi-ee-101332-working-with-clob-fields/
Fiston -
Hello,
I am using oracle8i. The date format is not giving the proper date values in XML conversion..
create table test(dt date);
insert into test values(sysdate);
insert into test values(sysdate);
insert into test values(sysdate);
TEST.WORLD> select * from test;
DT
28-NOV-04
28-NOV-04
28-NOV-04
set autoprint on
set long 100000
set linesize 100000
set longchunksize 100000
var g_clob clob
declare
l_ctx dbms_xmlquery.ctxType;
l_clob clob;
begin
l_ctx := dbms_xmlquery.newContext('select dt from test');
dbms_lob.createtemporary(:g_clob,true,dbms_lob.session);
dbms_xmlquery.setdateformat(l_ctx,'yyyy-mm-dd');
:g_clob := dbms_xmlquery.getXml(l_ctx);
end;
Here is the output . It is dispalying the 03 For the month november.
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<DT>2004-03-28</DT>
</ROW>
<ROW num="2">
<DT>2004-03-28</DT>
</ROW>
<ROW num="3">
<DT>2004-03-28</DT>
</ROW>
</ROWSET>When you call DBMS_XMLQUERY.SETDATEFORMAT, you must supply the mask using the syntax defined by java.text.SimpleDateFormat.
You need to use "yyyy-MM-dd".
In your case, "yyyy-mm-dd", the lower case "mm" is the mask for minutes. -
Mapping error in FCC to XML conversion
hiii friends,
im donig a simple fcc to xml conversion
my Sender msg type is like
TXT_mt
records 1.1
row 1.n
id 1
Name 1
address 1
My receiver msg type like
Xml_mt
records 1.1
row 1.n
id 1
Name 1
address 1
msg mapping like
records--->records
id--->id
Name-->Name
address-->address
**Im getting a mapping error like**
<SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
<SAP:Category>Application</SAP:Category>
<SAP:Code area="MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code>
<SAP:P1>com/sap/xi/tf/_pepsi_fcc_file_mm_</SAP:P1>
<SAP:P2>com.sap.aii.utilxi.misc.api.BaseRuntimeException</SAP:P2>
<SAP:P3>RuntimeException in Message-Mapping transformatio~</SAP:P3>
<SAP:P4 />
<SAP:AdditionalText />
<SAP:ApplicationFaultMessage namespace="" />
<SAP:Stack>During the application mapping com/sap/xi/tf/_pepsi_fcc_file_mm_ a com.sap.aii.utilxi.misc.api.BaseRuntimeException was thrown: RuntimeException in Message-Mapping transformatio~</SAP:Stack>
<SAP:Retry>M</SAP:Retry>
</SAP:Error>
I ve checked my adapeters they r green.
Could u tell me the problem here and how to solve it???
Regards
BalajiHii Volker,
I have tried to understand the trace msg,. i got one interesting error message i hope it will tell the exact problem im facing,,,
<Trace level="1" type="T">RuntimeException during appliction Java mapping com/sap/xi/tf/_pepsi_fcc_file_mm_</Trace>
<Trace level="1" type="T">com.sap.aii.utilxi.misc.api.BaseRuntimeException: RuntimeException in Message-Mapping transformation: Cannot produce target element /ns:xml_mt/record/row. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd at com.sap.aii.mappingtool.tf3.AMappingProgram
My Sender CC contains the following FCC parameters
Document Name -
> txt_mt
Recordset Name -
> records
recordset Structure -
> row, *
row.fieldNames -
> id, Names,address
row.fieldSeparator -
> , (comma)
row.endSeparator--- > 'nl'
row.processConfiguration -
> FromConfiguration
my TXT_in.txt contain
100,balaji,chennai
200,raj,orissa
300,charakrat,bangalore
Regards,
Balaji
Edited by: Balaji Pichaimuthu on Jul 1, 2009 3:44 PM -
hi all,
could you fix this problem in the File Adapter :-
Initialization error: Conversion initialization failed with java.lang.Exception: java.lang.Exception: Error(s) in XML conversion parameters found:
Parameter '.fieldFixedLengths' or '.fieldSeparator' is missing
while trying to write XML to a CSV file.
i've configured the FCC as:
Structure = structs ( with 6 columns)
struct.fieldFixedLengths 20,10,10,10,10,10
struct.fieldSeparator ,
struct.endSeparator 'nl'
thanks in advance
nikhil
nullI think the problem is a spelling error: you named your structure "structs" and then you refer to it as "struct".
You have to choose one between the two (or a better one if you can find it).
About File content conversion I suggest you to see the following links:
Content Conversion (Pattern/Random content in input file)
/people/anish.abraham2/blog/2005/06/08/content-conversion-patternrandom-content-in-input-file
File Content Conversion for Unequal Number of Columns
/people/jeyakumar.muthu2/blog/2005/11/29/file-content-conversion-for-unequal-number-of-columns
How to send a flat file with fixed lengths to XI 3.0 using a Central File Adapter
/people/michal.krawczyk2/blog/2004/12/15/how-to-send-a-flat-file-with-fixed-lengths-to-xi-30-using-a-central-file-adapter
Content Conversion ( The Key Field Problem )
/people/shabarish.vijayakumar/blog/2006/02/27/content-conversion-the-key-field-problem
Solution to the problem encountered using Variable Substitution with XI-SP12
/people/sravya.talanki2/blog/2005/08/11/solution-to-the-problem-encountered-using-variable-substitution-with-xi-sp12
I hope this will be helpfull.
Regards,
Salvatore -
Display BLOB and CLOB on browser
Hi All.
I need to display contents of BLOBs and CLOBs on the browser. They can be any docFlavour eg. .jpg, .gif, .pdf, .doc etc
Is there some standard way of doing this ???
If any all possible I would rather not use swing class because of its footprint and its slow performance over the net.Hi !
Just in case anyone read this and is willing to comment on it...
I have one BLOB and one CLOB column in the same record.
I have been able to stream documents into and out of the BLOB's incl. MS .doc Also I have been able to get the content from BLOB and write it to a target directory.
However I am having odd problems with CLOB, a simple text file. My servlet attempts to read the CLOB and does create the output file in the target directory, but does not copy the content over. It also returns 0 for clobLength !?! Here is the stub-code :
ResultSet clobRS = thisStmt.executeQuery (
"SELECT ATextMsg " +
"FROM ... " +
"WHERE ... " );
clobRS.next();
CLOB thisCLOB = ((OracleResultSet) clobRS).getCLOB("ATextMsg");
int chunkSize = thisClob.getChunkSize();
System.out.println("chunkSize is " + chunkSize); // default us 8132...
char [] textBuffer = new char[chunkSize];
String targetFile = targetDir + "retrieved_" + fileName;
File thisFile = new File(targetFile); // it does create an empty target file...
// read content as ASCII (text) content...
FileOutputStream thisFileOutputStream = new FileOutputStream(thisFile);
OutputStreamWriter thisWriter = new OutputStreamWriter(thisFileOutputStream);
BufferedWriter thisBufferedWriter = new BufferedWriter(thisWriter);
// things go wrong here, returns length of 0, why ?!?
long clobLength = thisClob.length();
System.out.println("clobLength is " + clobLength);
// flush to targetFile - but since clobLength=0, nothing gets copied over...
for (position=1; position<=clobLength; position+=chunkSize)
int charsRead = thisClob.getChars(position, chunkSize, textBuffer);
thisBufferedWriter.write(testBuffer);
Since the clobLength is 0, obviously it will not copy from the database CLOB to the file.
Manually change the clobLength = 8132, recompile and run, then it copies some junk to the targetFile, certainly not the textual data in the CLOB itself.
The BLOB is fine...
Can someone comment on this please and if possible, give me a hint on where I might have gone wrong with a simple text file ??? -
Hello,
In a DB to DB scenario, I am getting this error "Error: Unexpected error converting database resultset to XML, codepage conversion problem?" on the side of the sender adapter. I am not able to see any messages or trace in IE-Monitoring. Is there any log wherein I can find out the problem as to where it is occuring?
Regards,
SanjayHi Sanjay,
The JDBC sender adapter returns the rows selected from the database in the follwoing format.
<resultset>
<row>
<column-name1>column-value</ column-name1>
<column-name2>column-value</ column-name2>
<column-name3>column-value</ column-name3>
</row>
<row>
<column-name1>column-value</ column-name1>
<column-name2>column-value</ column-name2>
<column-name3>column-value</ column-name3>
</row>
</resultset>
This error occurs , when the source datatype you have created for the JDBC adapter does not match with this format. I would suggest that you check the source format along with the occurence of your field.
Regards,
Bhavesh -
IBR: Setting up DOC to XML Conversion
Hello,
I need to enable automatic conversion of DOC,DOCX documents to XML format.
I've set up IBR enabling XML Converter component then restarted IBR server. I've configured an outgoing provider from UCM to IBR and the connection is good.
When I check-in a DOC (or DOCX) file it says "GeneratingWWW" but the web viewable format generated still remains a .doc (or .docx) document.
Am I missing something??Maybe there is some additional configuration parameter to set in UCM??
Thank you in advance forn any answer.
Best Regards.I've figured out what's missing so I've solved the problem.
I (stupidly) simply forgot to enable XML conversion on "Primary Web-Viewable Rendition" tab.
Sorry for this topic! ;)
Greets! ;) -
Hi Experts,
we are facing a problem when converting one text file by using FTP adapter.
the flat txt file is as below
AT1230001
"AT" - Segment Name
"123" - Field One
"0001" - Field Two
we are using FTP Adapter conversion for the same
the result of XML is as below
- <AT>
<F1>AT</F1>
<F2>123</F2>
</AT>
for the field one it is taking the value of Segment Name, as we are giving KeyFieldValue in Configuration "AT".
please help, it is urgent,
Regards,
Study SAPHi Chirag,
Thanks for your reply,
what we are facing here is that in our flat file data, it is EDI file
AT is segment name value
*(estric) is separator
123 is first field value
0001 is second field value
in XML conversion the Segment Name is going into the first field name value and first field name is going in second field value and second field we are not able to capture as we have only two fields for capturing.
As in XML format
<AT>
<F1>AT</F1> "it is taking the value of Segment Name, but it should capture first field value which is "123"
<F2>123<F2> "it is taking the value of First field, it should capture value "0001"
</AT>
How we can ignore Segment value when transferring data ?
Regards,
Study SAP -
Help required in handling of Oracle BLOB and CLOB in OC4J
Hi,
I am in a process of porting my application from Weblogic 6 to OC4J.
I have problem while handling CLob and Blob's in oracle. Weblogic has
classes defined to do the same. (weblogic.jdbc.common.OracleClob)
Does any one know how I can achieve this.
Thanks in advance.
Regards,
MoinWe have an application running on OC4J accessing an Oracle 8.1.7 db, and have no problems using BLOBs and CLOBs. It is explained quite clearly in the Oracle documentation.
If you require further assistance let me know :-)
Maybe you are looking for
-
Opening a file opens welcome screen
This sounds silly and is not stopping me from working but is starting to get annoying. When i right click or click to open a file in Dreamweaver, Dreamweaver opens and shows the welcome screen. The file is not loaded so i have to go back and click ag
-
Adobe Digital Edition 4.0 doesn't run and a message appears
Hello, ADE doesn't open and this message appears. What is the solution or which other software can I use? Thank you.
-
Hi All, In FI-CA I am posting the document using transaction FPE1, it has field u2018BusTrnsctu2019 in this I entered main transaction and sub-transaction as 6000/0010 company code 3000 account determination 01 in the below structure for company code
-
I went to the Bootcamp Setup Assistant...
... and it says I can only install Windows 7, but I want to install Windows XP Pro SP3. Do I just continue restart and put in the Windows XP Pro SP3 disk? I also have Windows XP Home SP2 I could install but I'd rather use the Pro.
-
When plugged in, my WVC54GCA's blue LED lights up steadily, but after about 5 seconds, it goes off. Then abot 5 seconds later, it blinks twice, and then remains off. If I unplug the router, wait a bit, and plug it in again, the same sequence occurs.