Enqueuing XMLType
I am trying to enqueue an XMLType value and have some questions.
I tried to use a JMS ObjectMessage. But when I tried to setObject with the XMLType value, I get the following error:
oracle.jms.AQjmsException: JMS-157: IO Exception
Caused by: java.io.NotSerializableException: oracle.jdbc.driver.T4CConnection
I looked at the demos that came with the Oracle installation and found one which uses the AdtMessage with XMLType values. However, when I looked at the Javadoc for the classes related to the AdtMessage type, there were notes indicating that the methods would be deprecated sometime in the future.
So, my questions are:
1. Is using any of the JMS Message types out of the question for XMLType? If not, which Message type should I use? And what payload type should I use for the queue table? I know that I can convert the value to a byte array, but I was hoping to still persist the value as an XMLType. Is that possible? I've been trying to locate the Javadoc for the oracle.AQ packages, but have been unable to.
2. If I do need to use the AdtMessage type, should I be concerned about the deprecation warnings? Is it the case that these methods will merely be replaced by others? Or that support for this functionality will be going away?
Thanks so much for your help.
Code i used to complete the jms option with xml
dbms_aqadm.create_queue_table(
queue_table => 'change_q_tab',
multiple_consumers => FALSE,
storage_clause => 'TABLESPACE &x_tablespace',
sort_list => 'PRIORITY,ENQ_TIME',
message_grouping => DBMS_AQADM.NONE,
queue_payload_type =>'sys.aq$_jms_text_message',
comment => 'Creating queue table');
dbms_aqadm.create_queue(
queue_name => 'COST_CHANGE_Q',
queue_table => 'change_q_tab',
max_retries => 2,
comment => 'cost change queue');
PROCEDURE enqCostChange(
p_cost_change IN VARCHAR2
,p_priority IN NUMBER default LOW_PRIORITY
IS
PROC_NM constant VARCHAR2(30) := 'enqCostChange';
v_enqueue_opt DBMS_AQ.enqueue_options_t;
v_message_props DBMS_AQ.message_properties_t;
v_message_handle RAW(16);
-- for JMS
v_cost_change sys.aq$_jms_text_message;
v_agent sys.aq$_agent := sys.aq$_agent(' ', null, 0);
BEGIN
-- Construct the message for ENQ operation.
--JMS Construction
v_cost_change := sys.aq$_jms_text_message.construct;
v_cost_change.set_replyto(v_agent);
v_cost_change.set_type('mcd://xmlns');
v_cost_change.set_text(p_cost_change);
-- Set proper options and properties
v_enqueue_opt.visibility := DBMS_AQ.ON_COMMIT;
v_message_props.PRIORITY := p_priority ;
DBMS_AQ.enqueue (
queue_name => 'COST_CHANGE_Q',
enqueue_options => v_enqueue_opt,
message_properties => v_message_props,
payload => v_cost_change,
msgid => v_message_handle );
END enqCostChange;
Similar Messages
-
Ora-31001 invalid reference when enqueuing xmltype payload w/ dtd file ref
We're using AQ to store xmltype payloads in an Oracle 10gR2 DB.
We're able to enqueue normal XML payloads without issue, but recently we've attempted to enqueue XML with a DOCTYPE tag with reference to a dtd file. This results in an ora-31001 error stating the file reference for the dtd is invalid.
We've tried moving the dtd around, but are unsure what the oracle dbms thinks is the base dir for the file reference.
I've seen some documentation for xmldb that states the dtd must be located in reference to the xml doc, but as we are enqueueing an xmltype datatype in AQ I'm not sure how this can be applied. I've also seen documentation about using a dbms package to set the base url, but am also not sure how to apply it to this situation.
Anyone able to tell me where I can drop this dtd so that Oracle can reference it when parsing the xml during an enqueue?
Thanks!
TonySorry didn't receive email notification of your response, or I would have replied sooner. Seems like that is happening on the forums sometimes.
Here is a pl/sql block for enqueueing xml into a queue table with an xmltype payload:
BEGIN
declare
enqOpts dbms_aq.enqueue_options_t;
msgProps dbms_aq.message_properties_t;
enqMsgid raw(16);
begin
dbms_aq.enqueue(
queue_name => 'YOUR_QUEUE_NAME',
enqueue_options => enqOpts,
message_properties => msgProps,
payload => XMLType (
'<INSERT XML HERE>'),
msgid => enqMsgId);
commit;
END ;
END;
/ -
Performance of AQ when using callback procedure (using PL/SQL notification)
I am enqueueing XMLType in AQ.XML file is large in size.NOw I want to dequeue the AQ using PL/SQL notification(using callback procedure which will call DBMS_AQ.DEQUEUE to dequeue the AQ and process the XML.After fetching the data from XML ,I want to store these data in another table columns).
Please suggest,In this case which approach would be better to dequeue the AQ table :
1.PL/SQL notification(using callback procedure)
OR
2.Scheduling the call to DBMS_AQ.DEQUEUE to dequeue the AQ table
What would be the impact on performance of above two approaches?Hi,
The question of performance is not down to the technique one employes to enqueue/dequeue, but at a basic level, is relative to the number of messages!
The is what the Oracle documentation states:
>
When persistent messages are enqueued, they are stored in database tables. The performance characteristics of queue operations on persistent messages are similar to underlying database operations. The code path of an enqueue operation is comparable to SELECT and INSERT into a multicolumn queue table with three index-organized tables. The code path of a dequeue operation is comparable to SELECT, DELETE, and UPDATE operations on similar tables.
>
So, if anything, the dequeue is a fraction more time & resource consuming. However, it is only a "fraction". You could always add multiple subscribers to dequeue if you want!
You could ofcourse choose to have non-persistent messages if your application does not need the kind of fault-tolerance that persistent messaging offers, which speed things up, but only a bit, so don't get too excited about it!
There are other things to consider however, which you may wish to read up on before getting bogged down on whether you should use notification or the scheduler:
- Is your system clustered?
- Concurrency on a single queue (i.e. multiple enqueues/dequeues, but single queue)
- Propogation latency issues
Read about these and much more at:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14257/perform.htm
Finally, whether you pl/sql notification or not and whether you use dbms_scheduler is down to your application requirements!
P; -
Enqueue and xmltype and PLS-00306 error
I tried to create such a procedure but PL-SQL shows errors.
PLS-00306 Incorrect number or types of arguments for call enqueue
create or replace procedure enqueue_xmltype( queueName in varchar2,msgClob in CLOB) is
msgProp dbms_aq.message_properties_t;
enqOpt dbms_aq.enqueue_options_t;
msgHdl RAW(16);
message SYS.XMLTYPE;
begin
message:=SYS.XMLType.CreateXml(msgClob);
dbms_aq.enqueue(queue_name => queueName,
enqueue_options => enqOpt,
message_properties => msgProp,
payload => message,
msgid => msgHdl);
COMMIT;
end;
What is wrong ? I created queue table with XMLType payload.
Please help !!!
PiotrEnqueue of XMLType directly is not supported in 9.1. You need to create an ADT with an embedded XML type. Check out
http://docs.oracle.com/cd_a91034/DOC/appdev.901/a88890/adq08qap3.htm#91301
In Oracle9i release2 , you will be able to do what you are doing - ie. create queues with XMLtype payloads -
AQ XMLType : Example to Enqueue an XMLType message in 10g AQ
I am looking for an example to enqueue a XMLType message in AQ oracle 10g version : I need the actual payload example,
When I enqueue a payload the queue rejects the message.
any Help would be appreciated
Thanks
stanCreate Queue Table
EXECUTE DBMS_AQADM.CREATE_QUEUE_TABLE (queue_table=> 'fraudxml_qtab', queue_payload_type => 'sys.XMLTYPE');
Create Queue
EXECUTE DBMS_AQADM.CREATE_QUEUE (queue_name => 'fraudxml_queue', queue_table => 'fraudxml_qtab');
EXECUTE DBMS_AQADM.START_QUEUE (queue_name => 'fraudxml_queue');
This is the Enqueue
SET TIMING ON
DECLARE
enqueue_options dbms_aq.enqueue_options_t;
indoc VARCHAR2(2000);
indomdoc dbms_xmldom.domdocument;
innode dbms_xmldom.domnode;
myParser dbms_xmlparser.Parser;
message_properties dbms_aq.message_properties_t;
message_handle RAW(16);
message sys.XMLTYPE;
BEGIN
FOR j IN 1 ..100000
loop
indoc := '<emp><name> Stan </name></emp>';
myParser := dbms_xmlparser.newParser;
dbms_xmlparser.parseBuffer(myParser, indoc);
indomdoc := dbms_xmlparser.getDocument(myParser);
message := XMLTYPE(indomdoc);
-- message := XMLTYPE('<test><name>Stan Kumar</name><ID>11111111</ID></test>');
dbms_aq.enqueue(queue_name => 'msg_queue',
enqueue_options => enqueue_options,
message_properties => message_properties,
payload => message,
msgid => message_handle);
COMMIT;
end loop;
END; -
I need to enqueue xml files.How can I do this?(I need to use the JMS interfaces)
I am able to create a topic connection and session.I am unable to figure out how to create a ObjectPayload with the xml mesage in it.
I have created the necessary queue by running the following scripts:
CREATE TYPE queue_message_type AS XMLType ;
EXEC DBMS_AQADM.CREATE_QUEUE_TABLE (queue_table => 'multi_message_xml_table', queue_payload_type => 'SYS.XMLTYPE', multiple_consumers => TRUE);
EXEC DBMS_AQADM.CREATE_QUEUE (queue_name => 'multi_xml_queue', queue_table => 'multi_message_xml_table');
EXEC DBMS_AQADM.START_QUEUE (queue_name => 'multi_xml_queue');
Thanks,
MahimaJust to follow up with some other information.
I created an AQ queue with AQ$_JMS_MESSAGE as payload type. Only, JDeveloper doen't recognize this queue when trying to create an AQ adapter in an ESB or BPEL project. It says it only supports RAW or OBJECT payload types. This seems like a bug; also see: ESB 10.1.3.1 Not Connecting to AQ QUEUE with error
So I changed the payload type to SYS.XMLType and it works fine.
The PL/SQL trigger I use to enqueue messages is:
CREATE OR REPLACE TRIGGER JMSUSER.AIT_TEST AFTER INSERT ON JMSUSER.TEST_AQ_TABEL FOR each row
declare
msg SYS.XMLType;
queue_options DBMS_AQ.ENQUEUE_OPTIONS_T;
msg_props DBMS_AQ.MESSAGE_PROPERTIES_T;
msg_id RAW(16);
Begin
msg := SYS.XMLType.createXML('<?xml version="1.0"?>' || '<id xmlns="http://www.approach-alliance.com">' || :new.ID || '</id>');
DBMS_AQ.ENQUEUE(
queue_name => 'TESTXML_QUEUE',
enqueue_options => queue_options,
message_properties => msg_props,
payload => msg,
msgid => msg_id);
end ;
I can then create an AQ adapter in the ESB and transform and/or route the XML content as desired.
Regards,
Ronald -
Enqueue works fine Dequeue works when run manually but not via Notification
Hi,
My Enqueue works fine. My Dequeue procedure works fine when run manually. But when I register a notification the procedure is not called.
The log file shows:
ORACLE_HOME = /u01/app/oracle/product/10.2.0
System name: Linux
Node name: gooch.com
Release: 2.4.21-50.ELsmp
Version: #1 SMP Tue May 8 17:18:29 EDT 2007
Machine: i686
Instance name: xml
Redo thread mounted by this instance: 1
Oracle process number: 25
Unix process pid: 7761, image: [email protected] (J000)
*** 2010-03-06 14:09:22.167
*** ACTION NAME:() 2010-03-06 14:09:22.167
*** MODULE NAME:() 2010-03-06 14:09:22.167
*** SERVICE NAME:(SYS$USERS) 2010-03-06 14:09:22.167
*** SESSION ID:(145.99) 2010-03-06 14:09:22.167
Error in PLSQL notification of msgid:8128C090A10BE480E0407E0A660F1B97
Queue :"XML4"."TEST14_Q"
Consumer Name :TEST14
PLSQL function :xml4.test14_proc
: Exception Occured, Error msg:
ORA-00604: error occurred at recursive SQL level 2
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'TEST14_PROC'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
my code is
BEGIN
DBMS_AQADM.CREATE_QUEUE_TABLE(
queue_table => 'test14_t',
comment => 'Queue Table to process incoming ORDER XML messages from Management Dynamics',
multiple_consumers => TRUE,
queue_payload_type => 'SYS.XMLTYPE',
compatible => '8.1');
END;
BEGIN
DBMS_AQADM.CREATE_QUEUE(
queue_name => 'test14_q',
queue_table => 'test14_t');
END;
BEGIN
dbms_aqadm.start_queue('test14_q');
END;
BEGIN
DBMS_AQADM.ADD_SUBSCRIBER (
queue_name => 'test14_q',
subscriber => SYS.AQ$_AGENT('test14', NULL, NULL)
END;
CREATE or replace PROCEDURE test14_proc AS
deq_opts dbms_aq.dequeue_options_t;
mess_prop dbms_aq.message_properties_t;
mess_handle RAW(16);
message XMLTYPE;
buffer varchar2(100);
msglen number;
begin
deq_opts.wait := dbms_aq.FOREVER;
deq_opts.consumer_name := 'test14';
dbms_aq.dequeue(queue_name=> 'test14_q',
dequeue_options => deq_opts,
message_properties => mess_prop,
payload => message,
msgid => mess_handle);
commit;
insert into testxml values(message);
commit;
insert into hello select extractvalue(xml1, '/Hello') from testxml;
commit;
end test14_proc;
DECLARE
queue_options DBMS_AQ.ENQUEUE_OPTIONS_T;
message_properties DBMS_AQ.MESSAGE_PROPERTIES_T;
message_id RAW(16);
message SYS.XMLType;
BEGIN
message := sys.XMLType.createXML('<?xml version="1.0"?><Hello>Test</Hello>');
DBMS_AQ.ENQUEUE( queue_name => 'test14_q',
enqueue_options => queue_options,
message_properties => message_properties,
payload => message,
msgid => message_id);
COMMIT;
END;
BEGIN
DBMS_AQ.REGISTER (
SYS.AQ$_REG_INFO_LIST(
SYS.AQ$_REG_INFO(
'xml4.test14_q:test14',
DBMS_AQ.NAMESPACE_AQ,
'plsql://xml4.test14_proc?PR=0',
HEXTORAW('FF'))),1);
END;Any ideas?
Thanks in advance!I actually changed it to process RAW as well i.e.
BEGIN
DBMS_AQ.REGISTER (
SYS.AQ$_REG_INFO_LIST(
SYS.AQ$_REG_INFO(
'xml4.test14_q:test14',
DBMS_AQ.NAMESPACE_AQ,
'plsql://xml4.test14_proc?PR=0',
HEXTORAW('FF'))),1);
END;and it still is failing with the same error -
Reading Advance Queuing with XMLType payload and JDBC Driver character encoding
Hi
I've got a problem retrieving the message from the queue with XMLType payload in Java.
It was working fine in 10g database but after the switch to 11g it returns corrupted string instead of real XML message. Database NLS_LANG setting is AL32UTF8
It is said that JDBC driver should deal with that automatically but it obviously don't in this case. When I dequeue the message using database functionality (DBMS_AQ package) it looks fine but not when using JDBC driver so Ithink it is character encoding issue or so. The message itself is enqueued by the database and supposed to be retrieved by dedicated EJB.
Driver file used: ojdbc6.jar
Additional libraries: aqapi.jar, xdb.jar
All file taken from 11g database installation.
What shoul dI do to get the xml message correctly?Do you mean NLS_LANG is AL32UTF8 or the database character set is AL32UTF8? What is the database character set (SELECT value FROM nls_database_parameters WHERE parameter='NLS_CHARACTERSET')?
Thanks,
Sergiusz -
Standard datatype in dbms_aq.enqueue procedure
Payload argument is defined as standard datatype in dbms_aq.enqueue procedure definition. Any object type can then be passed to the enqueue procedure. Can we define an argument's type as STANDARD in a user defined PL/SQL procedure ?
What is standard datatype ? I haven't seen documentation for it.
PROCEDURE ENQUEUE
Argument Name Type
QUEUE_NAME VARCHAR2 IN
PAYLOAD STANDARD IN
other arguments..The payload has to be a user created object type. In Oracle9i you can use SYS.Anydata or SYS.XMLType.
-
Using XMLType as the AQ payload type
Can you help
Some developers working on a 9.2 db are under the impression that to use XMLType as the AQ payload type you need to have XML db (catqm etc) installed . Is this true ?
ie I don't want to install it unless necessary
Currently have the the XML sdk installed (initxml.sql)
ThanksHey,
I need some examples on how to actually enqueue an XMLType message into the Queue
Here is my PL/SQL Script
SET TIMING ON
DECLARE
enqueue_options dbms_aq.enqueue_options_t;
indoc VARCHAR2(2000);
indomdoc dbms_xmldom.domdocument;
innode dbms_xmldom.domnode;
myParser dbms_xmlparser.Parser;
message_properties dbms_aq.message_properties_t;
message_handle RAW(16);
message sys.XMLTYPE;
BEGIN
FOR j IN 1 ..100000
loop
indoc := '<emp><name> Stan </name></emp>';
myParser := dbms_xmlparser.newParser;
dbms_xmlparser.parseBuffer(myParser, indoc);
indomdoc := dbms_xmlparser.getDocument(myParser);
message := XMLTYPE(indomdoc);
-- message := XMLTYPE('<test><name>Stan </name><ID>11111111</ID></test>');
dbms_aq.enqueue(queue_name => 'msg_queue',
enqueue_options => enqueue_options,
message_properties => message_properties,
payload => message,
msgid => message_handle);
COMMIT;
end loop;
END; -
The XML column is stored as CLOB:
SQL> SELECT column_name,
2 storage_type
3 FROM user_xml_tab_cols
4 WHERE table_name = 'DEMO';
COLUMN_NAME STORAGE_TYPE
COL2 CLOB
I'm running the following procedure.
DECLARE
v_lcr SYS.LCR$_ROW_RECORD;
v_new SYS.LCR$_ROW_LIST := SYS.LCR$_ROW_LIST();
v_xml XMLTYPE;
BEGIN
v_new.EXTEND;
v_new(1) := SYS.LCR$_ROW_UNIT( column_name => 'COL1',
data => ANYDATA.CONVERTNUMBER(1),
lob_information => DBMS_LCR.NOT_A_LOB,
lob_offset => NULL,
lob_operation_size => NULL,
long_information => DBMS_LCR.not_a_long );
v_new.EXTEND;
v_new(2) := SYS.LCR$_ROW_UNIT( column_name => 'COL2',
data => ANYDATA.CONVERTOBJECT(v_xml),
lob_information => DBMS_LCR.EMPTY_LOB,
lob_offset => NULL,
lob_operation_size => NULL,
long_information => DBMS_LCR.not_a_long );
v_lcr := SYS.LCR$_ROW_RECORD.CONSTRUCT(
SOURCE_DATABASE_NAME => 'WHATEVER',
COMMAND_TYPE => 'INSERT',
OBJECT_OWNER => 'DRH_R9',
OBJECT_NAME => 'demo',
NEW_VALUES => v_new );
v_lcr.EXECUTE(FALSE);
END;
The error comes from the EXECUTE call. If I remove the xmltype column everything works fine. Am I missing something?
ThanksAs per the 11.1 documentation xmltype stored as lob is not supported in user enqueued messages:
See Table 11.1 LOB Data Type Representations in Row LCRs
Oracle® Streams Replication Administrator's Guide 11g Release 1 (11.1)
Chapter 11
It is though supported in captured messages -
Strategy and Process on how to best enqueue from the file system
I have a single database that must accept BFILES from one location via a directory folder, http text documents via proxy server, and unstructured XMLTYPE CLOB from another database.
I have created an ANYDATA queue, and will try to transform the dequeued output to XMLTYPE payloads for a pl/sql callback.
My problem is how to monitor both the file system BFILE folder, and the XMLTYPE CLOBS, to automatically begin then enqueue process. The queue would have to accept from (1) to anynumber of files, and given that requirement the use of an array batch is what I would like to use, but need to populate the array.
Any help would be most appreciated.
DavidThank you for the quick reply.
The database version is 10.2.0.3.
There are three sources of documents coming into the system.
Source 1: Outside entity (in-front of a secure firewall) who must place their XML (XSD compliant) files on a shared file system server (the BFILES).
Source 2: Internal entity (behind firewall) who publishes their XML files to a defined database directory on the database server.
Source 3: Enterprise Intranet contributors submitting their individual files via url.
On entry for each file they must be validated for XSD compliance then if passed submitted to the main enqueue for propagation to 5 additional process queues with separate callback procedures.
If reasonably possible, separate agents of some sort would "listen" at each folder location, then begin the enqueue process when either a batch of files or a single file is placed in the directory folder.
AQ itself has no such mechanism to monitor locations, and a scheduled job makes sense - however the job would have to continuously run given the very short processing requirement. However, using DBMS_SCHEDULER may be the best solution given ALL rhe requirements.
Thank you for your professionalism - I appreciate the assistance. -
Help on how to query 11g table with XMLType column
To all,
We have this table:
DESC MESSAGE
Name Null Type
MESSAGE_ID NOT NULL NUMBER(38)
REQUEST_UU_ID NOT NULL VARCHAR2(50)
MESSAGE_TYPE_CD NOT NULL CHAR(3 CHAR)
EMPLOYEE_NUM NOT NULL VARCHAR2(8)
SEQUENCE_NUM VARCHAR2(20)
REVERSAL_SEQUENCE_NUM VARCHAR2(20)
TRANSACTION_TS TIMESTAMP(6)
MESSAGE_CONTENT_TXT NOT NULL XMLTYPE()
CREATE_BY_NM NOT NULL VARCHAR2(50 CHAR)
CREATE_BY_TS NOT NULL TIMESTAMP(6)
LAST_UPDATE_BY_NM NOT NULL VARCHAR2(50 CHAR)
LAST_UPDATE_BY_TS NOT NULL TIMESTAMP(6)
Given we have multiple columns and one is XMLType how do I query to find rows in the db that match this XPath
Here is a fragment of XML that is held in MESSAGE_CONTENT_TXT XMLType column:
<?xml version="1.0" encoding="UTF-8"?>
<cfg-env:Envelope xmlns="http://www.co.com/schemas/CFX/" xmlns:cfg-env="http://www.co.com/schemas/cfg-env/" xmlns:cfg-hdr="http://www.co.com/schemas/cfg-hdr/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.co.com/schemas/cfg-env/" >
<cfg-env:Header>
<cfg-hdr:MessageHeader xmlns:cfg-hdr="http://www.co.com/schemas/cfg-hdr/" xmlns:cfg-env="http://www.co.com/schemas/cfg-env/" xmlns="http://www.co.com/schemas/CFX/">
<cfg-hdr:Service>
<cfg-hdr:ServiceName>process</cfg-hdr:ServiceName>
<cfg-hdr:MessageType>Request</cfg-hdr:MessageType>
<cfg-hdr:ServiceVersion>1</cfg-hdr:ServiceVersion>
</cfg-hdr:Service>
<cfg-hdr:From>
<cfg-hdr:PartyId>13-175-8724</cfg-hdr:PartyId>
<cfg-hdr:CostCenter>2009065</cfg-hdr:CostCenter>
<cfg-hdr:System>
<cfg-hdr:Application>[email protected]</cfg-hdr:Application>
<cfg-hdr:Version>1.0</cfg-hdr:Version>
<cfg-hdr:Channel>TLR</cfg-hdr:Channel>
</cfg-hdr:System>
<cfg-hdr:OrigReplyToQMgr>QMBKRD01</cfg-hdr:OrigReplyToQMgr>
<cfg-hdr:OrigReplyToQ>Q1</cfg-hdr:OrigReplyToQ>
</cfg-hdr:From>
<cfg-hdr:UserSession>
<cfg-hdr:SignonRole>User</cfg-hdr:SignonRole>
<cfg-hdr:LogonId>R099999</cfg-hdr:LogonId>
I'm trying to find rows in the database that are /Envelope/Header/MessageHeader/UserSession/LogonId/R099999.
Thanks for the assistance. I'm new to XML DB. I appreciate the help.
EricHi Eric,
You can use XMLExists, like this :
select *
from message t
where xmlexists(
'declare namespace env = "http://www.co.com/schemas/cfg-env/"; (: :)
declare namespace hdr = "http://www.co.com/schemas/cfg-hdr/"; (: :)
/env:Envelope/env:Header/hdr:MessageHeader/hdr:UserSession[hdr:LogonId=$id]'
passing t.message_content_txt
, 'R099999' as "id"
); -
Unable to convert BLOB to XML using XMLTYPE
Hello (XML) Experts
I need your help with manipulating a BLOB column containing XML data - I am encountering the following error:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00200: could not convert from encoding UTF-8 to WINDOWS-1252
Error at line 1
ORA-06512: at "SYS.XMLTYPE", line 283
I am on Windows 7 64 bit, Oracle 11.2.0.3 64 bit and database character set is WE8MSWIN1252, NLS_LANG is set to AMERICAN_AMERICA.AL32UTF8. The BLOB column contains the following XML data:
<?xml version="1.0" encoding="utf-8"?>
<Root CRC="-4065505">
<Header Converted="0">
<Version Type="String" Value="512" />
<Revision Type="String" Value="29" />
<SunSystemsVersion Type="String" Value="" />
<Date Type="String" Value="20080724" />
<Time Type="String" Value="165953" />
<DAG Type="String" Value="" />
<ChkID Type="String" Value="" />
<FormType Type="String" Value="1" />
<DB Type="String" Value="AllBusinessUnits" />
<FuncID Type="String" Value="SOE" />
<Status Type="String" Value="" />
<FileType Type="String" Value="SFL" />
<Descriptions>
<Default Type="String" Value="Sales Order Entry" />
<L01 Type="String" Value="Sales Order Entry" />
<L33 Type="String" Value="Saisie commande client" />
<L34 Type="String" Value="Entrada de órdenes de venta" />
<L39 Type="String" Value="Inserimento ordine di vendita" />
<L49 Type="String" Value="Aufträge erfassen" />
<L55 Type="String" Value="Entrada de pedido de venda" />
<L81 Type="String" Value="�注オーダー入力" />
<L86 Type="String" Value="销售订�录入" />
<L87 Type="String" Value="銷售訂單錄入" />
</Descriptions>
</Header>
<FormDesignerAppVer Type="String" Value="5.1" SFLOnly="1" />
</Root>I am using the XMLTYPE constructor and passing in the BLOB column and the character set id of the XML data stored in the BLOB column in order to extract and update a node in the XML as follows:
select xmltype(srce_form_detail,873) from SRCE_FORM where 873 above corresponds to the utf-8 encoding of the XML data in the BLOB column i.e. AL32UTF8, but this results in the above error.
I have also tried converting the BLOB to a CLOB first as below where BLOB2CLOB is a function that converts the BLOB to a CLOB:
select xmltype(BLOB2CLOB(srce_form_detail)).EXTRACT('/Root/Header/DB').getStringVal() XMLSrc from SRCE_FORM;This results in the following error:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00210: expected '<' instead of '¿'
Error at line 1
ORA-06512: at "SYS.XMLTYPE", line 272
ORA-06512: at line 1
Looking at the XML in the BLOB I noticed that it contains a BOM(byte order mark) and this is causing the XML parsing to fail and I don't know how to deal with it and I don't want to simply SUBSTR it out.
What I am trying to achieve is to extract the contents of the DB node in the XML and depending on its value I need to update the 'Value' part of that node. I am stuck at the point of extracting the contents of the DB node.
I hope I have provided enough information and I would appreciate any suggestions on how best to resolve this - my XML knowledge is very limited so I would appreciate any help.
Regards,
MohinderHi Marc
Thanks for your response.
You are correct that the blob contains Japanese and Chinese characters but I was expecting that using the XMLTYPE constructor would convert the character set albeit with some data loss or then not display the Chinese and Japanese characters correctly.
It seems to me that XMLTYPE is not handling/interpreting the BOM contained in the BLOB since even converting the BLOB to CLOB is resulting in an error. If I use SUBSTR and ignore the BOM to extract the XML from the BLOB then it works and as expected the Chinese and Japanese characters are not displayed correctly, they are displayed as '¿' corresponding to the lines beginning with L81, L86 & L87 , see below:
select xmltype(SUBSTR(BLOB2CLOB(srce_form_detail),4)) from SRCE_FORM
<?xml version="1.0" encoding="utf-8"?>
<Root CRC="-4065505">
<Header Converted="0">
<Version Type="String" Value="512" />
<Revision Type="String" Value="29" />
<SunSystemsVersion Type="String" Value="" />
<Date Type="String" Value="20080724" />
<Time Type="String" Value="165953" />
<DAG Type="String" Value="" />
<ChkID Type="String" Value="" />
<FormType Type="String" Value="1" />
<DB Type="String" Value="AllBusinessUnits" />
<FuncID Type="String" Value="SOE" />
<Status Type="String" Value="" />
<FileType Type="String" Value="SFL" />
<Descriptions>
<Default Type="String" Value="Sales Order Entry" />
<L01 Type="String" Value="Sales Order Entry" />
<L33 Type="String" Value="Saisie commande client" />
<L34 Type="String" Value="Entrada de ¿¿rdenes de venta" />
<L39 Type="String" Value="Inserimento ordine di vendita" />
<L49 Type="String" Value="Auftr¿¿ge erfassen" />
<L55 Type="String" Value="Entrada de pedido de venda" />
<L81 Type="String" Value="¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿" />
<L86 Type="String" Value="¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿" />
<L87 Type="String" Value="¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿" />
</Descriptions>
</Header>Can you please let me know how I can extract the binary dump of the BLOB and post it on the forum as I don't know how to do this. Below is snippet of the hexadecimal dump, that includes the BOM. I can post the full hexadecimal dump if this can help you to reproduce the error ?
EFBBBF3C3F786D6C2076657273696F6E3D22312E302220656E636F64696E673D227574662D38223F3E0D0A3C526F6F74204352433D222D34303635353035223E0D0A20203C48656164657220436F6E7665727465643D2230223E0D0A202020203C56657273696F6E20547970653D22537472696E67222056616C75653D2235313222202F3E0D0A202020203C5265766973696F6E20547970653D22537472696E67222056616C75653D22323922202F3E0D0A202020203C53756E53797374656D7356657273696F6E20547970653D22537472696E67222056616C75653D2222202F3E0D0A202020203C4461746520547970653D22537472696E67222056616C75653D22323030383037323422202F3E0D0A202020203C54696D6520547970653D22537472696E67222056616C75653D2231363539353322202F3E0D0A202020203C44414720547970653D22537472696E67222056616C75653D2222202F3E0D0A202020203C43686B494420547970653D22537472696E67222056616C75653D2222202F3E0D0A202020203C466F726D5479706520547970653D22537472696E67222056616C75653D223122202F3E0D0A202020203C444220547970653D22537472696E67222056616C75653D22416C6C427573696E657373556E69747322202F3E0D0A202020203C46756E63494420547970653D22537472696E67222056616C75653D22534F4522202F3E0D0A202020203C53746174757320547970653D22537472696E67222056616C75653D2222202F3E0D0A202020203C46696C655479706520547970653D22537472696E67222056616C75653D2253464C22202F3E0D0A202020203C4465736372697074696F6E733E0D0A2020202020203C44656661756C7420547970653D22537472696E67222056616C75653D2253616C6573204F7264657220456E74727922202F3E0D0A2020202020203C4C303120547970653D22537472696E67222056616C75653D2253616C6573204F7264657220456E74727922202F3E0D0A2020202020203C4C333320547970653D22537472696E67222056616C75653D2253616973696520636F6D6D616E646520636C69656E7422202F3E0D0A2020202020203C4C333420547970653D22537472696E67222056616C75653D22456E747261646120646520C3B37264656E65732064652076656E746122202F3E0D0A2020202020203C4C333920547970653D22537472696E67222056616C75653D22496E736572696D656E746F206F7264696E652064692076656E6469746122202F3E0D0A2020202020203C4C343920547970653D22537472696E67222056616C75653D224175667472C3A4676520657266617373656E22202F3E0D0A2020202020203C4C353520547970653D22537472696E67222056616C75653D22456E74726164612064652070656469646F2064652076656E646122202F3E0D0A2020202020203C4C383120547970653D22537472696E67222056616C75653D22E58F97E6B3A8E382AAE383BCE38380E383BCE585A5E58A9B22202F3E0D0A2020202020203C4C383620547970653D22537472696E67222056616C75653D22E99480E594AEE8AEA2E58D95E5BD95E585A522202F3E0D0A2020202020203C4C383720547970653D22537472696E67222056616C75653D22E98AB7E594AEE8A882E596AEE98C84E585A522202F3E0D0A202020203C2F4465736372697074696F6E733E0D0A20203C2F4865616465723E0D0A20203C466F726D3E0D0A202020203C4372656174696F6E4C616E6720547970653D22537472696E67222056616C75653D223031222053464C4F6E6C793D223122202F3E0D0A202020203C416374696F6E733E0D0A2020202020203C5065726D697373696F6E73202F3E0D0A202020203C2F416374696F6E733E0D0A202020203C48656C70202F3E0D0A202020203C466F6E743E0D0A2020202020203C446566466F6E7453697A6520547970653D22496E7465676572222056616C75653D2238222053464C4F6E6C793D223122202F3E0D0A2020202020203C466F6E743E0D0A20202020202020203C4C616E677561676520547970653D22537472696E67222056616C75653D2244656661756C7422202F3E0D0A20202020202020203C466F6E744E616D6520547970653D22537472696E67222056616C75653D224D532053616E7320536572696622202F3E0D0A2020202020203C2F466F6E743E0D0A2020202020203C466F6E743E0D0A20202020202020203C4C616E677561676520547970653D22537472696E67222056616C75653D22383122202F3E0D0A20202020202020203C466F6E744E616D6520547970653D22537472696E67222056616C75653D224D5320554920476F7468696322202F3E0D0A2020202020203C2F466F6E743E0D0A202020203C2F466F6E743E0D0A202020203C436F6E74726F6C733E0D0A2020202020203C436F6E74726F6C3E0D0A20202020202020203C436F6E74726F6C5479706520547970653D22496E746567657222204644496E743D2231222056616C75653D223122202F3E0D0A20202020202020203C446973706C61795479706520547970653D22537472696E6722204644496E743D2230222056616C75653D22466F726D2057696E646F77222053464C4F6E6C793D223122202F3E0D0A20202020202020203C43617074696F6E20547970653D22537472696E6722204644496E743D2230222056616C75653D2253597C3F7C55547C3F7C3F3F3F3F3F3F22202F3E0DThe XML I posted so far is actually truncated as the full XML is quite big but I showed the beginning of it as this is the section I believe that is not being handled properly. Furthermore I am able to write the BLOB out to a file successfully without any errors using DBMS_LOB & UTL_FILE.PUT_RAW and this seems to handle the BOM without any issues but what I really need to do is read a single node in the XML and update it directly preferably using XMLTYPE directly with the BLOB.
I would welcome your suggestions on how best to read a single node and update it when the XML is contained in a BLOB.
Regards,
Mohinder -
Move XMLTYPE data to a remote database
Hello,
I need your experience !!!!!
I am working with the 10.2.1 database.
I have try to call a remote procedure (using DBLINK) with a XMLTYPE parameter, I get a error link to a lob locator.
One solution could be to save XMLTYPE to disk.
Some body know other solution to transfer XMLTYPE data to a remote database.
Thanks in advance
Best RegardsA future alternative will be Oracle streams and b.t.w. one of the advantages (sometimes not, but anyway) of an Oracle database is that you can use object orientated methods, relational methods, java solutions, etc. and nowadays XML methods. XML was once all about transporting data, creating an uniform interface between solutions (databases, application/webservers, technology stacks, etc...). Think out of the Box. XMLDB isn't relational, but it is packaged in one. Make use of it and vice versa.
Maybe you are looking for
-
Hi, I have (stupid perhaps) question. Is this scenario possible: SNC connection from SAP GUI to SAP Router, and non-SNC connection from SAP Router to SAP System. I know how to set up scenario like this: SAP System --- (non-SNC conn) --- saprouter1 --
-
New to Garage Band..Need advice please...
Hello everyone, I would like to get back to playing the piano and am extremely confused about MIDI controllers and digital keyboards or pianos. I just want to be able to play the piano when I feel like it and then if I want to record some stuff, I ca
-
Installing os lion on multiple computers? Here's how...with a catch
Here is every bit of info i have gathered concerning this matter. For some reason it won't let me access the chat i had with a store representative but that doesn't matter. It IS long, but it is neccessary you get all the info. NOTE: the emails shown
-
when I use oracle 11 and have it set in automatic (in services) it operates properly. (after restart) When I have it in manual (in services) i get the message 'Firefox can't establish a connection to the server at localhost:1158.' We use the computer
-
PDF won't print form fields created within CS6
Hello! I have created a document within InDesign CS6 that contains "Text Field" form fields. I exported the document as an "Interactive PDF" and within Adobe Acrobat 10 (Professional) I can see the the form fields as pale blue boxes (see screen shots