Update xml column by inserting any missing child nodes from a M_V
Hello all,
I am trying to update a xml column(col1) of a table (abc) by looping through, by selecting from a materialized view and find any missing (child) nodes in the existing table (abc) of a xml column (col1) on each rows, and then do update the xml column (col1) of table (abc). How to do this in Oracle pl/sql?.
Thanks & Regards,
Josh
You do not need stored procedure for that. Use something like APPENDCHILDXML, INSERTCHILDXML or INSERTXMLBEFORE. For example, to insert a node into XML document:
SELECT APPENDCHILDXML(
XMLTYPE(
CURSOR(
SELECT ENAME,
SAL
FROM EMP
WHERE DEPTNO = 10
'//ROW',
XMLTYPE('<ROW><ENAME>user631757</ENAME><SAL>10000</SAL></ROW>')
) EMP_XML
FROM DUAL
EMP_XML
<?xml version="1.0"?><ROWSET><ROW><ENAME>CLARK</ENAME><SAL>2450</SAL><ROW><ENAME
user631757</ENAME><SAL>10000</SAL></ROW></ROW><ROW><ENAME>KING</ENAME><SAL>5000</SAL><ROW><ENAME>user631757</ENAME><SAL>10000</SAL></ROW></ROW><ROW><ENAME>MILL
ER</ENAME><SAL>1300</SAL><ROW><ENAME>user631757</ENAME><SAL>10000</SAL></ROW></R
OW></ROWSET>
SELECT INSERTXMLBEFORE(
XMLTYPE(
CURSOR(
SELECT ENAME,
SAL
FROM EMP
WHERE DEPTNO = 10
'//ROW[ENAME="KING"]',
XMLTYPE('<ROW><ENAME>user631757</ENAME><SAL>10000</SAL></ROW>')
) EMP_XML
FROM DUAL
EMP_XML
<?xml version="1.0"?><ROWSET><ROW><ENAME>CLARK</ENAME><SAL>2450</SAL></ROW><ROW>
<ENAME>user631757</ENAME><SAL>10000</SAL></ROW><ROW><ENAME>KING</ENAME><SAL>5000
</SAL></ROW><ROW><ENAME>MILLER</ENAME><SAL>1300</SAL></ROW></ROWSET>
SQL> SY.
Similar Messages
-
I did the update to 3.6.11 - After it started Firefox it would go to the requested site in the addressbar, but the page would be blank. I went to check for updates and it told me there was a problem in updating. It gave me this error message: Update XML file malformed (200)
I uninstalled and reinstalled and the same problem exists.
Any advice?For the error message see [[AUS Update XML File Malformed 200]].
As it appears not to be able to load any sites, a possible cause is your firewall blocking the new version of Firefox. For more details see [[Firefox cannot load websites but other programs can]]. -
A row is being inerted by GUI with a column as NULL. DB need to update this column.
Trigger will create a mutating Error.
Can you please help me how to update the column.
(Using Oracle 10g)>
UPDATE test
SET column6 = '100'
WHERE column1 = :new.column1;
END trig_test;
As updating the same table, getting Mutating Error.
>
Yes - you can't update the same table and you don't want to use the AFTER trigger.
Jeneesh's uses a BEFORE INSERT .. FOR EACH ROW trigger and sets the new value. So use his code to
create or replace trigger test_trig before insert
on test for each row
begin
if :new.column6 is null then
:new.column6 := '100';
end if;
end;And why are you storing what appears to be a number in a VARCHAR2 datatype? Store numbers in numeric columns. -
I am attempting to insert text nodes into an existing document (fragment as follows):
<sender>
<concat>
<freetext supplied_at_runtime="no">The sender of this letter is:</freetext>
<db_column colname="off_title"/>
<db_column colname="off_initials"/>
<db_column colname="off_surname"/>
</concat>
<freetext supplied_at_runtime="no">Who works at:</freetext>
<db_column colname="off_h_name"/>
<concat>
<db_column colname="off_h_num"/>
<db_column colname="off_street"/>
</concat>
<freetext supplied_at_runtime="no">rest of address</freetext>
</sender>
The problem is that when I run the following fragment of code:
Node sender_node = document.getElementsByTagName("sender").item(0);
NodeList child_nodes = sender_node.getChildNodes();
for (int i = 0; i < child_nodes.getLength(); i++){
out.println("NODE NAME: " + child_nodes.item(i).getNodeName());
if(child_nodes.item(i).getNodeName().equals("db_column")){
out.println("Found db column: " + i);
I get the following results:
NODE NAME: #text
NODE NAME: concat
NODE NAME: #text
NODE NAME: freetext
NODE NAME: #text
NODE NAME: db_column
Found db column: 5
NODE NAME: #text
NODE NAME: concat
NODE NAME: #text
NODE NAME: freetext
NODE NAME: #text
Somehow there are a number of child nodes that I am expecting to come out that aren't. It looks as if the nodes are being 'lost' somehow. Could someone explain to me what is happening, please?Well, everything seems to be quite correct... Let's see your xml with indent. I'll mark the nodes you've recieved with ********
<sender>
<concat> ********
<freetext supplied_at_runtime="no">The sender of this letter is:</freetext>
<db_column colname="off_title"/>
<db_column colname="off_initials"/>
<db_column colname="off_surname"/>
</concat>
<freetext supplied_at_runtime="no">Who works at:</freetext> ********
<db_column colname="off_h_name"/> ********
<concat> ********
<db_column colname="off_h_num"/>
<db_column colname="off_street"/>
</concat>
<freetext supplied_at_runtime="no">rest of address</freetext> ********
</sender>
So we've got five entity nodes as children of the root node. Seems to be correct... -
Read Xml Child node from XML Blob
Hi Gurus,
Greetings
I am working in oracle 10g /Solaris platform.
I have table with columns namely id varcha2,pmt blob.
PMT stores xml file.
<Products xmlns:source="http://apache.org/cocoon/source/1.0" DocStatus="approved" DocTimeStamp="2013-04-18T06:52:14" DocType="PMT" DocVersion="xUCDM_product_external_1_3.xsd">
<Product Country="DE" IsAccessory="false" IsLocalized="true" IsMaster="false" Locale="de_DE" lastModified="2013-04-18T00:08:11" masterLastModified="2013-02-25T14:46:40">
<Assets>
<Asset code="46PFL8008S_12" description="User manual" extension="pdf" extent="3359201" lastModified="2013-04-18" locale="de_DE" number="001" type="DFU">http://download.p4c.abc.com/files/4/46pfl8008s_12/46pfl8008s_12_dfu_deu.pdf</Asset>
<Asset code="46PFL8008S_12" description="Leaflet" extension="pdf" extent="970750" lastModified="2013-04-18" locale="de_DE" number="001" type="PSS">http://download.p4c.abc.com/files/4/46pfl8008s_12/46pfl8008s_12_pss_deu.pdf</Asset>
<Asset code="46PFL8008S_12" description="Quick start guide" extension="pdf" extent="911832" lastModified="2013-04-18" locale="de_DE" number="001" type="QSG">http://download.p4c.abc.com/files/4/46pfl8008s_12/46pfl8008s_12_qsg_deu.zip</Asset>
<Asset code="46PFL8008S_12" description="Front product photograph - highres 2196x1795" extension="jpg" extent="1989253" lastModified="2013-04-18" locale="global" number="001" type="_FP">http://images.abc.com/is/image/abcConsumer/46PFL8008S_12-_FP-global-001</Asset>
<Asset code="46PFL8008S_12" description="Alternative product photograph 1 - highres 2196x1795" extension="jpg" extent="603474" lastModified="2013-04-18" locale="global" number="001" type="A1P">http://images.abc.com/is/image/abcConsumer/46PFL8008S_12-A1P-global-001</Asset>
<Asset code="46PFL8008S_12" description="Alternative product photograph 2 - highres 2196x1795" extension="jpg" extent="407701" lastModified="2013-04-18" locale="global" number="001" type="A2P">http://images.abc.com/is/image/abcConsumer/46PFL8008S_12-A2P-global-001</Asset>
<Asset code="46PFL8008S_12" description="Alternative product photograph 3 - highres 2196x1795" extension="jpg" extent="174261" lastModified="2013-04-18" locale="global" number="001" type="A3P">http://images.abc.com/is/image/abcConsumer/46PFL8008S_12-A3P-global-001</Asset>
<Asset code="46PFL8008S_12" description="Alternative product photograph 4 - highres 2196x1795" extension="jpg" extent="109712" lastModified="2013-04-18" locale="global" number="001" type="A4P">http://images.abc.com/is/image/abcConsumer/46PFL8008S_12-A4P-global-001</Asset>
</Assets>
</Product>
</Products>');
I want the extract the ids from the table where pmt contains the child node (asset) contains .zip
for example http://download.p4c.abc.com/files/4/46pfl8008s_12/46pfl8008s_12_qsg_deu.zip
Then, I tried like this...
select r.* from
(SELECT xmltype(pmt) object_value
FROM PRODUCT_TR_PMT
XMLTABLE
'for $Product in $TEST/Products/Product/Assets/Asset
return <RESULT>
$Product
</RESULT>'
passing OBJECT_VALUE as "TEST"
columns Asset path 'Asset'
) r;
ORA-02263: need to specify the datatype for this column
Could you kindly help.
Thanks
RajBlob storage we (db folks) dont have any control its from application standard design.
If necessary, i can create function blob to clob.
Kindly help me in extracting child node which contains zip.
select r.* from
(SELECT xmltype(pmt) object_value
FROM PRODUCT_TR_PMT
XMLTABLE
'for $Product in $TEST/Products/Product/Assets/Asset
return <RESULT>
$Product
</RESULT>'
passing OBJECT_VALUE as "TEST"
columns Asset varchar2(255) path 'Asset'
) r;
ORA-06553: PLS-306: wrong number or types of arguments in call to 'XMLTYPE'Thanks
Raj -
Problem in delting child node from tree
Hello friends I have a problem in tree component
I am using Xml File with creator .
I am showing company name as a root node
then department name as a child of company name
then employee name as a child of department
Initialy its working fine ,user can add edit and delete any node
In add and edit option I have no problem but in delete I hava a problem
when I am deleting any child node and after deleting the node I am clicking on the root node of the deleted node the it gives me null pointer Ecxeption .
but user added any child node and then delete it then Application work properly .
What is the problem I can't Understand please help me
thanks
Raviraj Gangradethanks deepsix for helping me
it gives me java.lang.NullPointerException and class name is
net.sf.saxon.dom.NodeWrapper$ChildEnumeration
here is my Stack Trace
javax.faces.FacesException: #{Graphs.childNode_action}: javax.faces.el.EvaluationException: java.lang.NullPointerException
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)
at com.sun.rave.web.ui.appbase.faces.ActionListenerImpl.processAction(ActionListenerImpl.java:57)
at javax.faces.component.UICommand.broadcast(UICommand.java:312)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:307)
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:79)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:221)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
at sun.reflect.GeneratedMethodAccessor270.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)
at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.sun.rave.web.ui.util.UploadFilter.doFilter(UploadFilter.java:194)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:189)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doProcess(ProcessorTask.java:604)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:475)
at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:371)
at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:264)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:281)
at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:83)
Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException
at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:130)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
... 44 more
Caused by: java.lang.NullPointerException
at pegasusweb.Graphs.childNode_action(Graphs.java:1075)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
... 45 more
|#]
[#|2006-11-30T14:51:30.000+0530|SEVERE|sun-appserver-pe8.2|javax.enterprise.system.container.web|_ThreadID=16;|StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception
com.sun.rave.web.ui.appbase.ApplicationException: #{Graphs.childNode_action}: javax.faces.el.EvaluationException: java.lang.NullPointerException
at com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.destroy(ViewHandlerImpl.java:601)
at com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.renderView(ViewHandlerImpl.java:302)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:221)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
at sun.reflect.GeneratedMethodAccessor270.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)
at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.sun.rave.web.ui.util.UploadFilter.doFilter(UploadFilter.java:194)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:189)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doProcess(ProcessorTask.java:604)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:475)
at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:371)
at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:264)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:281)
at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:83)
Caused by: javax.faces.FacesException: #{Graphs.childNode_action}: javax.faces.el.EvaluationException: java.lang.NullPointerException
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)
at com.sun.rave.web.ui.appbase.faces.ActionListenerImpl.processAction(ActionListenerImpl.java:57)
at javax.faces.component.UICommand.broadcast(UICommand.java:312)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:307)
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:79)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:221)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
... 36 more
Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException
at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:130)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
... 44 more
Caused by: java.lang.NullPointerException
at pegasusweb.Graphs.childNode_action(Graphs.java:1075)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
... 45 more
|#] -
How can I remove child node from JTree???
Hi,
I would like to remove all the child node of my jtree. For instance I would like to remove the c, d, and e nodes. It's possible to remove all the child node or to remove by her name ("c", "d", and "e"). If yes what is the method that it permit to do.
A-----
|
b-------c
|
|--------d
|
---------e
I use the model : DefaultMutableTreeNode
ThanksThere are a couple of ways it can be done. If your tree uses DefaultTreeModel as its TreeModel, you can use removeNodeFromParent(). This will remove the node from its parent and effectively remove its children, too. All nodes removed will be garbage-collected if there are no other references to them.
If your tree model is not the default tree model, but still uses MutableTreeNode, you can use either remove() or removeFromParent() on the node itself, depending on whether you want to remove the node itself or one of its children.
On the other hand, your tree may use a model that simply "mirrors" another data structure, in which case you would have to remove the node from the other data structure and have it reflected in the model. -
How to parse XML Column and insert values into a table
Hello,
I am working on a simple project to demonstrate how to load and extract XML using SQL, I have already made a table that contains a column of XMLTYPE and loaded an XML file into it (code below)
create or replace directory XMLSRC as 'C:\XMLSRC';
drop table Inventory;
create table Inventory(Inv XMLTYPE);
INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
select * from Inventory;
I now however need to get the XML data back out of that and loaded into a new table. Troubleshooting guides I have read online seem to only be dealing with parsing an external XML document and loading it into a table, and not what I need to do which is parse a column of XML data and load that into a table. The project trivial with simple tables containing only 3 columns.
The table that needs to be loaded is as follows:
create table InventoryOut(PartNumber Number(10), QTY Number(10), WhLocation varchar2(500));
The XML document is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
<Inventory>
<PartNumber>101</PartNumber>
<QTY>12</QTY>
<WhLocation>WA</WhLocation>
</Inventory>
</dataroot>
Thank you for any help you can offer.First of all, thank you for your help!! Still stunned that you actually took the time to write out an eample using my tables/names/etc. Thank you!!
Attached is the code, there seems to be an issue with referencing the other table, Inventory.Inv, I checked and that table and the Inv column are showing up in the database so I am not sure why it is having issues locating them, take a look at the code I wrote as well as the output (*I included the real version number for you this time :)
EDIT: In your code right here:
select xt.*
3 from Inventory inve,
4 XMLTable('/dataroot/Inventory'
5 PASSING inve.Inv
I think is where I am messing it up, perhaps not understanding fully what is going on, as you write "Inventory inve" and "inve.Inv" ---- Is inve a keyword that I am just not familiar with? I think this is where the issues lies in my code.
END EDIT
EDIT2: Well that looks like it was it, changed that to how you have it and it now works!!! Could you please explain what that few lines is doing, and what the xt.* and inve are doing? Thanks again!!!
END EDIT2
drop table InventoryOut;
create table InventoryOut (PartNumber number(10), QTY number(10), WhLocation varchar2(500));
insert into InventoryOut (PartNumber, QTY, WhLocation)
select xt.*
from Inventory Inv,
XMLTable('/dataroot/Inventory'
PASSING Inventory.Inv COLUMNS
PartNumber number path 'PartNumber',
QTY number path 'QTY',
WhLocation path 'WhLocation')xt;
select * from InventoryOut;
select * from v$version;
table INVENTORYOUT dropped.
table INVENTORYOUT created.
Error starting at line 4 in command:
insert into InventoryOut (PartNumber, QTY, WhLocation)
select xt.*
from Inventory Inv,
XMLTable('/dataroot/Inventory'
PASSING Inventory.Inv COLUMNS
PartNumber number path 'PartNumber',
QTY number path 'QTY',
WhLocation path 'WhLocation')xt
Error at Command Line:8 Column:12
Error report:
SQL Error: ORA-00904: "INVENTORY"."INV": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
PARTNUMBER QTY WHLOCATION
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
If this helps here is the code and output for the creation of the Inventory table itself:
create or replace directory XMLSRC as 'C:\XMLSRC';
drop table Inventory;
create table Inventory(Inv XMLTYPE);
INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
select * from Inventory;
directory XMLSRC created.
table INVENTORY dropped.
table INVENTORY created.
1 rows inserted.
INV
<?xml version="1.0" encoding="WINDOWS-1252"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
<Inventory>
<PartNumber>101</PartNumber>
<QTY>12</QTY>
<WhLocation>WA</WhLocation>
</Inventory>
</dataroot>
Thanks again for your help so far! Hope we can get this working :)
Edited by: 926502 on Apr 11, 2012 2:47 PM
Edited by: 926502 on Apr 11, 2012 2:49 PM
Edited by: 926502 on Apr 11, 2012 2:54 PM
Edited by: 926502 on Apr 11, 2012 2:54 PM
Updated issue to solved - Edited by: 926502 on Apr 11, 2012 2:55 PM -
Get child nodes and only child nodes from a tree?
Hi all,
Relatively simple table
create table replaced_parts
old_part_number varchar(7),
replaced_part_number varchar(7),
updated_date date
insert into Replaced_parts values('AAAAA/1', 'BBBBB/1', '2012-Feb-16');
insert into Replaced_parts values('BBBBB/1', 'FFFFF/1', '2012-Feb-23');
insert into Replaced_parts values('YYYYY/3', 'ZZZZZ/3', '2012-Mar-17');
insert into Replaced_parts values('FFFFF/1', 'LLLLL/1', '2012-Mar-18');
insert into Replaced_parts values('LLLLL/1', 'HHHHH/1', '2012-Mar-19');The question is how do I issue a select using 'AAAAA/1' and get the result 'HHHHH/1'
i.e. (A... -> B, B->F, F->L, L->H)
and select using 'YYYYY/3' to get 'ZZZZZ/3' (Y... ->Z)?
It would be really nice if I could also get my original value, say, 'CCCCC/1' if there is no entry
for 'CCCCC/1' in the replaced_parts table (maybe NVL?).
I have googled and tried various combinations of CONNECT BY, PRIOR, ISLEAF... &c. but
am beating my head off a brick wall at the moment.
TIA,
Paul...>
Hi, Paul,Hi again Frank - couldn't sleep and am back at the "£$%^&* computer...
Yeah - it's a pity they weren't correct - I'll make doubly sure in future - see
my edited post (with DROP TABLE commands inter alia - I also removed
Order_Parts.User_Number since it was redundant - all that's needed is
Order_Number (normalisation) so now your SQL doesn't work - sorry
about that.
Just saying something "doesn't work" isn;t very helpful. What exactly is wrong with the SQL
statements I posted? Point out a couple of places where they are wrong, and explain how
you get the right results in those places.Nothing is wrong with your SQL - I meant *sorry* about the confusion in the DDL/DML from my end.
Now, I'm sorry again about the ambiguity of my English.
I'll reconstruct the original data that I gave you and re-run your SQL against that data - again,
this is *totally* my fault.
My tables creation script seems to work fine now - I've edited my reponse to Solomon - the definitive scripts
are now there - with Order_Parts.User_Number gone and the TO_DATE(...) as
you suggested - the VARCHARs seemed to give the right result though - but I
agree that if there's a correct way of doing it, then it should be done that way.
Remember why you need to go to the trouble of posting CREATE TABLE and INSERT statements
for some sample data here. It's to allow the people who want to help you to re-create the prolem
and test their ideas. I know, and that's why I did it - the OR REPLACE that I added (stupidly and without thinking or testing) was
so that people wouldn't have to go to the trouble of dropping the tables - I have now added
DROP TABLE blah... to the beginning of the script so it won't be necessary.
I have over 600 posts on this forum and only 26 questions - most of my time
spent here is trying to help (to the best of my limited ability - I'm not a guru
like yourself) and learning - it's amazing the number of times problems that
I've seen here have subsequently arisen at work - and I am frequently
frustrated by some posters' inability to explain their problem or at least give test
cases.
I can forgive bad English (except my own) - not everybody is a fluent speaker of the language,
but SQL should run no matter what language one speaks.
I appreciate that people are volunteering their time and effort here and I really do
try and make it as easy as possible for them when I ask questions - I messed up
this time, I'm afraid. It might also be the fact that I'm moving between SQL*Plus
and SQL Developer and a text editor that I got confused (plus, fatigue didn't help...)
In general, other people are not going to test anything on your system. I'm going to test
things on my system, Solomon will test things on his system, and other people will test things
on other systems. Well, if ever you're in Dublin ;). Again, I appreciate the effort that you, Solomon and sKr have
gone to in helping me.
Your INSERT earlier statements did not work on my system, because you were using a VARCHAR2
in a place where a DATE was required. The correct thing to do is to use DATEs where DATEs are required. Indeed, and I agreed with you that if there's a right way of doing it, then it should be done that way.
If your NLS settings are such that this is not causing you any errors right now, it's still a good
idea for you to fix it; but, at any rate, whether it works on your system isn't what's important in
this case; you're posting it to run on other peoples' systems.Ahhh.... <the blinding light of a moment of epiphany descends on Paul> I didn't realise it was
an NLS setting - of course Americans will be different - it's just that I thought that YYYY-Mon-DD
worked everywhere (I tried to avoid the day-first/month-first pitfall ) but now that you've explained
it to me, I'll *never* make that mistake again.
Yes - my mistake - I've now corrected the error
Where are the desired results? Don't merely hide them in an old message; post them in a new message.OK. I'll put it in a reply to this post. I really am endeavouring to be as clear as possible - please
excuse my errors - I will do better in future. I'm also very annoyed at my own incompetence and at
having put you to more trouble than you would have had to go to if I had my wits about me.
- should I keep Order_Parts.User_Number even
if it isn't conformant to normalisation rules?
If you have a good reason, it's okay to store de-normalized data. For example, some address tables in
the US contain both state and ZIP code, even though state is fucntionally depenedent on ZIP code. I think that in this case, denormalisation is not called for.
Re. the ZIP code thing, yeah, sure AIUI, the first two digits are dependent on the state, but the
last three? They're more or less random - at least in the sense that there's no way to type
in an address and calculate (mathematically, using a formula) them - so unless one were
to have weird SQL lookups to a "State" table for the first two digits and then take the final
three from a user-entered string field, then do a TO_CHAR on the returned 2-digit state number and add
this to the 3-character one - I can't see how the ZIP code is an example of this? But, maybe
(unless you wish to discuss that) we're getting side-tracked. Perhaps I'll ask this question
on comp.databases.theory?
Oracle actually added a new feature in version 11 (virtual columns) to make de-normalizing easier.Hmmm... is adding virtual columns denormalisation per se? My favourite "cheap'n'cheerful"
db server (Firebird) has had a COMPUTED BY clause (same idea) for yonks (> 12yrs) - no data
is actually stored - rather it is calculated on the fly. Another one for comp.databases.theory
perhaps?
BTW, wouldn't triggers remove all this hassle? It was my first idea, but trying to do it
purely through SQL is now *obsessing* me ;)
That would be another example of de-normalization. If the benefits of doing that outweigh the
costs, then go ahead. A trigger will take some effort to maintain, and it will make all DML slower, regardless
of how often that derived value is needed. Having the extra column will make some queries simpler and faster. Disk is cheap. Have an Original_Orders table (never changes) and a Revised_Orders table. When
a part replacement occurs - for orders that haven't been fulfilled (boolean flag?), change the
old part number to the new one. I can't imagine that replacement occurs very frequently, so
the expense of a trigger would IMHO be minimal - plus the down side of any trigger would
be mitigated by greatly simplifying the production of the Revised_Orders report?
... I'll experiment with what you've given me so far - but it's 23:40 here now, so I won't
get a chance to do it tonight - unfortunately, I *do* have to sleep.
If you haven't tested it yet, why did you start this message saying "your SQL doesn't work"?Sorry - what I meant was it obviously doesn't work when this eejit (i.e. me) has changed
the table structure - I did run it quickly (your 1st statement) against the (revised table
structure, the one you hadn't seen and I don't think even a man of your great SQL talents
can be expected to write working queries against unknown table structures :)).
Again, thanks for your help so far - I'll post the *_correct_* DDL and DML as a reply to this post
with the desired result. I'll also reconstitute the old (i.e. the one you worked against) tables
and data and let you know - again as a reply to this post - if I can at least learn something
from my fiasco, it won't have been a total waste of my time, and again, apologies for
wasting yours.
Thanks again and rgs.
Paul...
Edited by: Paulie on 22-Mar-2012 02:50 -
How to auto update date column without using trigger
Hi,
How to write below MYSQL query in Oracle 10g :
CREATE TABLE example_timestamp (
Id number(10) NOT NULL PRIMARY KEY,
Data VARCHAR(100),
Date_time TIMESTAMP DEFAULT current_timestamp on update current_timestamp
I need to auto update the Date_Time column without using trigger when ever i update a record.
Example shown below is from MYSQL. I want to perform the below steps in ORACLE to auto update Date_Time column.
mysql> INSERT INTO example_timestamp (data)
VALUES ('The time of creation is:');
mysql> SELECT * FROM example_timestamp;
| id | data | Date_Time |
| 1 | The time of creation is: | 2012-06-28 12:37:22 |
mysql> UPDATE example_timestamp
SET data='The current timestamp is: '
WHERE id=1;
mysql> SELECT * FROM example_timestamp;
| id | data | Date_Time |
| 1 | The current timestamp is: | 2012-06-28 12:38:55 |
Regards,
Yogesh.Is there no functionality in oracle to auto update date column without using trigger??
I dont want to update the date column in UPDATE statement.
The date column should automatically get updated when ever i execute an Update statement. -
How to update two columns in two tables?
hi friends
I have two tables linked to each other through SaleNo and SaleDT. their structure as below
Sales Table============
SaleNo int PK auto increment
SaleDT Datetime PK
Qnty decimal
Units decimal
Invoices table
=================InvoiceNo int PK Auto incremented
InvoiceDT Datetime
SaleNo int FK
SaleDT Datetime FK
Note that SaleDT column is NOT assigned with getDate() expression.
1. what I need to do is update the SaleDT column of Sales table and Invoices table with the value '2013-01-31 10:31:55.813', how do I do this without manually breaking the link between the tables?
2. Assume SaleNos 15 to 27 needs update the SaleDT to '2013-06-12 10:31:55.813', how do I do this complex operation where I I have update SaleDt column of two table of SaleNo range from 15 to 27?
thanks
I use Visual studio 2012 Ultimate and SQL server 2008 developer edition!Why not below? May be you will not be able to change your design now, but just want to share.
Sales Table============
SALEID int PK autoincrement
SaleNo int
SaleDT Datetime
Qnty decimal
Units decimalUNIQUE (Saleno,SaleDT)
Invoices table
=================InvoiceNo int PK Auto incremented
InvoiceDT Datetime
SALEID int FK -
How to store multiple child nodes using dbms_xmlstore
Hi,
I'm using oracle 10g environment. In DBMS_XMLSTORE package I cannot able to insert the multiple child node value into db table.
Here I have given the xml value
<DATAPACKET REQUEST-ID="10001094">
<HEADER>
<SEARCH-RESULT-LIST>
<SEARCH-RESULT-ITEM NAME="Ra-Al-Gul" CONFIDENCE-SCORE="750" BUREAU-ID="893991307899440">
<IDENTIFIERS>
<IDENTIFIER IDSOURCE="0001" MATCHED="TRUE"/>
</IDENTIFIERS>
<SURROGATES>
<SURROGATE ID="CH0001" MATCHED="TRUE"/>
<SURROGATE ID="CH0002" MATCHED="TRUE"/>
<SURROGATE ID="CH0003" MATCHED="TRUE"/>
</SURROGATES>
</SEARCH-RESULT-ITEM>
</SEARCH-RESULT-LIST>
</HEADER>
</DATAPACKET>for this xml data I have created the below table structure
-- Table create script
CREATE TABLE xml_insert (datapacket t_response );
/* Type creation code */
CREATE OR REPLACE TYPE t_response AS OBJECT
"@REQUEST-ID" VARCHAR2(100),
header t_resp_header
CREATE OR REPLACE TYPE t_resp_header AS OBJECT
"SEARCH-RESULT-LIST" t_search_item
CREATE OR REPLACE TYPE t_search_item AS OBJECT
("SEARCH-RESULT-ITEM" t_search_list);
CREATE OR REPLACE TYPE t_search_list AS OBJECT
("@NAME" VARCHAR2(300),
"@CONFIDENCE-SCORE" VARCHAR2(300),
"@BUREAU-ID" VARCHAR2(300),
IDENTIFIERS t_search_identifiers,
SURROGATES t_search_surrogates
CREATE OR REPLACE TYPE t_search_identifiers AS OBJECT
(IDENTIFIER t_search_IDENTIFIER);
CREATE OR REPLACE TYPE t_search_identifier AS OBJECT
"@IDSOURCE" VARCHAR2(20),
"@MATCHED" VARCHAR2(20)
CREATE OR REPLACE TYPE t_search_surrogates AS OBJECT
(SURROGATE t_search_SURROGATE);
CREATE OR REPLACE TYPE t_search_surrogate AS OBJECT
"@ID" VARCHAR2(20),
"@MATCHED" VARCHAR2(20)
CREATE OR REPLACE TYPE tb_search_surrogate AS TABLE of t_search_SURROGATE;
/and run this block
DECLARE
insCtx DBMS_XMLStore.ctxType;
rows NUMBER;
xmldoc CLOB :=
<ROWSET>
<ROW>
<DATAPACKET REQUEST-ID="Q10001094">
<HEADER>
<SEARCH-RESULT-LIST>
<SEARCH-RESULT-ITEM NAME="Anis kulam" CONFIDENCE-SCORE="750" BUREAU-ID="893991307899440">
<IDENTIFIERS>
<IDENTIFIER IDSOURCE="0001" MATCHED="TRUE"/>
</IDENTIFIERS>
<SURROGATES>
<SURROGATE ID="CH0001" MATCHED="TRUE"/>
<SURROGATE ID="CH0002" MATCHED="TRUE"/>
<SURROGATE ID="CH0003" MATCHED="TRUE"/>
</SURROGATES>
</SEARCH-RESULT-ITEM>
</SEARCH-RESULT-LIST>
</HEADER>
</DATAPACKET>
</ROW>
</ROWSET>';
BEGIN
insCtx := DBMS_XMLStore.newContext('xml_check');
rows := DBMS_XMLStore.insertXML(insCtx, xmlDoc);
DBMS_XMLStore.closeContext(insCtx);
END;I got the following error
Error Messgae :
ORA-19031: XML element or attribute SURROGATE does not match any in type DOHADEV.T_CRB_SEARCH_SURROGATES
ORA-06512: at "SYS.DBMS_XMLSTORE", line 78
ORA-06512: at line 28Hi,
A couple of comments to begin with :
- Your setup script, test case and error message are not consistent with each other.
- You've not chosen the easiest road with DBMS_XMLSTORE and nested objects. As pointed out in a previous thread of yours, the whole thing would be far more simple with XMLTable.
Do you really need to store the data in an object-relational structure at the end, or do you intend to further break it down into relational rows and columns?
Do you have an XML schema? -
Parent node showing in schema when child nodes not present
I had several folks answer my questions on mapping from a flat file to an EDI 835 schema and I am down to just a couple of issues before I finish up. I have a conditional mapping issue that I have to solve before I can map the rest of the document. I am
mapping three fields in a single non-repeating line in the flat file to a repeating segment in the 835. Basically I need to create a separate AMT_ClaimSupplementalInformation segment for each field in the flat file line. As you can see in the picture
below I want to create a AMT_ClaimSupplementalInformation segment for CDISCOUNT, CINELIGIBLE and CALLOWED.
You can see I have quite a bit of conditional logic attached to the three fields, but I have all three connected via a loop to the AMT_ClaimSupplementalInformation parent. I cannot attach the loop to the parent of the three fields because it only appears
once in the file. And if I leave the loop out the AMT segments get stacked funny, like this:
<AMT_ClaimSupplementalInformation>
AMT1
AMT1
AMT2
AMT2
</AMT_ClaimSupplementalInformation>
You can see how they should be stacked in the next pic.
In some cases however, one of those fields may be blank so I will not need to create a AMT_ClaimSupplementalInformation segment for it. I was able to use some conditional mapping ideas you guys gave me using the Not-Equal and Value Mapping functoids, and
that works great to keep blank child nodes from being created. However, Since I have a loop attached to the AMT_ClaimSupplementalInformation parent node it still creates an empty parent node even when the child nodes are not created. See the empty parent
node in the pic below.
Since looping functoids can only be attached to links I don't know how to make the parent node conditional.
Any suggestions?
Thanks.Boatseller, thanks for the tip. I did end up going the XSLT direction. It's a bit of a hack, but I'm using the following XSLT to eliminate empty nodes :
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:if test=". != ''">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
I created a new map with the 835 schema on each side. I then created an XSLT file and pointed to it in the Custom XSLT Path property. It seems to work well. I call this map right after my FlatFile_To_835 map.
I was hoping to use the scripting functoid with inline XSLT in the map so that I didn't have to worry about deploying the XSLT file(just another thing to keep up with in the future), but when I compile it I get the following error:
The "Scripting" functoid has 1 input parameter(s), but 2 parameter(s) are expected.
I'm wondering if I'm connecting the schemas incorrectly in the map:
In any case, I'm past the empty nodes issue for now, which was a big roadblock. Now I have to deal with the CAS segments which are, as you said, a real pain.
Thanks for all of your input. -
Copy node from XML tree problem
I am trying to copy an XML node 9whic hmay have child nodes) from one tree to another with the code
nodes = dataDoc.getElementsByTagName("text");
currentElement = (Element) nodes.item(0);
textNode.appendChild(nodes.item(0).cloneNode(true));
gives the error
org.apache.crimson.tree.DomEx: WRONG_DOCUMENT_ERR: That node doesn't belong in this document.
at org.apache.crimson.tree.ParentNode.checkDocument(ParentNode.java:250)
at org.apache.crimson.tree.ParentNode.appendChild(ParentNode.java:333)
What am I doing wrong?
Regards,
MArkWhat am I doing wrong?Failing to use the Document.importNode() method.
-
Hi,
I have done a application with Tree by NST table .
The initial screen will contains around 6 fields , the first field (ObjKey) will be displayed. I have stored in one internal table and i i want to display the child node for correponding objkey,for that child node again im storing in to the same internal table . now when i to expand the child node from the output there was no details coming , i got one empty line thats it .
I have seen many links available in the forum. but not helpful , please explainhi andre .
i am also facing same problem .......
my context is like ......
folder
| folder_content (recurcive node)
| file
| | file attribute
| folder attribute.
can u plz tell me about recurcive node .... if have any doc. then plz give the link ....
thanks .
Maybe you are looking for
-
Change the colour of any transaction
Hi SAP Gurus, Can anybody help me...... I need to change the colour of any transaction from default blue to black and white. I need this at transaction level, I can do this at user level (Customized local layout). Thanks & Regards, Krishn
-
How to check the tables we have created in JDBC??
I have created a table called COFFEE2 in a datasource called temp which is in SQL server...How to check the table values?? i went into administrative tools and odbc cource then i could see the data source i have created but how to see the table?? Can
-
My phone goes silent in conference call, but others can still talk??
When I start a conference call, after a random time period my end goes silent, but the other callers can hear eachother. What's going on?
-
Working with multiple audio tracks
Hello, I'm working with video clips that have a stereo audio track (guide audio fed into the camera) synch'ed to 4 mono tracks (recorded from a variety of boom mics and lavaliers). Although I've linked all the audio clips to the video, it still gets
-
Newbie question on raw adjustments in LR
I am just trying to get a handle on how lightroom works. If I make adjustments in the Develop module are the adjustments made to the RAW file itself or are the adjustments written as instructions within LR. When I use ACR in bridge I notice that I ca