Update xml to replace value
I have seen good example on how to use updateXML to update the value as the one below,
but no luck on search on how to replace from one value to another.
Does anyone have example on how to replace value using updateXML?
Thanks,
Luan
insert into XML_CLOB values ( xmltype(
'<student id="211">
<personal idPer="2561">
<firstName>John</firstName>
<middleName>Michael</middleName>
<lastName>Scott</lastName>
<birthday>15-11-1984</birthday>
<address>8600 Beverly Blvd.</address>
<city>Los Angeles, CA.</city>
<country>USA</country>
</personal>
<personal idPer="2561">
<firstName>John</firstName>
<middleName>Michael</middleName>
<lastName>Scott</lastName>
<birthday>15-11-1984</birthday>
<address>8600 Beverly Blvd.</address>
<city>Los Angeles, CA.</city>
<country>USA</country>
</personal>
<personal idPer="2221">
<firstName>John</firstName>
<middleName>Michael</middleName>
<lastName>Scott</lastName>
<birthday>15-11-1984</birthday>
<address>8600 Beverly Blvd.</address>
<city>Los Angeles, CA.</city>
<country>USA</country>
</personal>
</student>'));
prompt 'select object_value from xml_clob';
select object_value from xml_clob;
prompt 'update XML_CLOBset object_value = updateXML( object_value,/student/personal/city/text(),New York City)where existsNode(object_value,/student[@id="211"]) = 1';
update XML_CLOB
set object_value = updateXML
object_value,
'/student/personal/city/text()',
'New York City'
where existsNode(object_value,'/student[@id="211"]') = 1;
Sure, I meant to find/replace. In the real world example,
I have an order with many items, but one item has typo missing a digit.
I wanted to find that item and replace with new correct value in the xml.
Order: 1234
item: 9000292
item: 9020777
item: 9003833
Let's say my third item "9003833" is not correct and I wanted to replace with new item "9003844". Hope that clear!
here is an example that I am working with:
I would like to replace firstName = "Luan" with "The World is Great" in my example below, and I want to replace only when it finds firstName = "Luan".
drop table xml_clob
create table xml_clob of xmltype;
insert into XML_CLOB values ( xmltype(
'<student id="211">
<personal>
<idPer>2561</idPer>
<firstName>John</firstName>
<middleName>Michael</middleName>
<lastName>Scott</lastName>
<birthday>15-11-1984</birthday>
<address>8600 Beverly Blvd.</address>
<city>Los Angeles, CA.</city>
<country>USA</country>
</personal>
<personal>
<idPer>2221</idPer>
<firstName>Luan</firstName>
<middleName>M</middleName>
<lastName>Nguyen</lastName>
<birthday>06-01-1977</birthday>
<address>2100 Pine Street.</address>
<city>Los Angeles, CA.</city>
<country>USA</country>
</personal>
</student>'));
select * from xml_clob
-- This update statement does not correct. It didn't update the firstName value. I created a new "personal" tag and remove the previous "personal". I wanted to find("Luan") and replace("The World is Great").
UPDATE xml_clob
set object_value =
UPDATEXML(object_value,
'/student/personal[firstName="Luan"]/text()','The World is Great')
-- Thanks,
-- Luan
Similar Messages
-
Update xml string values.
Hi,
I'm on 11.2.0.2 and got table with nclob column which stores long xml string .
{code}
"<?xml version="1.0" encoding="UTF-8"?>
<?fuego version="6.5.2" build="101272"?>
<set>
<configuration name="TEST Database" type="SQL" subtype="DDORACLE">
<property name="jdbc.pool.idle_timeout" value="5"/>
<property name="jdbc.pool.entry.max" value="10"/>
<property name="oracle.dateEqualsTimestamp" value="false"/>
<property name="jdbc.schema" value="user1"/>
<property name="jdbc.host" value="hostname"/>
<property name="user" value="user1"/>
<property name="jdbc.port" value="1521"/>
<property name="jdbc.pool.min" value="0"/>
<property name="jdbc.pool.maxopencursors" value="50"/>
<property name="oracle.sid" value="dbsid"/>
<property name="password" value="user101"/>
<property name="jdbc.xa" value="false"/>
<property name="jdbc.pool.max" value="10"/>
</configuration>
<configuration name="TEST Database2" type="SQL" subtype="DDORACLE">
<property name="jdbc.pool.idle_timeout" value="5"/>
<property name="jdbc.pool.entry.max" value="10"/>
<property name="oracle.dateEqualsTimestamp" value="false"/>
<property name="jdbc.schema" value="user2"/>
<property name="jdbc.host" value="hostname"/>
<property name="user" value="user2"/>
<property name="jdbc.port" value="1521"/>
<property name="jdbc.pool.min" value="0"/>
<property name="jdbc.pool.maxopencursors" value="50"/>
<property name="oracle.sid" value="dbsid2"/>
<property name="password" value="user201"/>
<property name="jdbc.xa" value="false"/>
<property name="jdbc.pool.max" value="10"/>
</configuration>
</set>
{code}
My goal is to update password value in such way that it equals to value from jdbc.schema value <property name="jdbc.schema" value="user2"/> so in this case user2 || '01'
<property name="password" value="user201"/> <-- that is my goal .
Regards
GregHi,
You can find a few methods here : How To : Update XML nodes with values from the same document | Odie's Oracle Blog
They're not all applicable to your version and settings though.
Here's the first one applied to your case :
declare
v_xmldoc xmltype;
begin
select xmlparse(document to_clob(t.xmldoc))
into v_xmldoc
from my_nclob_table t
where t.id = 1;
for r in (
select idx, schema_name
from my_nclob_table t
, xmltable(
'/set/configuration'
passing v_xmldoc
columns idx for ordinality
, schema_name varchar2(30) path 'property[@name="jdbc.schema"]/@value'
loop
select updatexml(
v_xmldoc
, '/set/configuration['||to_char(r.idx)||']/property[@name="password"]/@value'
, r.schema_name || '01'
into v_xmldoc
from dual ;
end loop;
update my_nclob_table t
set t.xmldoc = to_nclob(xmlserialize(document v_xmldoc indent))
where t.id = 1;
end;
Here's another one, using DOM :
declare
doc clob;
p dbms_xmlparser.Parser;
domdoc dbms_xmldom.DOMDocument;
docnode dbms_xmldom.DOMNode;
conf_list dbms_xmldom.DOMNodeList;
conf_node dbms_xmldom.DOMNode;
password_node dbms_xmldom.DOMNode;
schema_name varchar2(30);
password_value varchar2(256);
begin
select to_clob(xmldoc)
into doc
from my_nclob_table
where id = 1 ;
p := dbms_xmlparser.newParser;
dbms_xmlparser.parseClob(p, doc);
domdoc := dbms_xmlparser.getDocument(p);
dbms_xmlparser.freeParser(p);
docnode := dbms_xmldom.makeNode(domdoc);
conf_list := dbms_xslprocessor.selectNodes(docnode, '/set/configuration');
for i in 0 .. dbms_xmldom.getLength(conf_list) - 1 loop
conf_node := dbms_xmldom.item(conf_list, i);
dbms_xslprocessor.valueOf(conf_node, 'property[@name="jdbc.schema"]/@value', schema_name);
password_node := dbms_xslprocessor.selectSingleNode(conf_node, 'property[@name="password"]/@value');
dbms_xmldom.setNodeValue(password_node, schema_name || '01');
end loop;
dbms_xmldom.writeToClob(domdoc, doc);
dbms_xmldom.freeDocument(domdoc);
update my_nclob_table t
set t.xmldoc = to_nclob(doc)
where t.id = 1;
end;
Message was edited by: odie_63 - added DOM example -
How do I update XML parameters in this situation...?
I have a table called Users that has an XML column, xmlSettings, that I store various data about the user's last session. Here is a snippet of a typical xmlSettings doc:
<Forms>
<Form name="InvoiceList">
<Grid name="dbgInvoices">
<GridLayout>
<Columns>
<Column key="field1" />
<Column key="TableName.ID"/>
<Column key="field2" />
<Column key="TableName.SomeOtherField" />
<Column key="field3" />
</Columns>
</GridLayout>
</Grid>
</Form>
<Form name="SomeOtherForm">...</Form>
<Forms
Now in this document, there will be settings for many forms. I need to change "TableName" to "SomeTable". I need to go through all the forms of the <Forms> node, and for the node that has name=InvoiceList, I need to go
into the <Columns> nodes and change any mention of "TableName" to "SomeTable". I only have to do this for the InvoiceList form. Also, there will be a row in this table for each user, and each row has its own xmlSettings
column that will contain settings for many forms. I need to do this for all rows in the table. I'm assuming I need to use .nodes() somehow, but I can't quite figure it out.
I can probably do this with a sproc of some sort, but I'm guessing there's a query that will do it.Saurabh
Your approach is correct but suggestion wont give the exact output what poster is looking at
The reason is since the update happens inside loop it will replace all the instances of key with your first replace value itself and will exit loop.
See the output for your illustration
<Forms>
<Form name="InvoiceList">
<Grid name="dbgInvoices">
<GridLayout>
<Columns>
<Column key="field1" />
<Column key="TableName.ID" />
<Column key="field2" />
<Column key="TableName.SomeOtherField" />
<Column key="field3" />
</Columns>
</GridLayout>
</Grid>
</Form>
<Form name="SomeOtherForm">...</Form>
</Forms>
The above xml would get replaced as
<Forms>
<Form name="InvoiceList">
<Grid name="dbgInvoices">
<GridLayout>
<Columns>
<Column key="field1" />
<Column key="SomeTable.ID" />
<Column key="field2" />
<Column key="SomeTable.ID" />
<Column key="field3" />
</Columns>
</GridLayout>
</Grid>
</Form>
<Form name="SomeOtherForm">...</Form>
</Forms>
If you see part in bold you can find that it will end up replacing all occurances with first key_val value from @table1
So the solution would be to do something like below
DECLARE @UserTable TABLE
userId INT IDENTITY(1, 1) ,
sUserName NVARCHAR(150) ,
xmlSettings XML
INSERT INTO @usertable
SELECT 'saurabh' ,
'<Forms>
<Form name="InvoiceList">
<Grid name="dbgInvoices">
<GridLayout>
<Columns>
<Column key="field1" />
<Column key="TableName.ID"/>
<Column key="field2" />
<Column key="TableName.SomeOtherField" />
<Column key="field3" />
<Column key="TableName.SomeOtherField2" />
<Column key="field3" />
</Columns>
</GridLayout>
</Grid>
</Form>
<Form name="SomeOtherForm">...</Form>
</Forms>'
UNION ALL
SELECT 'test' ,
'<Forms>
<Form name="InvoiceList">
<Grid name="dbgInvoices">
<GridLayout>
<Columns>
<Column key="field1" />
<Column key="TableName.ID"/>
<Column key="field2" />
<Column key="TableName.SomeOtherField" />
<Column key="field3" />
<Column key="TableName.SomeOtherField3" />
<Column key="field3" />
</Columns>
</GridLayout>
</Grid>
</Form>
<Form name="SomeOtherForm">...</Form>
</Forms>'
SELECT *
FROM @usertable
WHILE EXISTS ( SELECT 1
FROM @UserTable
WHERE xmlSettings.exist('//Grid[@name="dbgInvoices"]/GridLayout/Columns/Column[ contains(@key , "TableName")]') = 1 )
BEGIN
UPDATE m
SET xmlSettings.modify('replace value of (//Grid[@name="dbgInvoices"]/GridLayout/Columns/Column[ contains(@key , "TableName")]/@key)[1] with sql:column("replaceval") ')
FROM
(SELECT xmlSettings,REPLACE(t.u.value('./@key[1]','varchar(100)'),'TableName.','SomeOthertable.') AS replaceval
FROM @UserTable p
CROSS APPLY p.xmlSettings.nodes('/Forms/Form/Grid[@name="dbgInvoices"]/GridLayout/Columns/Column[ contains(@key , "TableName")]')t(u)
)m
END
SELECT *
FROM @usertable
Now check the output and you will see it will do replacement correctly
<Forms>
<Form name="InvoiceList">
<Grid name="dbgInvoices">
<GridLayout>
<Columns>
<Column key="field1" />
<Column key="SomeOthertable.ID" />
<Column key="field2" />
<Column key="SomeOthertable.SomeOtherField" />
<Column key="field3" />
<Column key="SomeOthertable.SomeOtherField2" />
<Column key="field3" />
</Columns>
</GridLayout>
</Grid>
</Form>
<Form name="SomeOtherForm">...</Form>
</Forms>
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
Update XML data stored in CLOB Column
Hi All,
i am new to Oracle and new to SQL
i am trying to update XML data stored in CLOB cloumn,data is stored with the follwoing format
<attrs><attr name="name"><string>Schade</string></attr></attrs>
i am using the following query for updating the value
UPDATE PRODUCT p SET ATTRIBUTES_nl_nl=UPDATEXML(XMLTYPE.createXML(ATTRIBUTES_nl_nl),'/attrs/attr[@name="name"]/string/text()','Schade').getClobVal() WHERE p.sku='000000000000040576_200911-5010057'
this query is working fine but it changing the data to the following format
<attrs><attr name="name">Schade</attr></attrs>
some how it is ommiting the <string> tag from it, i am unable to figure it out whats the reason.
any help in this regard will b e much appriciated
Thanks in Advance
-UmeshHi,
You should have created your own thread for this, and included database version.
This works for me on 11.2.0.2 and 10.2.0.5 :
SQL> create table t_org ( xml_clob clob );
Table created
SQL>
SQL> insert into t_org
2 values(
3 '<Message>
4 <Entity>
5 <ASSIGNMENT>
6 <OAVendorLocation> </OAVendorLocation>
7 <Vendorid>1</Vendorid>
8 </ASSIGNMENT>
9 </Entity>
10 </Message>'
11 );
1 row inserted
SQL> commit;
Commit complete
SQL> select '*' ||
2 extractvalue(xmltype(xml_clob),'/Message/Entity/ASSIGNMENT/OAVendorLocation')
3 || '*' as result
4 from t_org;
RESULT
SQL> update t_org set xml_clob =
2 updatexml(xmltype(xml_clob),
3 '/Message/Entity/ASSIGNMENT/OAVendorLocation/text()','LONDON').getClobVal()
4 ;
1 row updated
SQL> select '*' ||
2 extractvalue(xmltype(xml_clob),'/Message/Entity/ASSIGNMENT/OAVendorLocation')
3 || '*' as result
4 from t_org;
RESULT
*LONDON*
Does the OAVendorLocation really have a whitespace value?
If not then it's expected behaviour, you're trying to update a text() node that doesn't exist. In this case, the solution is to use appendChildXML to create the text() node, or update the whole element.
Is it your real document? Do you actually have some namespaces? -
Error While trying to Get XML element(tag) Values
We are trying to get XML element (TAG) value from the XML pay load.
Example.
Getting XML String from a web service and then converting into XML payload.
ora:parseEscapedXML(bpws:getVariableData('signOn_Out','signOnReturn'))
From this XML payload we are trying to get an element (Tag) value.
We are getting following error
Error in evaluate <from> expression at line "130". The result is empty for the XPath expression : "/client:TririgaProcessResponse/client:User/client:LastName".
oracle.xml.parser.v2.XMLElement@118dc2a
{http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure" has been thrown.
- <selectionFailure xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
- <part name="summary">
<summary>
empty variable/expression result.
xpath variable/expression expression "/client:TririgaProcessResponse/client:User/client:LastName" is empty at line 130, when attempting reading/copying it.
Please make sure the variable/expression result "/client:TririgaProcessResponse/client:User/client:LastName" is not empty.
</summary>
</part>
</selectionFailure>
Here are signOnReturn and XML Payload XSD's
<schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://xmlns.oracle.com/Web1"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="Web1ProcessRequest">
<complexType>
<sequence>
<element name="userName" type="string"/>
<element name="password" type="string"/>
</sequence>
</complexType>
</element>
<element name="Web1ProcessResponse">
<complexType>
<sequence>
<element name="result" type="string"/>
</sequence>
</complexType>
</element>
</schema>
<?xml version="1.0" encoding="windows-1252" ?>
<schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://xmlns.oracle.com/Web"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="TProcessResponse">
<complexType>
<sequence>
<element name="result" type="string"/>
<element name="User">
<complexType>
<sequence>
<element name="Id" type="string"/>
<element name="CompanyId" type="string"/>
<element name="SecurityToken" type="string"/>
<element name="FirstName" type="string"/>
<element name="LastName" type="string"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</schema>I am sure and can see the data in audit trail.
[2006/12/12 09:17:36]
Updated variable "signOn_Output"
- <signOn_Output>
- <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="payload">
- <WebMethodsProcessResponse xmlns="http://xmlns.oracle.com/WebMethods">
<Result xmlns="">
Success
</Result>
- <User xmlns="">
<Id>
2694069
</Id>
<CompanyId>
208133
</CompanyId>
<SecurityToken>
1165936654605
</SecurityToken>
<FirstName>
Jagan
</FirstName>
<LastName>
Rao
</LastName>
</User>
</WebMethodsProcessResponse>
</part>
</signOn_Output>
Copy details to clipboard
[2006/12/12 09:17:36]
Updated variable "tririga"
- <tririga>
- <TririgaProcessResponse xmlns="http://xmlns.oracle.com/WebMethods">
<Result xmlns="">
Success
</Result>
- <User xmlns="">
<Id>
2694069
</Id>
<CompanyId>
208133
</CompanyId>
<SecurityToken>
1165936654605
</SecurityToken>
<FirstName>
Jagan
</FirstName>
<LastName>
Rao
</LastName>
</User>
</TririgaProcessResponse>
</tririga>
Copy details to clipboard
[2006/12/12 09:17:36]
Updated variable "Variable_2"
- <Variable_2>
- <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="payload">
- <TririgaProcessResponse xmlns="http://xmlns.oracle.com/WebMethods">
<Result xmlns="">
Success
</Result>
- <User xmlns="">
<Id>
2694069
</Id>
<CompanyId>
208133
</CompanyId>
<SecurityToken>
1165936654605
</SecurityToken>
<FirstName>
Jagan
</FirstName>
<LastName>
Rao
</LastName>
</User>
</TririgaProcessResponse>
</part>
</Variable_2>
Copy details to clipboard
[2006/12/12 09:17:36]
Error in evaluate <from> expression at line "130". The result is empty for the XPath expression : "/client:TririgaProcessResponse/client:User/client:LastName".
oracle.xml.parser.v2.XMLElement@1c8768e
Copy details to clipboard
[2006/12/12 09:17:36]
"{http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure" has been thrown.
- <selectionFailure xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
- <part name="summary">
<summary>
empty variable/expression result.
xpath variable/expression expression "/client:TririgaProcessResponse/client:User/client:LastName" is empty at line 130, when attempting reading/copying it.
Please make sure the variable/expression result "/client:TririgaProcessResponse/client:User/client:LastName" is not empty.
</summary>
</part>
</selectionFailure>
Copy details to clipboard -
To replace values of one of the field in the database table
How to replace values of one of the field in the database table with a new values? Pls help to solve
Hi
You can use the UPDATE command to update one of the field value in a table
see the UPDATE syntax and use it
but in real time you should not do like this
Regards
Anji -
HOw to update XML file residing in DAM by component JSP in run-time?
i have made a component which reads xml file residing in DAM.
Content Author can fill some values in dialog of this component, as soon as author provide the values,i have to update these values in XML file and component reloadsby reading the updated xml file.
i am trying to achieve this by making object of XML file and giving it's path., but i ma unable to access the XML file.
Can anyone help me out to how to update XML file by component JSP in run-time?Now the changed data must be exported back into the XML file, meaning that the content of certain elements must be updated. How can this be done with XSLT?
XSLT approach: check these online tutorial
http://www.xml.com/pub/a/2000/08/02/xslt/index.html
http://www.xml.com/pub/a/2000/06/07/transforming/index.html
ABAP approach:
for example you have the xml (original) in a string called say xml_out .
data: l_xml type ref to cl_xml_document ,
node type ref to if_ixml_node .
create object l_xml.
call method l_xml->parse_string
exporting
stream = xml_out.
node = l_xml->find_node(
name = 'IDENTITY'
ROOT = ROOT
l_xml->set_attribute(
name = 'Name'
value = 'Charles'
node = node
(the above example reads the element IDENTITY and sets attribute name/value to the same)
like wise you can add new elements starting from IDENTITY using various methods available in class CL_XML_DOCUMENT
so how do I access the XML file in order to update it?
you have already read this XML into a ABAP variable right?
Sorry couldnt understand your whole process, why do you need to read local XML file?
Raja -
Failure doing very simple "replace value of node ..." on an attribute
Hello
(Working on DBXML 2.5.13. on Windows Server 2003)
With the following document in a container:
<village xmlns="carrapateira.info">
<pictures quantity="124"/>
</village>
When trying to replace the value of the attribute 'quantity' with the dbxml shell, using the following commands:
dbxml> setn "" "carrapateira.info"
Binding -> carrapateira.info
dbxml> cquery /village/pictures
1 objects returned for eager expression '/village/pictures'
dbxml> print
<pictures xmlns="carrapateira.info" quantity="124"/>
dbxml> contextQ @quantity
1 objects returned for expression '@quantity'
dbxml> print
{}quantity="124"
dbxml> contextQ "replace value of node . with 222"
stdin:7: contextQuery failed
I always get that last message, whatever I try.
What is fundamentally wrong in my approach? Or is this a shell problem?
Thank you
KoenGeorge
I have run some tests, of which a Java program. The problem persisted.
I re-created the container completely and it now works. I have no clue why I had that problem and what solved it.
I will keep you informed if this error repeats.
I have another problem with XQuery Update which I will post in another thread later.
Thank you very much,
Koen -
Revision: 3127
Author: [email protected]
Date: 2008-09-05 14:16:53 -0700 (Fri, 05 Sep 2008)
Log Message:
Updating asdoc to replace the avmplus call with new set of java files.
Removing all files related to asdochelper.
QA: Yes, also please test on non windows platform.
Doc:
Tests: checkintests, asdoc
Reviewed by: Pete Farland
Modified Paths:
flex/sdk/trunk/asdoc/templates/ASDoc_Config_Base.xml
flex/sdk/trunk/asdoc/templates/asdoc-util.xslt
flex/sdk/trunk/modules/compiler/build.xml
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/AsDocAPI.java
Added Paths:
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/AsClass.java
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/AsDocHelper.java
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/AsDocUtil.java
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/QualifiedNameInfo.java
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/SortComparator.java
flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/TopLevelClassesGenerator.ja va
Removed Paths:
flex/sdk/trunk/asdoc/templates/asDocHelper
flex/sdk/trunk/asdoc/templates/asDocHelper.linux
flex/sdk/trunk/modules/compiler/asdoc/I had a generic record class that has a HashMap to hold the data fields (...)
method called createRecord() for each record type which would populate the HashMap with the correct data fieldsI'm not sure I understand: are the contents of this field map the same between two records of the same type? Then yes, you don't need to clone the map per record instance.
one thing that needs fixing is the fact that each time the createRecord() method is called I'm creating a new fieldMap to define the dataFields in the record class.Probably, but that will only get you a little bigger files; you won't gain an order of magnitude on the size of files. The problem for huge files is that as soon as their content is bigger than the available memory, you'll run into problems. A more radical approach if you need to address huge files is to process the records on the fly, and not load all records in memory. Of course not all algorithms or business logic can afford that...
I know I could rewrite the code and create a class for each record type and declare the fieldMap static but I was wondering if anyone had any better suggestions The Record instance could receive and keep a reference to its RecordType instance, and ask the RecordType instance the DataType for a field's name. That way the RecordType encapsulates the map, and there's less risk that a clumsy other class modifies the static map.
before I go rewriting a load of code.A load of code?!? Even with the idea of the static map, you only have to edit the enum type (well more accurately, each RecordType enumerated constant's createRecord() method). -
JCA adapter doesnt update MarkReadColumn with correct value
Hi,
I've created a JCA adapter in the SOA suite which polls a certain database. The poll works perfect only during configuration I set it to do a logical delete. My JCA looks like:
<adapter-config name="SchoolFitListener" adapter="Database Adapter" wsdlLocation="../WSDL/SchoolFitListener.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
<connection-factory location="eis/DB/SchoolFit" UIConnectionName="SchoolFit" adapterRef=""/>
<endpoint-activation portType="SchoolFitListener_ptt" operation="receive">
<activation-spec className="oracle.tip.adapter.db.DBActivationSpec">
<property name="DescriptorName" value="SchoolFitListener.PollSchoolfitPolltable"/>
<property name="QueryName" value="SchoolFitListenerSelect"/>
<property name="MappingsMetaDataURL" value="SchoolFitListener-or-mappings.xml"/>
<property name="PollingStrategy" value="LogicalDeletePollingStrategy"/>
<property name="MarkReadColumn" value="MESSAGE_READ"/>
<property name="MarkReadValue" value="READ"/>
<property name="MarkUnreadValue" value="UNREAD"/>
<property name="PollingInterval" value="60"/>
<property name="MaxRaiseSize" value="1"/>
<property name="MaxTransactionSize" value="10"/>
<property name="NumberOfThreads" value="1"/>
<property name="ReturnSingleResultSet" value="false"/>
</activation-spec>
</endpoint-activation>
</adapter-config>When I look in the log, it does the update only with the wrong value:
UPDATE POLL_SCHOOLFIT_POLLTABLE SET MESSAGE_READ = ? WHERE (((((((((((((MESSAGE_TYPE = ?) AND (MESSAGE_READ = ?)) AND (EMPLID = ?)) AND (SF_ID = ?)) AND (VOORNAAM = ?)) AND (ACHTERNAAM = ?)) AND (VOLLEDIGE_NAAM = ?)) AND (STRAAT = ?)) AND (HUISNR = ?)) AND (POSTCODE = ?)) AND (WOONPLAATS = ?)) AND (GEBOORTEDATUM = ?)) AND (BSN = ?))
[2011-06-15T15:34:17.067+02:00] [osb_server1] [TRACE] [] [] [tid: [ACTIVE].ExecuteThread: '7' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: weblogic] [ecid: 0000J2JW9fx7y0G_yx0FyW1Dvr150008l6,0] [SRC_CLASS: org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism] [APP: JCA Transport Provider] [dcid: ae78371b7bf314eb:253fe233:1306f4ea111:-8000-00000000000149e2] [SRC_METHOD: executeBatchedStatements] bind => [UNREAD, C, UNREAD, SF9905731, 131983, John, Doe, John Doe, DowningStreet, 79, 57112, NY, 15-3-1994, 1234567890]Can anyone tell me why it does an update with the wrong value?
Much thanks!Found it. Marked too many fields as PK's during wizard so it couldn't find the right row for the update.
-
How to update xml nodes?
Hi friends,
i have a xml with 100 contacts , every contact has child nodes.....i want to update a perticular contact based on the id , how to update or a replace a new contact with matched contact based on contact id ,please help me out......
thanks
-BaluHi
The 'keyword transform' step uses the template XML file to generate the actual XML file you want to post... the template would be a plain text file uploaded to the repository, and would look like so:
<?xml version="1.0" ?>
CALL LOG
Support Call log
1
%%calldatetime%% - %%clinumber%%
Now - if you had that bit of XML, with correct time/number in it - have you verified know that you can definately just post that XML to a certain URL to get it on the server? Check with whoever manages that server exactly what you need to do to get it to appear - then worry about how you do that from UCCX. It may not be a matter of posting up that XML, you may need it in a different format or something..
Aaron -
Updating xml ( again...)
I know that there are zillions post about this but I got a bit confused...
My problem is, I need to change a node value and write back to the xml file.
I used this code to save the changes back in the file:
TransformerFactory xformFactory = TransformerFactory.newInstance();
Transformer transformer = xformFactory.newTransformer();
Source input = new DOMSource(doc.getDocumentElement());
Result output = new StreamResult(new FileOutputStream("myfile.xml"));transformer.transform(input, output);and all worked well but it seems that all the xml were re-written!
There's a way to update only the node value without rewritting the whole file?
ThanksYou do have to erase the old file and create a new file, if that was your question. It is a text file, after all.
-
Migrating V9 to V10: Update XML Fragment CLOB does not work anymore
I have an XML Schema that contains an element, named Operazione, mapped to a CLOB.
I just migrate to Oracle 10.1.0.2.0 from version 9.2.0.2.0 and the code I developed does not work anymore.
To get a CLOB on v 9.2.0.2.0 I issued the following statement:
select extractValue(value(p),'/operazione.log/Operazione') from XMT_OPERAZIONE_LOG p
where existsNode(value(p),'/operazione.log/Journal[NumeroElettronico=1234567890]') = 1
To make it working on V10 I have to change it as follow:
select extract(value(p),'/operazione.log/Operazione').getClobVal() from XMT_OPERAZIONE_LOG p
where existsNode(value(p),'/operazione.log/Journal[NumeroElettronico=1234567890]') = 1
So using extract intead of extractValue and adding getClobVal() I was able to read the CLOB.
The problem that I was not able to solve is related to CLOB update. In V9 just adding the âfor updateâ clause I was able to change the CLOB value on DB.
In V10 if I run the V9 statement I get the error:
ORA-03113: end-of-file on communication channel
If I use the statement modified for V10, adding the âfor updateâ clause, I get the CLOB and I can change the CLOB value but nothing goes on the DB. Probably I am working on a copy of the DB CLOB.
If I remove the getClobVal() I get an OPAQUE type that I can use on a XMLType but, still, nothing is stored on DB.
Any suggestion ?
I tried with both OCI and Thin ClientCan anybody help me ?
Is it better to use different strategies ( eg. Stored Procedure, DBMS_XMLSTORE etc, etc. ) ?
Any experience updatating XML Fragment CLOB on Oracle V10 ? -
Form or form on report to update XML tagS stored in CLOB field.
I would like to create a form or a form on a report
where i can update xml tags. The xml data is stored in a CLOB field.
sample CLOB DATA
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE preferences SYSTEM 'http://java.sun.com/dtd/preferences.dtd'>
<preferences EXTERNAL_XML_VERSION="1.0">
<root type="user">
<map />
<node name="com">
<map />
<node name="mynode">
<map />
<node name="utils">
<map />
<node name="properties">
<map>
<entry key="Save" value="ON" />
<entry key="TM_PORT" value="55555" />
<entry key="TM_PORT2" value="7777" />
<entry key="SubID" value="all" />
<entry key="UserDBUsr" value="myuser" />
<entry key="JMS_JDBC" value="OFF" />
<entry key="Side" value="BUY" />
<entry key="HEALTH_MONITOR_CRITICAL_DISK_SPACE" value="500" />
<entry key="HEALTH_MONITOR_WARNING_DISK_SPACE" value="750" />
<entry key="HEALTH_MONITOR_PERIOD" value="600000" />
</map>
</node>
</node>
</node>
</node>
</root>
</preferences>
the goal is to have a form where i can view and update the "value" of following:
TM_PORT
TM_PORT2
SubID
UserDBUsr
JMS_JDBC
Side
HEALTH_MONITOR_CRITICAL_DISK_SPACE
HEALTH_MONITOR_WARNING_DISK_SPACE
HEALTH_MONITOR_PERIOD
I have searched around this forum but could not find an example.
it would be cool if I could also load the an xml file into the clob.
Thank you.Hi,
I think you just study first the topics about XML DB to understand how to manupulate xml data in the database.
See:
http://www.oracle.com/technology/tech/xml/xmldb/index.html
and
XML DB
Regards,
Cafer -
Urgent Issue: Error Mapping Existing Forms to manually updated XML
Hi All,
We are working on pretty complex InfoPath form which contains 150+ fields. Based on new requirements, we added few sections containing
repeating tables with default data of multiple rows (using default values feature). To make sure that existing forms get these repeating table values correctly we wrote a PowerShell script to update the existing forms (xml files) directly.
This is done so that when an existing form is opened data should get properly mapped. But unfortunately only few repeating tables are showing the correct data and other repeating tables are showing only first record multiple times. This is working for new
forms exactly the way we expect.
We tried to download the xml file and updating the changed xml section from new form xml but it still does not work and shows the same issue. But when we open the existing
form, save it, download it and then change the xml with xml from new form, it works. Somehow when we open existing forms, the mapping is not correct.
Please guide me on this issue. Appreciate your help.
Please let me know if I need to provide more details.
Thanks,
Rahul Babar
ASP.NET, C# 4.0, Sharepoint 2007/2010, Infopath 2007/2010 Developer http://sharepoint247.wordpress.com/Dear Rahul,
The problem is very well clear, but in order to suggest in your solution I recommend to post the code you used in PowerShell to update xml, any XSLT customization, custom code related to the repeating table you have implemented etc.
If you find this information as helpful please mark this as ANSWER or HELPFUL. Thanks
Maybe you are looking for
-
To refresh the contents in JTextArea on selection of a row in JTable.
This is the block of code that i have tried : import java.awt.GridBagConstraints; import java.awt.SystemColor; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JButton; import
-
Getting a program Dump Error in Herarchial ALV
Hello All, I am getting a dump error when I am executing the below program. Kindly help as I am not getting the output. However all the subroutines are getting properly populated with data. Getting a dump error while calling the function : REUSE_ALV_
-
Hide Cost Center & GL Account in Movement Types 551-556
All, Requirement - Movement Types 551-556 should not allow the user to see or enter the Cost Center or G/L Account. How can I remove the user from having to enter and see the cost center and G/L account fields from movement types 551-556? I see I can
-
I was given an iPhone 3G, reset it, and now have picture which I believe indicates I should connect to my computer and iTunes. Have done so, clicked download which was done, but nothing changes on the phone. I know I can only upgrade to ios 4.2 but
-
Get the pc name with domain name and add it to my properties file using commands
i want to get the pc name with domain name and add it to my properties file using powershell . sid