Filtering xml records from CLOB database column
Hi,
I have a xml data stored in a CLOB field in database.
I need to retrieve the contents that match my filter criteria.
Say my xml is like below,
<ROOT>
<EMP>
<EMP_NO>1</EMP_NO>
<SAL>100</SAL>
</EMP>
<EMP>
<EMP_NO>2</EMP_NO>
<SAL>200</SAL>
</EMP>
<EMP>
<EMP_NO>3</EMP_NO>
<SAL>300</SAL>
</EMP>
</ROOT>
I want to fetch the entire xml tree but filtered based on the SAL field, WHERE SAL>100.
So my resulting xml should be
<ROOT>
<EMP>
<EMP_NO>2</EMP_NO>
<SAL>200</SAL>
</EMP>
<EMP>
<EMP_NO>3</EMP_NO>
<SAL>300</SAL>
</EMP>
</ROOT>
I will be having 'n' number of columns, and I cant specify everything in COLUMNS clause.
I want to select all nodes, but filter based on few fields.
I tried using it as below, but I feel it took some time for it to display results.
select x.*
from emp t
, xmltable(
'/ROOT'
passing xmltype(t.doc)
columns VSAL number PATH './EMP/SAL'
, OTHER xmltype PATH '.'
) x
where x.VSAL>100
Please suggest me a solution that doesnt consume much time.
I think the problem with my query is OTHER xmltype PATH '.'
Here 'xmltype' datatype is expensive I think, because after I included that, the query took some time.
I cant hardcode the SAL value of 100 as its dynamic. So I am unable to use this method of filtering.
select x.*
from emp t
, xmltable(
'/ROOT[.//EMP/SAL>100]'
passing xmltype(t.doc)
) x
Thanks!
Edited by: Chit on Mar 24, 2012 10:12 AM
Hi,
I want to fetch the entire xml tree but filtered based on the SAL field, WHERE SAL>100.Then you have to rebuild the document keeping only the elements satisfying the condition (and yes, you can bind XQuery variables too) :
SQL> select xmlserialize(document x.doc as clob indent)
2 from emp t
3 , xmltable(
4 '<ROOT>
5 {
6 for $i in /ROOT/EMP
7 where $i/SAL > $minsal
8 return $i
9 }
10 </ROOT>'
11 passing xmlparse(document t.doc)
12 , 100 as "minsal"
13 columns doc xmltype path '.'
14 ) x
15 ;
XMLSERIALIZE(DOCUMENTX.DOCASCL
<ROOT>
<EMP>
<EMP_NO>2</EMP_NO>
<SAL>200</SAL>
</EMP>
<EMP>
<EMP_NO>3</EMP_NO>
<SAL>300</SAL>
</EMP>
</ROOT>
Or you can just delete the nodes you don't want :
SQL> var minsal number
SQL> exec :minsal := 100
PL/SQL procedure successfully completed
SQL> select xmlserialize(document
2 deletexml( xmlparse(document t.doc)
3 , '/ROOT/EMP[SAL<='||:minsal||']' )
4 as clob indent
5 )
6 from emp t
7 ;
XMLSERIALIZE(DOCUMENTDELETEXML
<ROOT>
<EMP>
<EMP_NO>2</EMP_NO>
<SAL>200</SAL>
</EMP>
<EMP>
<EMP_NO>3</EMP_NO>
<SAL>300</SAL>
</EMP>
</ROOT>
Please suggest me a solution that doesnt consume much time.
I think the problem with my query is OTHER xmltype PATH '.'The real problem is the CLOB text storage.
If you want performance, use binary XMLType or object-relational.
Similar Messages
-
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 -
Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the records?
Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.The Oracle documentation has a good overview of the options available
Generating XML Data from the Database
Without knowing your version, I just picked 11.2, so you made need to look for that chapter in the documentation for your version to find applicable information.
You can also find some information in XML DB FAQ -
Select records from one database and insert it into another database
Hi
I need to write a statement to select records from one database which is on machine 1 and insert these records on a table in another database which is on machine 2. Following is what I did:
1. I created the following script on machine 2
sqlplus remedy_intf/test@sptd @load_hrdata.sql
2. I created the following sql statements in file called load_hrdata.sql:
rem This script will perform the following steps
rem 1. Delete previous HR data/table to start w/ clean import tables
rem 2. Create database link to HR database, and
rem 3. Create User Data import table taking info from HR
rem 4. Drop HRP link before exiting
SET COPYCOMMIT 100
delete from remedy.remedy_feed;
commit;
COPY FROM nav/donnelley@hrp -
INSERT INTO remedy.remedy_feed -
(EMPLID, FIRST_NAME, MI, LAST_NAME, BUSINESS_TITLE, WORK_PHONE, -
RRD_INTRNT_EMAIL, LOCATION, RRD_OFFICE_MAIL, RRD_BUS_UNIT_DESCR) -
USING SELECT EMPLID, FIRST_NAME, MI, LAST_NAME, BUSINESS_TITLE, WORK_PHONE, -
RRD_INTRNT_EMAIL, LOCATION, RRD_OFFICE_MAIL, RRD_BUS_UNIT_DESCR -
FROM ps_rrd_intf_medium -
where empl_status IN ('A', 'L', 'P', 'S', 'X')
COMMIT;
EXIT;
However, whenever I run the statement I keep getting the following error:
SP2-0498: missing parenthetical column list or USING keyword
Do you have any suggestions on how I can fix this or what am I doing wrong?
Thanks
AliThis doesn't seem to relate to Adobe Reader. Please let us know the product you are using so we may redirect you or refer to the list of forums at http://forums.adobe.com/
-
Moving audit Records from one database to another database using dblink
i got five database, i have to move sys.aud$ records from five databases to one centralized database into another schema every day at 10:00 clock, i have to use a dblink for this, i have to create same table as sys.aud$ with different schema in centralized database with one extra column db_unique_name,by using db_link how i need to move records from all the five databases to one centralized database, can anyone help me here how to create a db_link from to move records from five database to one centralized database, due to maintainance perspective i have to move the records from all the five databases to one centralized database. i have to write a script for moving the audit records from all the five databases to one centralized database, can anyone help me how to write the script, or if you have any related scripts , can u post here, it will helpful for me.
spool audit.log
--"Auditing Initialisation Parameters: check initialization parameter"
select name || '=' || value from v$parameter where name like '%audit%'
---"if auditing is disabled then issue this command and bounce"
alter system set audit_trail=db,extended scope = spfile
shutdown immediate
startup
create tablespace ORDER_DATA datafile '+DDATA' size 50m;
create user INFO identified by INFO;
Grant connect,resource to INFO;
Alter user INFO quota unlimited on ORDER_DATA;
create table INFO.ORDER as select * from sys.aud$;
alter INFO.ORDER add db_unique_name varchar2(50);
create table INFO.ORDER
partition by range (Timestamp#)
subpartition by hash(dbid)
subpartition template
(subpartition sp1 tablespace users,
subpartition sp2 tablespace users)(
partition p1 values less than (TO_DATE('07/29/2010','MM/DD/YYYY')),
partition p2 values less than (TO_DATE('07/29/2011','MM/DD/YYYY')),
partition p3 values less than (MAXVALUE)) tablespace BGORDER_DATA as select * from sys.aud$
spool off;
exit
BEGIN
DBMS_SCHEDULER.create_job(
job_name => 'Move Aud$ records',
job_type => 'PLSQL_BLOCK',
job_action => 'CREATE OR REPLACE PROCEDURE bgorder_aud
AS
ts TIMESTAMP;
BEGIN
ts := SYSTIMESTAMP;
insert into info.order select * from sys.aud$ where timestamp# < ts;
delete sys.aud$ where timestamp# < ts;
commit;
END;
start_date => TRUNC(SYSDATE) + 22 / 24,
repeat_interval => 'FREQ=daily;BYHOUR=22;BYMINUTE=0;BYSECOND=0',
enabled => TRUE,
comments => 'Move records');
END;
/ -
How to get Hierarchical XML File from a Database Join Query !
Hi,
How can i get a Hierarchical XML File from a Database Join Query ?
Any join query returns repeated values as below:
BD17:SQL>select d.dname, e.ename, e.sal
2 from dept d
3 natural join
4 emp e
5 /
DNAME ENAME SAL
ACCOUNTING CLARK 2450
ACCOUNTING KING 5000
ACCOUNTING MILLER 1300
RESEARCH SMITH 800
RESEARCH ADAMS 1100
RESEARCH FORD 3000
RESEARCH SCOTT 3000
RESEARCH JONES 2975
SALES ALLEN 1600
SALES BLAKE 2850
SALES MARTIN 1250
SALES JAMES 950
SALES TURNER 1500
SALES WARD 1250
14 rows selected.
We tried use DBMS_XMLQUERY to generate a xml file, but it was unable to get xml in Hierarchical format.
<?xml version="1.0" encoding="ISO-8859-1" ?>
- <ROWSET>
- <ROW num="1">
<DNAME>ACCOUNTING</DNAME>
<ENAME>CLARK</ENAME>
<SAL>2450</SAL>
</ROW>
- <ROW num="2">
<DNAME>ACCOUNTING</DNAME>
<ENAME>KING</ENAME>
<SAL>5000</SAL>
</ROW>
- <ROW num="3">
<DNAME>ACCOUNTING</DNAME>
<ENAME>MILLER</ENAME>
<SAL>1300</SAL>
</ROW>
- <ROW num="4">
<DNAME>RESEARCH</DNAME>
<ENAME>SMITH</ENAME>
<SAL>800</SAL>
</ROW>
- <ROW num="5">
<DNAME>RESEARCH</DNAME>
<ENAME>ADAMS</ENAME>
<SAL>1100</SAL>
</ROW>
- <ROW num="6">
<DNAME>RESEARCH</DNAME>
<ENAME>FORD</ENAME>
<SAL>3000</SAL>
</ROW>
- <ROW num="7">
<DNAME>RESEARCH</DNAME>
<ENAME>SCOTT</ENAME>
<SAL>3000</SAL>
</ROW>
- <ROW num="8">
<DNAME>RESEARCH</DNAME>
<ENAME>JONES</ENAME>
<SAL>2975</SAL>
</ROW>
- <ROW num="9">
<DNAME>SALES</DNAME>
<ENAME>ALLEN</ENAME>
<SAL>1600</SAL>
</ROW>
- <ROW num="10">
<DNAME>SALES</DNAME>
<ENAME>BLAKE</ENAME>
<SAL>2850</SAL>
</ROW>
- <ROW num="11">
<DNAME>SALES</DNAME>
<ENAME>MARTIN</ENAME>
<SAL>1250</SAL>
</ROW>
- <ROW num="12">
<DNAME>SALES</DNAME>
<ENAME>JAMES</ENAME>
<SAL>950</SAL>
</ROW>
- <ROW num="13">
<DNAME>SALES</DNAME>
<ENAME>TURNER</ENAME>
<SAL>1500</SAL>
</ROW>
- <ROW num="14">
<DNAME>SALES</DNAME>
<ENAME>WARD</ENAME>
<SAL>1250</SAL>
</ROW>
</ROWSET>
Thank you for some help.
Nelson AlbertiHi,
I wrote a general ABAP program which can be configured to grab contrent from an URL and post that content as a new PI message into the integration adapter .... from that point on normal PI configuration can be used to route it to anywhere ...
It can be easily scheduled as a background job to grab content on a daily basis etc ...
Regards,
Steven -
How to delete the child record from the database
how to delete a parent and child record from the database can we do it in the servlet and my database is oracle
I'm not sure I understand the question but you could certainly use the JDBC API from within your servlet to access and modify a DB. You could also use an EJB layer to access your DB and accomplish the same tasks.
-
How to export an XML file from oracle database?
plz help me its urgent requirement....could u pls tell me the step by step procedure for following questions...?how to export a data as an XML file from oracle database?
thanks in advance,
Bala.
Edited by: user3523292 on Nov 14, 2008 5:43 AMuser3523292 wrote:
plz help me its urgent requirement....could u pls tell me the step by step procedure for following questions...?how to export a data as an XML file from oracle database?
thanks in advance,
Bala.
Edited by: user3523292 on Nov 14, 2008 5:43 AMThis is a forum of volunteers. There is no "urgent" here. Nevertheless, a google search of 'xml oracle export' quickly lead me to this Oracle site:
otn.oracle.com/sample_code/tech/xml/index.html
I also see lots of hits when I search the documentation library at tahiti.oracle.com for 'xml'. This one in particular may be what you are looking for:
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14252/adx_j_xsu.htm#ADXDK070 -
Export an XML file from oracle database
plz help me its urgent requirement....could u pls tell me the step by step procedure for following questions...?how to export a data as an XML file from oracle database? is it possible..?
thanks in advance,
Bala. is it possible?
Edited by: user3523292 on Nov 14, 2008 5:45 AMHere's the quick and dirty method using SQL*Plus...
SQL> select * from emp where deptno = 10;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7839 KING PRESIDENT 17-NOV-81 5000 10
7934 MILLER CLERK 7782 23-JAN-82 1300 10
SQL> set markup html on
SQL> select * from emp where deptno = 10;
<br>
<p>
<table border='1' width='90%' align='center' summary='Script output'>
<tr>
<th scope="col">
EMPNO
</th>
<th scope="col">
ENAME
</th>
<th scope="col">
JOB
</th>
<th scope="col">
MGR
</th>
<th scope="col">
HIREDATE
</th>
<th scope="col">
SAL
</th>
<th scope="col">
COMM
</th>
<th scope="col">
DEPTNO
</th>
</tr>
<tr>
<td align="right">
7782
</td>
<td>
CLARK
</td>
<td>
MANAGER
</td>
<td align="right">
7839
</td>
<td>
09-JUN-81
</td>
<td align="right">
2450
</td>
<td align="right">
</td>
<td align="right">
10
</td>
</tr>
<tr>
<td align="right">
7839
</td>
<td>
KING
</td>
<td>
PRESIDENT
</td>
<td align="right">
</td>
<td>
17-NOV-81
</td>
<td align="right">
5000
</td>
<td align="right">
</td>
<td align="right">
10
</td>
</tr>
<tr>
<td align="right">
7934
</td>
<td>
MILLER
</td>
<td>
CLERK
</td>
<td align="right">
7782
</td>
<td>
23-JAN-82
</td>
<td align="right">
1300
</td>
<td align="right">
</td>
<td align="right">
10
</td>
</tr>
</table>
<p>
SQL>which you can spool to a file. -
How to fetch records from the database into a combo box?
Hi:
I´m really new with ABLBPM and I´m trying to fetch records from the database to display them into a combo box as valid values for a presentation but I´m using a dynamic method with this code:
<em>for each row in SELECT campo1, campo2 from TABLE</em>
<em>do</em>
<em>solicitudes[] = [row.campo1, row.campo2]</em>
<em>end</em>
<em>return solicitudes
</em>And the debugger says that SQL instructions can be used only in fuctions and procedures that are executed on the server.
Do you know another way to do it?
P.D. Sorry for my terrible english
GreetingsHi Steve,
Thank you, your idea is perfect, but when I try to run the screenflow where the combo should be filled I get this error:
fuego.lang.ComponentExecutionException: No se ha podido ejecutar correctamente la tarea.
Motivo: 'java.lang.NullPointerException'.
at fuego.web.execution.InteractiveExecution.setExecutionError(InteractiveExecution.java:307)
at fuego.web.execution.InteractiveExecution.process(InteractiveExecution.java:166)
at fuego.web.execution.impl.WebInteractiveExecution.process(WebInteractiveExecution.java:54)
at fuego.webdebugger.servlet.DebuggerServlet.redirect(DebuggerServlet.java:136)
at fuego.webdebugger.servlet.DebuggerServlet.doPost(DebuggerServlet.java:85)
at fuego.webdebugger.servlet.DebuggerServlet.doGet(DebuggerServlet.java:66)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at fuego.web.execution.servlet.ServletExternalContext.forwardInternal(ServletExternalContext.java:197)
at fuego.web.execution.servlet.ServletExternalContext.processAction(ServletExternalContext.java:110)
at fuego.webdebugger.servlet.DebuggerExecution.dispatchComponentExecution(DebuggerExecution.java:64)
at fuego.web.execution.InteractiveExecution.invokePrepare(InteractiveExecution.java:351)
at fuego.web.execution.InteractiveExecution.process(InteractiveExecution.java:192)
at fuego.web.execution.impl.WebInteractiveExecution.process(WebInteractiveExecution.java:54)
at fuego.web.execution.InteractiveExecution.process(InteractiveExecution.java:223)
at fuego.webdebugger.servlet.DebuggerServlet.doDebug(DebuggerServlet.java:148)
at fuego.webdebugger.servlet.DebuggerServlet.doPost(DebuggerServlet.java:82)
at fuego.webdebugger.servlet.DebuggerServlet.doGet(DebuggerServlet.java:66)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
Any ideas??
Thanks and greetings -
How to get first 10 records from the database using JSP
i want ot get first 10 records from the database and then after clicking the next button in the page,it must show the next precceding 10 records from the database.i am getting the first 10 records .but how to post to the same page to get another preceeding 10 record.
Search the forums - this has been asked a lot. I usually recommend experimenting with tops and order bys until you're satisfied.
Kind regards,
Levi -
Selecting the last record from a database table
In my ABAP Program, I have to use a select statement to retrieve the last record from the database table with the same key. In other words, the Program will get more than one hit on the database table for the selected keys and I need to retrieve values from only the last record and not the first. I know I can use an internal table to sort the records first and then retrieve the right value. But to make things easier, is there a SELECT statement keyword than I can use to do this in one single step? Thanks!
hi,
tables:mara.
data: begin of it_mara occurs 0,
matnr like mara-matnr,
meins like mara-meins,
mtart like mara-mtart,
end of it_mara.
select-options:s_matnr for mara-matnr.
select matnr
meins
mtart
from mara
into table it_mara
where matnr in s_matnr.
if not it_mara[] is initial.
sort it_mara by matnr descending.
read table it_mara index 1.
endif.
then you get the last record of the select statement.
reward points if useful,
venkat. -
Fetching 3 laks records from the database
Hi All,
I have a requirement that if we are fetchin 3 lakks records from the database, can we fetch the records in a single span of time ,if yes then how?
If no, then we have to fetch the recods multiple times but since for the first time it is fetching 1 lakh records and for the next time how the bpel engine know that it has to fetch 1000001 record.
Can anybody came this type of scenario. Please guide me on this.
Regards,
ChThere are some options given here @ http://myexperienceswithsoa.blogspot.com/2010/06/db-adapter-polling-tricks.html
Check them out.
But if you reading so much of data at once, you better have the necessary infrastructure to handle the load like memory, jvm tuning, etc ...
If there is a limitation, you will need to assess your polling record count to be may 10K or so to strike a balance on the performance.
Hope this helps.
Thanks,
Patrick -
Hello Friends,
The background is I am working as conversion manager and we move the data from oracle to SQL Server using SSMA and then we will apply the conversion logic and then move the data to system test ,UAT and Production.
Scenario:
Moving the 80 Million records from Conversion database to System Test database (Just for one transaction table) taking too long. Both the databases are in the same server.
Questions are…
What is best option?
IF we use the SSIS it’s very slow and taking 17 hours (some time it use to stuck and won’t allow us to do any process).
I am using my own script (Stored procedure) and it’s taking only 1 hour 40 Min. I would like know is there any better process to speed up and why the SSIS is taking too long.
When we move the data using SSIS do they commit inside after particular count? (or) is the Microsoft is committing all the records together after writing into Transaction Log
Thanks
Karthikeyan Jothihttp://www.dfarber.com/computer-consulting-blog.aspx?filterby=Copy%20hundreds%20of%20millions%20records%20in%20ms%20sql
Processing
hundreds of millions records can be done in less than an hour.
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Deleting records from a Database using JTable
Hello!
I have a JTable that displays records from a database and a Jbutton .
If i press the button i want that the record coresponding to selectedRow(from the JTable) to be erased from the database.How can i manipulate selectedRow from JTable to do that?
Pls any suggestions (and if it's possible +code)?
Thanks!Hi Margot,
Let's assume that you have created a table using vectors. Simply remove the element from the vector at row selected and redraw. Maybe not the greatest solution but should work.
Vector rowData = new Vector();
//read in values for each row
Vector headers = new Vector();
//add your headers
JTable table = new JTable(rowData, headers);
int row = table.getSelectedRow();
rowData.removeElementAt(row);
table = new JTable(rowData, headers);HTH,
Chris
Maybe you are looking for
-
How do you change color of an event in a calendar in ical
how do I change the color of an EVENTt in ical
-
I purchased downloaded and installed Adobe Photoshop CS6 and Bridge CS6 and Bridge since installing it today has not been able to open. I tried holding the option button (im using a Mac w/ Snow Leopard) and clicking the app to reset to factory settin
-
How to set the size of the frame in the decoration controls
Hi, I am drawing some frames or boxes using the patterns in the "Decorations" control in labview. Is there other way to set the size of the frames or boxes rather than to drag them? also how can I change the color of the borders? Thanks, Joyce Solved
-
Ok, so I want to use Lightroom to create a web gallery, which is easy enough, but I would like to use a different design other than the ones provided with the software. The included templates are fine, but are a little boring and look a bit dated. A
-
Hi , Could you please let me know how to dynamically change the 508 compliance to normal view and from normal view to 508 compliance. I was able to change the accessibility mode in triandad.xml file to screen reader to change the normal UI to 508 com