Load XML to CLOB column
i want to load xml file to a column with CLOB datatype.
I can do it with the help of tools like TOAD etc but i want to do through sql or pl/sql.
Can anybody can help on this?
Check this.
http://www.oracle.com/technology/sample_code/tech/java/codesnippet/xmldb/HowToLoadLargeXML.html#PLSQLCode
Regards
Sundar
Similar Messages
-
I’m building some ETL process to extract data from XML in CLOB columns. I know that there are solutions to use functions as extractvalue() of WB_XML_LOAD(), but I want to know if there is any other way to deal with XML. The reason for that is because my XML files have multiple namespaces and nodes, and I need something more complex to deal with that, since I already tried those two first solutions.
My first solution was to create a PL/SQL that parses the XML and looks for tags and elements. It populates a relational table, and I might use OWB to extract the data from this table. But I’m dealing with a large table and it takes a while for processing, plus my code is hude!
My question is: Does someone have any experience with complex XML in Clob columns? If so, what was your solution for that?
Thanks a lot!
Angelo Buss
[email protected]CLOB is a fully-updateable, character large object that is stored inside the database. It can be text-indexed using interMedia for document searching.
BFILE is a readonly pointer to a file on the external file system whose content is not physically stored in the database. It can also be text-indexed for document searching, but it can't be updated. -
XML Import CLOB column size limit
I have a table with a CLOB column and some of the rows have up to 7000 characters in the column. I exported the table to XML and the XML file contains all the data. When I try to import the file into another APEX instance I get the error:
XML Load error.
After some experimentation, I found that If I manually edit the XML to reduce the size of the text to under 4000 characters (3700 in my test), it imports fine.
Is there a way around this limitation? The database I'm migrating has LOTS of CLOB columns (converted from MS Access "memo" fields).jlange,
Having converted a bunch of MS Access applications myself, I would encourage you to look at the Oracle Migration Workbench (OMWB): http://www.oracle.com/technology/tech/migration/index.html
This free tool can be downloaded from OTN, and provides a more streamlined approach to moving the data from MS Access to Oracle, including support for Memos to CLOBs.
Once you're data has been moved over, you can then use ApEx to re-create the UI.
Thanks,
- Scott - -
Problem in Loading data for clob column using sql ldr
Hi,
I am having problem in loading data for tables having clob column.
Could anyone help me in correcting the below script for ctrl file inorder to load the data which is in mentioned format.
Any help really appreciated.
Table Script
Create table samp
no number,
col1 clob,
col2 clob
Ctrl File
options (skip =1)
load data
infile 'c:\1.csv'
Replace into table samp
fields terminated by ","
trailing nullcols
no,
col1 Char(100000000) ,
col2 Char(100000000) enclosed by '"' and '"'
Data File(1.csv)
1,asdf,"assasadsdsdsd""sfasdfadf""sdsdsa,ssfsf"
2,sfjass,"dksadk,kd,ss""dfdfjkdjfdk""sasfjaslaljs"
Error Encountered
ORA-01461: can bind a LONG value only for insert into a LONG column
Table sampThanks in advanceI can't reproduce it on my 10.2.0.4.0. CTL file:
load data
INFILE *
Replace into table samp
fields terminated by ","
trailing nullcols
no,
col1 Char(100000000) ,
col2 Char(100000000) enclosed by '"' and '"'
BEGINDATA
1,asdf,"assasadsdsdsd""sfasdfadf""sdsdsa,ssfsf"
2,sfjass,"dksadk,kd,ss""dfdfjkdjfdk""sasfjaslaljs"Loading:
SQL> Create table samp
2 (
3 no number,
4 col1 clob,
5 col2 clob
6 );
Table created.
SQL> host sqlldr scott/tiger control=c:\temp\samp.ctl log=c:\temp\samp.log
SQL> select * from samp
2 /
NO
COL1
COL2
1
asdf
assasadsdsdsd"sfasdfadf"sdsdsa,ssfsf
2
sfjass
dksadk,kd,ss"dfdfjkdjfdk"sasfjaslaljs
NO
COL1
COL2
SQL> SY. -
Select fields from XML in CLOB column
Hi,
I have the following XML stored in a table as CLOB field. What i want is to select specific fields into Relational Data.
<?xml version=1.0 encoding=UTF-8?>
<msgContext>
<JMSHeaders xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">
<jms1:JMSDeliveryMode>PERSISTENT</jms1:JMSDeliveryMode>
<jms1:JMSTimestamp>1329217943352</jms1:JMSTimestamp>
<jms1:JMSExpiration>0</jms1:JMSExpiration>
<jms1:JMSRedelivered>false</jms1:JMSRedelivered>
<jms1:JMSPriority>4</jms1:JMSPriority>
</JMSHeaders>
<OtherProperties>
<auditPartnerId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">010000000001189CC2BC2C</auditPartnerId>
<auditServiceId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">Auth</auditServiceId>
<correlationTransactionId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">d0022064-1df3-43ef-be5b-93aedc96b3b2</correlationTransactionId>
<auditReceivedDate xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">2012-02-14 12:12:23.346 +0100</auditReceivedDate>
<auditStatus xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">ok</auditStatus>
<auditForwardedDate xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">2012-02-14 12:12:23.351 +0100</auditForwardedDate>
<auditMsisdn xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms"/>
<auditEngineId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">dpNorthLog</auditEngineId>
<ns0:auditInfo xmlns:ns0="http://www.tibco.com/schemas/Project_gig_reporting/tib_bw_reporting/Resources/Schemas/auditInfo.xsd">
<ns0:dp-logpoint>response</ns0:dp-logpoint>
<ns0:dp-target-url/>
<ns0:dp-port>20565</ns0:dp-port>
<ns0:dp-uri>/comp_am</ns0:dp-uri>
<ns0:dp-size>1365</ns0:dp-size>
<ns0:dp-replytoengine/>
</ns0:auditInfo>
</OtherProperties>
</msgContext>I tried to use the xml_query below with no luck :
SELECT x.auditPartnerId,
x.auditServiceId
FROM source s
, XMLTable(
'/msgContext/OtherProperties'
passing s.messagetext
columns
auditPartnerId VARCHAR2(20) PATH 'auditPartnerId'
, auditServiceId VARCHAR2(20) PATH 'auditServiceId'
) x;Any help appreciatedalekons wrote:
Any help appreciatedYou will have to convert it to xmltype first. See below:
SQL> select * from v$version ;
BANNER
Oracle Database 10g Release 10.2.0.5.0 - Production
PL/SQL Release 10.2.0.5.0 - Production
CORE 10.2.0.5.0 Production
TNS for Linux: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production
SQL> with src as ( select to_clob('<msgContext>
<JMSHeaders xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">
<jms1:JMSDeliveryMode>PERSISTENT</jms1:JMSDeliveryMode>
<jms1:JMSTimestamp>1329217943352</jms1:JMSTimestamp>
<jms1:JMSExpiration>0</jms1:JMSExpiration>
<jms1:JMSRedelivered>false</jms1:JMSRedelivered>
<jms1:JMSPriority>4</jms1:JMSPriority>
</JMSHeaders>
<OtherProperties>
<auditPartnerId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">010000000001189CC2BC2C</auditPartnerId>
<auditServiceId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">Auth</auditServiceId>
<correlationTransactionId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">d0022064-1df3-43ef-be5b-93aedc96b3b2</correlationTransactionId>
<auditReceivedDate xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">2012-02-14 12:12:23.346 +0100</auditReceivedDate>
<auditStatus xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">ok</auditStatus>
<auditForwardedDate xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">2012-02-14 12:12:23.351 +0100</auditForwardedDate>
<auditMsisdn xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms"/>
<auditEngineId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">dpNorthLog</auditEngineId>
<ns0:auditInfo xmlns:ns0="http://www.tibco.com/schemas/Project_gig_reporting/tib_bw_reporting/Resources/Schemas/auditInfo.xsd">
<ns0:dp-logpoint>response</ns0:dp-logpoint>
<ns0:dp-target-url/>
<ns0:dp-port>20565</ns0:dp-port>
<ns0:dp-uri>/comp_am</ns0:dp-uri>
<ns0:dp-size>1365</ns0:dp-size>
<ns0:dp-replytoengine/>
</ns0:auditInfo>
</OtherProperties>
</msgContext>') as messagetext from dual )
SELECT x.auditPartnerId,
x.auditServiceId
FROM src s
, XMLTable(
'/msgContext/OtherProperties'
passing s.messagetext
columns
auditPartnerId VARCHAR2(20) PATH 'auditPartnerId'
, AUDITSERVICEID VARCHAR2(20) PATH 'auditServiceId'
) x;
36 37 passing s.messagetext
ERROR at line 33:
ORA-00932: inconsistent datatypes: expected - got CLOB
with src as ( select xmltype(to_clob('<msgContext>
<JMSHeaders xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">
<jms1:JMSDeliveryMode>PERSISTENT</jms1:JMSDeliveryMode>
<jms1:JMSTimestamp>1329217943352</jms1:JMSTimestamp>
<jms1:JMSExpiration>0</jms1:JMSExpiration>
<jms1:JMSRedelivered>false</jms1:JMSRedelivered>
<jms1:JMSPriority>4</jms1:JMSPriority>
</JMSHeaders>
<OtherProperties>
<auditPartnerId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">010000000001189CC2BC2C</auditPartnerId>
<auditServiceId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">Auth</auditServiceId>
<correlationTransactionId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">d0022064-1df3-43ef-be5b-93aedc96b3b2</correlationTransactionId>
<auditReceivedDate xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">2012-02-14 12:12:23.346 +0100</auditReceivedDate>
<auditStatus xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">ok</auditStatus>
<auditForwardedDate xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">2012-02-14 12:12:23.351 +0100</auditForwardedDate>
<auditMsisdn xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms"/>
<auditEngineId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">dpNorthLog</auditEngineId>
<ns0:auditInfo xmlns:ns0="http://www.tibco.com/schemas/Project_gig_reporting/tib_bw_reporting/Resources/Schemas/auditInfo.xsd">
<ns0:dp-logpoint>response</ns0:dp-logpoint>
<ns0:dp-target-url/>
<ns0:dp-port>20565</ns0:dp-port>
<ns0:dp-uri>/comp_am</ns0:dp-uri>
<ns0:dp-size>1365</ns0:dp-size>
<ns0:dp-replytoengine/>
</ns0:auditInfo>
</OtherProperties>
</msgContext>')) as messagetext from dual )
SELECT x.auditPartnerId,
x.auditServiceId
FROM src s
, XMLTable(
'/msgContext/OtherProperties'
passing s.messagetext
columns
auditPartnerId VARCHAR2(20) PATH 'auditPartnerId'
, AUDITSERVICEID VARCHAR2(20) PATH 'auditServiceId'
37 ) x;
AUDITPARTNERID AUDITSERVICEID
010000000001189CC2BC Auth -
SQL LOADER: how to load CLOB column using stored function
Hi,
I am a newbie of sql loader. Everything seems to be fine until I hit a
road block - the CLOB column type. I want to load data into the clob
column using a stored function. I need to do some manipulation on the
data before it gets saved to that column. But I got this error when I
run the sql loader.
SQL*Loader-309: No SQL string allowed as part of "DATA" field
specification
DATA is my CLOB type column.
here is the content of the control file:
LOAD DATA
INFILE 'test.csv'
BADFILE 'test.bad'
DISCARDFILE 'test.dsc'
REPLACE
INTO TABLE test_table
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
codeid BOUNDFILLER,
reason BOUNDFILLER,
Checkstamp "to_date(:CHECKSTAMP, 'mm/dd/yyyy')",
"DATA" "GetContent(:codeid, :reason)"
All references are suggesting to use a file to load data on
CLOB column but I want to use a function in which it generates
the content to be saved into the column.
Any help is greatly appreciated.
Thanks,
Baldwin
MISICompany*** Duplicate Post ... Please Ignore ***
-
I am not sure if this is the correct forum for this question, so please forgive if this is posted in wrong forum.
I am new to working with CLOBs in Oracle. The procedure updates a CLOB column which stores large XML files. The XML files are first moved to the /u04 directory, then we execute the procedure which looks for the XML in /u04, then uses those XML files to update the CLOB column.
The procure works fine in our development environment, but doesn't work in our System Test box. No exceptions are thrown in Sys Test, but when we check the CLOB column it's NULL/empty.
Both Dev and Sys Test environments are on the same physical server.
Is there something in the database setup I should be looking for which may cause this difference in functionality?
Code is below. I'm sure it could be better but this is my first go-around with CLOBs.
Any help is greatly appreciated!
--open CLOB used to clear out old XML in CLOB column
dbms_lob.open(v_pre_clob, dbms_lob.lob_readwrite);
-- prep XML CLOB column for update
UPDATE REPORT_TBL
SET REPORT_XML = v_pre_clob
WHERE REPORT_ID = p_rep_id;
--Close pre-update CLOB
dbms_lob.close(v_pre_clob);
--get a reference to the XML CLOB that needs to be updated
select report_xml
into v_clob
from report_tbl
where report_id = p_rep_id for update;
--open the target CLOB and source report xml file in /u04
dbms_lob.open(v_clob, dbms_lob.lob_readwrite);
dbms_lob.open(v_report_xml_file);
--Load the contents of the xml file in /u04 into the CLOB column
dbms_lob.loadclobfromfile(v_clob, v_xml_file,
dbms_lob.lobmaxsize,
v_destination_offset, v_source_offset,
nls_charset_id('US7ASCII'),
v_language_context, v_warning_message);
--Check for the only possible warning message.
if v_warning_message = dbms_lob.warn_inconvertible_char then
dbms_output.put_line('Warning! Some characters couldn''t be converted.');
end if;
--Close both LOBs
dbms_lob.close(v_clob);
dbms_lob.close(v_xml_file);
null;
EXCEPTION
WHEN OTHERS THEN
v_return_code := SQLCODE;
v_return_mesg := SQLERRM;
DBMS_OUTPUT.PUT_LINE('PROCEDURE update_xml_from_file');
DBMS_OUTPUT.PUT_LINE('RETURN_CODE = ' || v_return_code);
DBMS_OUTPUT.PUT_LINE('RETURN_MESG = ' || v_return_mesg);Sorry, pulled that code from development where it was working.
The issue was the GRANT on the /u04 directory. -
Loading UTF-8 String into CLOB column
Hello!
I am trying to load UTF-8 encoded strings into a CLOB column in an Oracle 9i database from VB.Net using ODP.Net (9.2.0.414).
The strings are XML snippets (Microsoft WordML to be precise). Each corresponds to a record which already exists in the database, therefore I do an update to add the UTF-8 string.
Some of the XML snippets contain characters which once inserted look like upside down question marks (characters represented by 0x92 and 0x96 for example end up as 0xBF once in the database).
Setting breakpoints in Visual Studio, I can watch the string values in the 'Locals' window and they appear correct (in fact I can copy from the 'Locals' window and using a tool such as TOAD can paste the strings into the database successfully). Pasting through TOAD, the characters are properly represented in the database (ie 0x92 is 0x92).
I've tried a number of approaches with no luck.
Any advice/suggestion are most welcome. Thanks!
Here is my code:
strConnectionString = ConfigurationSettings.AppSettings.Item("ConnectionString")
strComponentsTable = ConfigurationSettings.AppSettings.Item("ComponentsTable")
objConnection = New OracleConnection(strConnectionString)
objCommand = objConnection.CreateCommand()
objCommand.CommandType = CommandType.Text
objCommand.CommandText = "UPDATE " & strComponentsTable & " SET TEMPLATE_COMPONENT_CONTENT = :p_content WHERE TEMPLATE_COMPONENT_ID = :p_id"
objConnection.Open()
For Each strId In objComponents.Keys
strContent = objComponents.Item(strId)
objCommand.Parameters.Clear()
objParameter = objCommand.CreateParameter()
objParameter.ParameterName = "p_content"
objParameter.OracleDbType = OracleDbType.Clob
objParameter.Direction = ParameterDirection.Input
objParameter.Value = strContent
objCommand.Parameters.Add(objParameter)
objParameter = objCommand.CreateParameter()
objParameter.ParameterName = "p_id"
objParameter.OracleDbType = OracleDbType.Int32
objParameter.Direction = ParameterDirection.Input
objParameter.Value = CInt(strId)
objCommand.Parameters.Add(objParameter)
intResult = objCommand.ExecuteNonQuery()
NextSome further research has revealed the following:
Two of the characters I provided as examples of not being stored properly in the database are (in Unicode) U+2013 and U=2019. These characters, encoded as UTF-8 should each be three bytes (0xE2 80 93 and 0xE2 80 99 respectively). Sent via VB.Net and ODP.Net they both end up in the database as one byte each (0xBF). Copy and Pasted via TOAD they end up as one byte each (0x92 and 0x96 respectively).
The NLS settings on the server side are:
NLS_CHARACTERSET = WE8ISO8859P1
NLS_NCHAR_CHARACTERSET = AL16UTF16
I have tried using both CLOB and NCLOB column with the results being identical.
Not sure what else to try... -
We have some XML data loaded into CLOB columns, for reasons too long to explain here we are not using the XMLTYPE, but we do need to extract rows based on conditions of the XML data. For performance reasons we do not want to index the CLOB column. I am looking at ways of inspecting the XML and returning matching results by casting the CLOB out as XMLTYPE and opening up xpath/xquery functions - but need this to be efficient. I have initially used extract().getXXXXVal in the where clause of a select statement, ie. where x.xmltype(clob_col).extract('<xpath>').getNumberVal = nn, but have found this very inefficient with memory usage increasing consistently and CPU hitting 100%. can anyone suggest some alternative methods?
Hi
In expression operator ignore "PLS-00201: identifier 'EXTRACTVALUE' must be declared" .
In Mapping Level Configure Default Operating Mode : Setbased and
Generation Mode : Setbased
and deploy and execute your mapping. -
Loading data into a CLOB column
I need to find out how to load about ten sentences of data into a clob column for a table in the database. I have a pl/sql procedure that loads data from an xml file into various tables in the the database. Recently, we added a column (test_dummy) to one of the tables and defined it as a CLOB. There is a corresponding node (detail_info) in the XML file that maps to this column. I need to figure out how to incorporate this in the pl/sql procedure so that the data in the XML file for the node (detail_info) is loaded into "test_dummy". Any ideas?
Take it one at a time. Use 'extract' function to extract an XML snippet from a given XML. The question couldn't be more vague. Maybe an example would help?
Rahul -
How to retreive soap xml data from clob column in a table
Hi,
I am trying to retrieve the XML tag value from clob column.
Table name = xyz and column= abc (clob datatype)
data stored in abc column is as below
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:head="http://www.abc.com/gcgi/shared/system/header" xmlns:v6="http://www.abc.com/gcgi/services/v6_0_0_0" xmlns:sys="http://www.abc.com/gcgi/shared/system/systemtypes">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<RqHeader soapenv:mustUnderstand="0" xmlns="http://www.abc.com/gcgi/shared/system/header">
<DateAndTimeStamp>2011-12-20T16:02:36.677+08:00</DateAndTimeStamp>
<UUID>1000002932</UUID>
<Version>6_0_0_0</Version>
<ClientDetails>
<Org>ABC</Org>
<OrgUnit>ABC</OrgUnit>
<ChannelID>HBK</ChannelID>
<TerminalID>0000</TerminalID>
<SrcCountryCode>SG</SrcCountryCode>
<DestCountryCode>SG</DestCountryCode>
<UserGroup>HBK</UserGroup>
</ClientDetails>
</RqHeader>
<wsa:Action>/SvcImpl/bank/
SOAPEndpoint/AlertsService.serviceagent/OpEndpointHTTP/AlertDeleteInq</wsa:Action></soapenv:Header>
<soapenv:Body>
<v6:AlertDeleteInqRq>
<v6:Base>
<v6:VID>20071209013112</v6:VID>
<!--Optional:-->
<v6:Ref>CTAA00000002644</v6:Ref>
</v6:Base>
</v6:AlertDeleteInqRq>
</soapenv:Body>
</soapenv:Envelope>
And i want to retrieve the values of tag
<ChannelID> and <v6:VID>
can somebody help, i have tried with extractvalue but not able to get the valuesI have used the below two queries but not able to get the expected results. Both queries result into no values.
select xmltype(MED_REQ_PAYLOAD).extract('//ClientDetails/Org','xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" || xmlns="http://www.abc.com/gcgi/shared/system/header"').getStringValue() from ESB_OUTPUT_TEMP where SOAPACTION = '/SvcImpl/bank/alerts/v6_0_0_0/SOAPEndpoint/AlertsService.serviceagent/OpEndpointHTTP/AlertDeleteInq'
select EXTRACTVALUE(xmltype(MED_REQ_PAYLOAD),'/RqHeader/) from ESB_OUTPUT_TEMP where SOAPACTION = '/SvcImpl/bank/SOAPEndpoint/AlertsService.serviceagent/OpEndpointHTTP/AlertDeleteInq'
Well, for starters, both queries are syntactically wrong :
- non terminated string
- incorrect namespace mapping declaration
- unknown XMLType method "getStringValue()"
Secondly, all those functions are deprecated now.
Here's an up-to-date example using XMLTable. It will retrieve the two tag values you mentioned :
SQL> select x.*
2 from esb_output_temp t
3 , xmltable(
4 xmlnamespaces(
5 'http://schemas.xmlsoap.org/soap/envelope/' as "soap"
6 , 'http://www.abc.com/gcgi/shared/system/header' as "head"
7 , 'http://www.abc.com/gcgi/services/v6_0_0_0' as "v6"
8 )
9 , '/soap:Envelope'
10 passing xmlparse(document t.med_req_payload)
11 columns ChannelID varchar2(10) path 'soap:Header/head:RqHeader/head:ClientDetails/head:ChannelID'
12 , VID varchar2(30) path 'soap:Body/v6:AlertDeleteInqRq/v6:Base/v6:VID'
13 ) x
14 ;
CHANNELID VID
HBK 20071209013112
You may also want to store XML in XMLType columns for both performance and storage optimizations. -
Trying to Insert an XML Element into XML data stored in CLOB column
Hi all,
My ORACLE DB version is:
('Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production');
('PL/SQL Release 11.2.0.2.0 - Production');
('CORE 11.2.0.2.0 Production');
('TNS for Linux: Version 11.2.0.2.0 - Production');
('NLSRTL Version 11.2.0.2.0 - Production');
I have this XML data stored in a CLOB column:
<Activity>
<Changes>
</Changes>
<Inserts>
</Inserts>
<Definition>
</Definition>
<Assignment TYPE="Apply">
</Assignment>
<Spawned>
<Activity>576D8CD9-57A1-8608-1563-8F6DC74BDF3C</Activity>
<Activity>11226E79-5D24-02EB-A950-D34A9CCFB3FF</Activity>
<Activity>DAA68DC0-CA9A-BB15-DE31-9596E19513EE</Activity>
<Activity>93F667D6-966A-7EAD-9B70-630D9BEFDDD2</Activity>
<Activity>FA63D9D3-86BB-3FF0-BE69-17EAA7581637</Activity>
</Spawned>
<SpawnedBy>AFC49BD4-5AA7-38C0-AE27-F59D16EE1B1C</SpawnedBy>
</Activity>
I am in need of some assistance in creating an update that will insert another <Activity>SomeGUID</Activity> into the <Spawned> parent.
Any help is greatly appreciated.
Thanks.
Edited by: 943783 on Dec 14, 2012 12:58 PMSee XML updating functions : http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb04cre.htm#i1032611
For example :
UPDATE my_table t
SET t.my_clob =
XMLSerialize(document
insertChildXML(
XMLParse(document t.my_clob)
, '/Activity/Spawned'
, 'Activity'
, XMLElement("Activity", 'Some GUID')
WHERE ...
;Although it works, there's overhead introduced by parsing the CLOB, then serializing again.
Is there any chance you can change the CLOB to SECUREFILE binary XMLType storage instead?
You would then be able to benefit from optimized piecewise update of the XML and improved storage. -
How to insert more than 32k xml data into oracle clob column
how to insert more than 32k xml data into oracle clob column.
xml data is coming from java front end
if we cannot use clob than what are the different options availableAre you facing any issue with my code?
String lateral size error will come when you try to insert the full xml in string format.
public static boolean writeCLOBData(String tableName, String id, String columnName, String strContents) throws DataAccessException{
boolean isUpdated = true;
Connection connection = null;
try {
connection = ConnectionManager.getConnection ();
//connection.setAutoCommit ( false );
PreparedStatement PREPARE_STATEMENT = null;
String sqlQuery = "UPDATE " + tableName + " SET " + columnName + " = ? WHERE ID =" + id;
PREPARE_STATEMENT = connection.prepareStatement ( sqlQuery );
// converting string to reader stream
Reader reader = new StringReader ( strContents );
PREPARE_STATEMENT.setClob ( 1, reader );
// return false after updating the clob data to DB
isUpdated = PREPARE_STATEMENT.execute ();
PREPARE_STATEMENT.close ();
} catch ( SQLException e ) {
e.printStackTrace ();
finally{
return isUpdated;
Try this JAVA code. -
Reading Xml file from clob column in the staging table
Hi,
I am trying to poll the staging table with the database adapter which has CLOB column type containing XML file. How do I extract the XML file from CLOB and map the fields to the another variable with definite schema.
Thanks,
Edited by: chaitu123 on Sep 20, 2009 8:16 AM1) when you create DBAdapter on a table which having the clob column watch closely the created xsd for the DBAdapter the clob cloumn element should be a String data type
2) create xsd for Xml File and create variable for the xsd element
3) use ora:parseEscapedXML("yourDBAdapterclobElement") to XmlFileVarilable
Krishna -
Remove an element from XML present in CLOB column
Hi,
I need to remove element TEST2 and TEST3 from the below XML which is present in the CLOB column of a table. I need to do this using DBMS_XMLDOM package of Oracle as my existing code is using the same -
<ROOT>
<LEAF1>
<TEST1>TEXT1</TEST1>
<TEST2>TEXT2</TEST2>
<TEST3>TEXT3</TEST3>
</LEAF1>
</ROOT>
Hence the final o/p should be like
<ROOT>
<LEAF1>
<TEST1>TEXT1</TEST1>
</LEAF1>
</ROOT>
Please suggest how to achieve this.Something like this?
Anton
declare
t_doc dbms_xmldom.DOMDocument;
t_root dbms_xmldom.DOMNode;
t_node dbms_xmldom.DOMNode;
t_buf varchar2(1000);
begin
t_doc := dbms_xmldom.newDOMDocument( xmltype( '<ROOT>
<LEAF1>
<TEST1>TEXT1</TEST1>
<TEST2>TEXT2</TEST2>
<TEST3>TEXT3</TEST3>
</LEAF1>
</ROOT>' ) );
t_root := dbms_xmldom.makeNode( t_doc );
t_node := dbms_xmldom.removeChild( t_root, dbms_xslprocessor.selectSingleNode( t_root, '/ROOT/LEAF1/TEST2' ) );
t_node := dbms_xmldom.removeChild( t_root, dbms_xslprocessor.selectSingleNode( t_root, '/ROOT/LEAF1/TEST3' ) );
dbms_xmldom.writetoBuffer( t_root, t_buf );
dbms_output.put_line( t_buf );
end;
Maybe you are looking for
-
Urgent help needed in two clarifictions of applet code
Hi, I have an applet code where I have two buttons. Now, if button A is clicked it should pass a particular query string while if button B is clicked it should pass another particular query string. I would like to confirm 1) Whether the query string
-
Keyboard dictation function not working with wifi
very curious thing happening. the 'mic' icon activated dictation function is not working in wifi mode on my iphone at home. you get the dancing balls and no text ever appears. in 4g mode dictation works fine. wifi seems to be working ok. dictation
-
Is it possible to show the album artwork on a shared itunes library
I use itunes in my home and office environments. I store all the content on a server and use the shared library to play it back on my stereo in a different room - or on my laptop in the office using the library on the office 'music server'. It seems
-
Reporting Agent filename convention and result directory
Hi Experts, We are using BW 3.1 so the questions below are refering to this version of BW. I have to run a query on a monthly basis which has many results depending on a cost center input. The problem is that I need to make a standard filename conven
-
Software Installation CD, won't recognize hard drive not labeled C:\
My hard drive is labeled I:\. The installation cd does not recognized this and will not install the software. How can I get the installation program to recognize the hard drive? Post relates to: Palm TX This question was solved. View Solution.