Querying RESOURCE_VIEW using XQuery
Hi all:
Anybody knows the best way to query RESOURCE_VIEW using XQuery to show directory listing information as an example.
For example, I want to produce an XML Document with something like this using XQuery:
<directoryListing>
<dir anyPath="/public/JURRICULUM/cms/en">
<DisplayName xmlns="http://xmlns.oracle.com/xdb/XDBResource.xsd">en</DisplayName>
</dir>
<dir anyPath="/public/JURRICULUM/cms/en/live">
<DisplayName xmlns="http://xmlns.oracle.com/xdb/XDBResource.xsd">live</DisplayName>
</dir>
<dir anyPath="/public/JURRICULUM/cms/es">
<DisplayName xmlns="http://xmlns.oracle.com/xdb/XDBResource.xsd">es</DisplayName>
</dir>
<dir anyPath="/public/JURRICULUM/cms/es/live">
<DisplayName xmlns="http://xmlns.oracle.com/xdb/XDBResource.xsd">live</DisplayName>
</dir>
</directoryListing>
I made this result by executing this query:
SELECT XMLQuery('declare namespace res = "http://xmlns.oracle.com/xdb/XDBResource.xsd";
<directoryListing>
{for $i in $directoryListing/dir
where $i/res:Resource/@Container="true"
return
<dir anyPath="{$i/@ANY_PATH}">
{$i/res:Resource/res:DisplayName}
</dir>}
</directoryListing>'
PASSING (
select XMLAgg(XMLElement("dir",XMLATTRIBUTES(any_path,resid),res))
from resource_view where
under_path(res,'/public/JURRICULUM/cms')=1
) as "directoryListing" RETURNING CONTENT).getStringVal()
FROM dual
I had injected resource_view's content as an argument.
Another way is to use ora:view() extension function, but I can't use under_path functionality for example.
Is there some extension funcion like doc() or collection() but instead of returning the content of the document, returning the information of resource_view asociated to the URI?
Is the above query optimal in term of execution plan?
I tested it with JDeveloper and shows an execution plan similar to the query on resource_view alone.
Best regards, Marcelo.
Hi all:
I had implemented an XQuery extension library ready to run inside the Oracle JVM, but it can run outside as well.
The code is on the XQuery forums:
How to write an XQuery Extension library
I tested outside the database and the result is:
/usr/java/jdk1.5.0_04/bin/java -hotspot -classpath ... com.prism.cms.xquery.Application1 /public/PCT_ADMIN/cms/es/3-AcercaParque/ 7934
testXQL elapsed time: 3094
testXQ elapsed time: 2164
Running as Java Stored Procedure, it looks like this:
SQL> exec testXQ('/public/PCT_ADMIN/cms/es/3-AcercaParque/','7934')
testXQL elapsed time: 943
testXQ elapsed time: 854
PL/SQL procedure successfully completed.
Obviously running as Java Stored procedure its around 3.5 faster than a regular application.
Injecting the resource_view content as an argument instead of using an XQuery extension library seem to be equals (943 ~ 854), so I'll use the extension library mechanish for clearlying on the code.
Best regards, Marcelo
Similar Messages
-
Querying RESOURCE_VIEW using /Resource/XMLRef as key
Hi:
I am trying to query resource_view efficiently but instead of using equals_path or under_path which uses the domain index XDB.XDBHI_IDX using /Resource/XMLRef column.
For example, for a resource stored in a object relational table with a registered schema:
select extractValue(res,'/Resource/VCRUID'),any_path from resource_view
where extractValue(res,'/Resource/XMLRef')=make_ref(cms_docs,'27F5F5642ACA600AE040A8C00301464E');I am getting this execution plan:
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 152 | 9 (0)| 00:00:01 |
|* 1 | TABLE ACCESS BY INDEX ROWID| XDB$RESOURCE | 1 | 152 | 9 (0)| 00:00:01 |
|* 2 | DOMAIN INDEX | XDBHI_IDX | 1 | | | |
Predicate Information (identified by operation id):
1 - filter("P"."SYS_NC00024$"=MAKE_REF("CMS_DOCS",HEXTORAW('27F5F5642ACA600AE040A
8C00301464E') ))
2 - access("XDB"."UNDER_PATH"(SYS_MAKEXML('8758D485E6004793E034080020B242C6',734,
"XMLEXTRA","XMLDATA"),'/',9999)=1)
17 rows selected.For a query using sys_op_r2o operator, used to create the index XDB.XDB$RESOURCE_OID_INDEX on XDB$RESOURCE table:
select extractValue(res,'/Resource/VCRUID'),any_path from resource_view
where sys_op_r2o(extractValue(res,'/Resource/XMLRef'))=hextoraw('27F5F5642ACA600AE040A8C00301464E');I am getting a similar execution plan:
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 152 | 9 (0)| 00:00:01 |
|* 1 | TABLE ACCESS BY INDEX ROWID| XDB$RESOURCE | 1 | 152 | 9 (0)| 00:00:01 |
|* 2 | DOMAIN INDEX | XDBHI_IDX | 1 | | | |
Predicate Information (identified by operation id):
1 - filter("P"."SYS_NC00024$"=HEXTORAW('27F5F5642ACA600AE040A8C00301464E') )
2 - access("XDB"."UNDER_PATH"(SYS_MAKEXML('8758D485E6004793E034080020B242C6',734,
"XMLEXTRA","XMLDATA"),'/',9999)=1)
16 rows selected.What a I am doing wrong :(
Best regards, Marcelo.Hi:
Gathering the stats with null solve the problems, here the commands logged as XDB:
SQL> begin
2 DBMS_STATS.GATHER_TABLE_STATS (
3 ownname => 'XDB',
4 tabname => 'XDB$RESOURCE',
5 estimate_percent => null);
6 end;
7 /
SQL> begin
2 DBMS_STATS.GATHER_INDEX_STATS (
3 ownname => 'XDB',
4 INDNAME => 'XDBHI_IDX',
5 estimate_percent => null);
6 end;
7 /
SQL> begin
2 DBMS_STATS.GATHER_INDEX_STATS (
3 ownname => 'XDB',
4 INDNAME => 'XDB$RESOURCE_OID_INDEX',
5 estimate_percent => null);
6 end;
7 /Many thanks for the hint. Marcelo.
PD: I tested it on 11g beta 4 Linux 32 -
Creating a new document using XQuery
Hello everyone,
I wondered if there was a way to create a new document using XQuery. What I am trying to do is to run a query on XML file and try to print the results in HTML for viewing purpose.
The HTML is spitted out on DOS prompt. Instead I wanted to write that HTML to a file on disk. Is this possible with the XQuery tools provided by Oracle?
Thanks in advance for all the help
KFolks,
Kinda answering to my question. Just send the DOS output to some file. Pretty Simple huh!
Thankyou anyways
K -
RowNum for header and detail for XMLNodes using XQuery Sqlserver
Hi All,
I have this xml.
declare @xml xml
set @xml =' <StudentsData>
<StudentData>
<Name>AAA</Name>
<subjects>
<subject>
<Name>computers</Name>
<marks>30</marks>
</subject>
<subject>
<Name>Maths</Name>
<marks>40</marks>
</subject>
</subjects>
</StudentData>
<StudentData>
<Name>BBB</Name>
<subjects>
<subject>
<Name>Science</Name>
<marks>30</marks>
</subject>
<subject>
<Name>Physics</Name>
<marks>40</marks>
</subject>
</subjects>
</StudentData>
</StudentsData>'
I am able to get the proper data by querying like below.
select
s.n.value('(Name/text())[1]', 'varchar(50)') as StudentName ,
z.c.value('(Name/text())[1]','varchar(50)') as SubjectName ,
z.c.value('(marks/text())[1]','int') as Marks
from
@XML.nodes('/StudentsData/StudentData') as S(N)
CROSS APPLY s.n.nodes('subjects/subject') z(c)
But I want to include the header_id and detail_id to for these records using a variable like below.
eg: declare @header_id =100
declare @detail_id = 1000
I want the output like below.
HeaderId DetailId StudentName SubjectName Marks
101 1001 AAA computers 30
101 1002 AAA Maths 40
102 1003 BBB Science 30
102 1004 BBB Physics 40
how do I get this using xquery.
Thanks in advance.pls try
declare @xml xml
set @xml =' <StudentsData>
<StudentData>
<Name>AAA</Name>
<subjects>
<subject>
<Name>computers</Name>
<marks>30</marks>
</subject>
<subject>
<Name>Maths</Name>
<marks>40</marks>
</subject>
</subjects>
</StudentData>
<StudentData>
<Name>BBB</Name>
<subjects>
<subject>
<Name>Science</Name>
<marks>30</marks>
</subject>
<subject>
<Name>Physics</Name>
<marks>40</marks>
</subject>
</subjects>
</StudentData>
</StudentsData>'
declare @header_id int =100
declare @detail_id int= 1000
select @header_id+ROW_NUMBER() over(order by (select 1)) header_id,@detail_id+ROW_NUMBER() over(order by (select 1))detail_id,
s.n.value('(Name/text())[1]', 'varchar(50)') as StudentName ,
z.c.value('(Name/text())[1]','varchar(50)') as SubjectName ,
z.c.value('(marks/text())[1]','int') as Marks
from
@XML.nodes('/StudentsData/StudentData') as S(N)
CROSS APPLY s.n.nodes('subjects/subject') z(c)
vt
Please mark answered if I've answered your question and vote for it as helpful to help other user's find a solution quicker -
Can I refactor this query to use an index more efficiently?
I have a members table with fields such as id, last name, first name, address, join date, etc.
I have a unique index defined on (last_name, join_date, id).
This query will use the index for a range scan, no sort required since the index will be in order for that range ('Smith'):
SELECT members.*
FROM members
WHERE last_name = 'Smith'
ORDER BY joindate, idIs there any way I can get something like the following to use the index (with no sort) as well:
SELECT members.*
FROM members
WHERE last_name like 'S%'
ORDER BY joindate, idI understand the difficulty is probably; even if it does a range scan on every last name 'S%' (assuming it can?), they're not necessarily in order. Case in point:
Last_Name: JoinDate:
Smith 2/5/2010
Smuckers 1/10/2010An index range scan of 'S%' would return them in the above order, which is not ordered by joindate.
So is there any way I can refactor this (query or index) such that the index can be range scanned (using LIKE 'x%') and return rows in the correct order without performing a sort? Or is that simply not possible?xaeryan wrote:
I have a members table with fields such as id, last name, first name, address, join date, etc.
I have a unique index defined on (last_name, join_date, id).
This query will use the index for a range scan, no sort required since the index will be in order for that range ('Smith'):
SELECT members.*
FROM members
WHERE last_name = 'Smith'
ORDER BY joindate, idIs there any way I can get something like the following to use the index (with no sort) as well:
SELECT members.*
FROM members
WHERE last_name like 'S%'
ORDER BY joindate, idI understand the difficulty is probably; even if it does a range scan on every last name 'S%' (assuming it can?), they're not necessarily in order. Case in point:
Last_Name: JoinDate:
Smith 2/5/2010
Smuckers 1/10/2010An index range scan of 'S%' would return them in the above order, which is not ordered by joindate.
So is there any way I can refactor this (query or index) such that the index can be range scanned (using LIKE 'x%') and return rows in the correct order without performing a sort? Or is that simply not possible?Come on. Index column order does matter. "LIKE 'x%'" actually is full table scan. The db engine accesses contiguous index entries and then uses the ROWID values in the index to retrieve the table rows. -
How to write a SQL Query without using group by clause
Hi,
Can anyone help me to find out if there is a approach to build a SQL Query without using group by clause.
Please site an example if is it so,
RegardsI hope this example could illuminate danepc on is problem.
CREATE or replace TYPE MY_ARRAY AS TABLE OF INTEGER
CREATE OR REPLACE FUNCTION GET_ARR return my_array
as
arr my_array;
begin
arr := my_array();
for i in 1..10 loop
arr.extend;
arr(i) := i mod 7;
end loop;
return arr;
end;
select column_value
from table(get_arr)
order by column_value;
select column_value,count(*) occurences
from table(get_arr)
group by column_value
order by column_value;And the output should be something like this:
SQL> CREATE or replace TYPE MY_ARRAY AS TABLE OF INTEGER
2 /
Tipo creato.
SQL>
SQL> CREATE OR REPLACE FUNCTION GET_ARR return my_array
2 as
3 arr my_array;
4 begin
5 arr := my_array();
6 for i in 1..10 loop
7 arr.extend;
8 arr(i) := i mod 7;
9 end loop;
10 return arr;
11 end;
12 /
Funzione creata.
SQL>
SQL>
SQL> select column_value
2 from table(get_arr)
3 order by column_value;
COLUMN_VALUE
0
1
1
2
2
3
3
4
5
6
Selezionate 10 righe.
SQL>
SQL> select column_value,count(*) occurences
2 from table(get_arr)
3 group by column_value
4 order by column_value;
COLUMN_VALUE OCCURENCES
0 1
1 2
2 2
3 2
4 1
5 1
6 1
Selezionate 7 righe.
SQL> Bye Alessandro -
Unable to parse query when using dblink in forms 4.5
Hi,
I have created a query that uses a DBlink because I need to do query on a table located on another dbase. I've used the query on creating my report using Reports 6i. The report needs to be called from a menu on our system, which was developed under Developer 2000 (forms 4.5). The problem is, when I tried to access the report from the menu, it returns the error 'unable to parse query'. What I did after getting error was to create a dummy module using Forms 6i, and call my report from there. It worked fine.
By the way, the table that I'm accessing using the dblink is under Oracle 9i dbase, and the dbase of the system that I've been working at is Oracle 8i.
I don't have any idea on what's causing this error. Is there a compatibility issue when using a dblink located in Oracle 9i database with forms 4.5?
Thanks!Hello,
Not sure if it is the good answer, but I know that Forms does not recognize dblink and owner.object syntax. You have to create a simple synomym that point to the distant object and use this synonym within Forms.
Francois -
WEB BASED MAPPING APPLICATION TO DEVELOP QUERY UTILITY USING MAPVIEWER
Dear Sir,
please any one can answer me as soon as possible its very urgent
WEB BASED MAPPING APPLICATION TO DEVELOP QUERY UTILITY USING MAPVIEWER
I As oracle mapviewer Chapter 8 (Oracle Maps) says generating our own Web based mapping application we are trying to generate our own maps for our own data contains in our layers like example boundary lines and roads and etc. and we are following complete example as described in Oracle Mapviewer Document Chapter 8.
Before this step we tried with demo data downloaded from OTN mvdemo. And we downloaded latest demo today itself from the OTN and imported into our database schema called mvdemo. And we copied all three jar files mvclient and mvconnection and mvpalette into our jdeveloper .
II. We created a jsp to execute the following code from oracle mapviewer chapter 8 documents
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces" prefix="af"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces/customizable" prefix="cust"%>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/jwcache.tld"
prefix="jwcache"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces/html" prefix="afh"%>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/fileaccess.tld"
prefix="fileaccess"%>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/jesitaglib.tld"
prefix="JESI"%>
<f:view>
<html>
<head>
<META http-equiv="Content-Type" content="text/html" charset=UTF-8>
<TITLE>A sample Oracle Maps Application</TITLE>
<script language="Javascript" src="jslib/loadscript.js"></script>
<script language=javascript>
var themebasedfoi=null
function on_load_mapview()
var baseURL = " http://localhost:8888/mapviewer/omserver";
// Create an MVMapView instance to display the map
var mapview = new MVMapView(document.getElementById("map"), baseURL);
// Add a base map layer as background
mapview.addBaseMapLayer(new MVBaseMap("mvdemo.demo_map"));
// Add a theme-based FOI layer to display customers on the map
themebasedfoi = new MVThemeBasedFOI('themebasedfoi1','mvdemo.customers');
themebasedfoi.setBringToTopOnMouseOver(true);
mapview.addThemeBasedFOI(themebasedfoi);
// Set the initial map center and zoom level
mapview.setCenter(MVSdoGeometry.createPoint(-122.45,37.7706,8307));
mapview.setZoomLevel(4);
// Add a navigation panel on the right side of the map
mapview.addNavigationPanel('east');
// Add a scale bar
mapview.addScaleBar();
// Display the map.
mapview.display();
function setLayerVisible(checkBox){
// Show the theme-based FOI layer if the check box is checked and
// hide the theme-based FOI layer otherwise.
if(checkBox.checked)
themebasedfoi.setVisible(true) ;
else
themebasedfoi.setVisible(false);
</script>
</head>
<body onload= javascript:on_load_mapview() >
<h2> A sample Oracle Maps Application</h2>
<INPUT TYPE="checkbox" onclick="setLayerVisible(this)" checked/>Show customers
<div id="map" style="width: 600px; height: 500px"></div>
</body>
</html>
</f:view>
<!--
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=windows-1252"/>
<title>mapPage</title>
</head>
<body><h:form binding="#{backing_mapPage.form1}" id="form1"></h:form></body>
</html>
-->
<%-- oracle-jdev-comment:auto-binding-backing-bean-name:backing_mapPage--%>
III. When we run this jsp it’s giving us following Two errors
1 Error: ‘MVMapView’ is undefined
Code: 0
URL: http://192.168.100.149:8988/MapViewerApp-WebProj-context-root/faces/mapPage.jsp
2 Error: ‘themebasedfoi’ is null or not an object
Code: 0
URL: http://192.168.100.149:8988/MapViewerApp-WebProj-context-root/faces/mapPage.jsp
Please let us know what could be problem as soon as possible. Very urgent
Please let us know where we can find Mapviewer AJAX API’s for Jdeveloper Extention
Thanks
KabeerI currently use parameters, and they are passed from the form to the report. Report is then generated based on a function returning ‘strongly typed’ cursor. The ‘strongly typed’ cursor in my case returns a record consisting of an orderly collection of fields.
This collection of fields is returned by another function that relies on the IF … THEN logic.
However, the number of IF ... THEN statements is quite large (currently 64 covering all possible combinations of 6 parameters available in the form).
I would like to avoid the large number of IF … THEN statements, and hope that there is a way of passing a string to a query, where the Dynamic SQL would in Select close and Where close reflect parameters passed by the form.
In addition to this I would like to avoid creating and populating a table or a view dedicated to the report, because this may lead to a conflict in case of multiple users concurrently generating reports with different choice of parameters.
Edited by: user6883574 on May 28, 2009 9:16 PM -
How to find out Query last used by whom
Dear All,
Can any one tell me that "How to find out the Query last used by whom. I have already searched in SDN but no luck. In my system BW Stats are not installed and I have already checked the below tables.
RSZELTDIR - Directory of the reporting component elements
RSZELTTXT - Texts of reporting component elements
RSZELTXREF - Directory of query element references
RSRREPDIR - Directory of all reports (Query GENUNIID)
RSZCOMPDIR - Directory of reporting components
RSZRANGE - Selection specification for an element
RSZSELECT - Selection properties of an element
RSZELTDIR - Directory of the reporting component elements
RSZCOMPIC - Assignment reuseable component <-> InfoCube
RSZELTPRIO - Priorities with element collisions
RSZELTPROP - Element properties (settings)
RSZELTATTR - Attribute selection per dimension element
RSZCALC - Definition of a formula element
RSZCEL - Query Designer: Directory of Cells
RSZGLOBV - Global Variables in Reporting
RSZCHANGES Change history of reporting components
I am able to find out the Date and time but not the user name. So could you please help on this.
Regards
Sankari think u have missed it.
RSZCOMPDIR IS THE ONLY TABLE WHICH PROVIDES THE DATA.
ENTER TECHNICAL QUERY Name in RSZCOMPDIR-COMPID.
RSZCOMPDIR-TSTNAM gives you the user id of sap bw user who made the change.
RSZCOMPDIR-TSTPDAT gives you date on which change was made .
RSZCOMPDIR-TSTPTIM gives you timestamp on which change was made .
all users details can be obtained from TCODE SU01 where you need to enter sap user id.
You can also get user name( description) by using tcode SE09 and entering above sap user id. -
Combine two reports in query designer using key figure with sap exit
Hi experts,
i want to combine two reports in query designer using key figure with sap exit
in the report 1 key figure calculation based on the open on key date(0P_DATE_OPEN)
to calculate due and not due in two columns
in report 2 key figure calculate in the time zones using given in variable Grid Width (0DPM_BV0) like due in 1 to 30 days, 31 to 60 days...the due amount based on the open on key date(0P_DATE_OPEN)
to calculate in 1-30, 31-60, 61-90, 91-120, 121-150 and >150 days in 6 columns
now i have requirement like this
not due, 1-30, 31-60, >60, due,1-30, 31-60, >60 in 8 columns
or
not due, due, 1-30, 31-60, 61-90, 91-120, 121-150 and >150 in 8 col
thank youHi Dirk,
you perhaps know my requirement,
for the management to make used in one report,
we have in reporting finacials Ehp3.
Vendor Due Date Analysis - which show due, not due
Vendor Overdue Analysis - show only due and analysis in time grid frame
i want to combine in one report that show NOT DUE, DUE, DUE time frames in grid.
krish... -
Convertion of String to XML node using Xquery transformation in OSB
How to convert string to XML node elementusing a built in function using Xquery transformation in OSB?
check this out - http://www.javamonamour.org/2011/06/fn-beainlinedxml.html
if in SOA (BPEL & Mediator) you can use oraext:parseXML.
you should thoroughly analyse where to implement your requirement as some good practices advise to implement more complex logic in SOA and leave OSB to only connect to the services' endpoints.
Hope this helps,
A. -
Invalid column name in query string - using Format function
In my post just before this one the problem was solved for writing a query string using a date range. The rest of the query string includes the same date field (Call_Date) but formatted as 'MMM-YY'. I get an invalid column name error when I add this field to the query string. Here is the rest of the query string:
strSql = "SELECT Format(CALL_DATE,'mmm-yy'), " _
& "HOME_REGION FROM CCC2.CASE_EPRP " _
& "WHERE (HOME_REGION = 'NCR') AND " _
"(CALL_DATE >= to_date( '1/1/2002', 'MM/DD/YYYY' )" _
& "AND CALL_DATE <= to_date( '2/28/2003', 'MM/DD/YYYY' ))"
In the Access Query tool I can include this field
Format(CALL_DATE,'mmm-yy')
and the query runs fine (I just need to make it dynamic using ADO). But in my ADO query string above, I get the invalid column name error. Is there a way I can include
Format(CALL_DATE,'mmm-yy')
in my ADO query string? I appologize for not being more familiar with Oracle Sql. Any help greatly appreciated.
Thanks again,
RichThank you very much for your reply. I think I'm getting closer to the solution. Just I got an error message
"date format not recognized"
when I add "to_char( call_date, 'mmm-yy' )" to the query string. I tried using all uppercase, but that did not make a difference. Do I need to use to_date inside the to_char maybe?
to_char(to_date(call_date, 'mmm/yy'), 'mmm-yy')
Thanks again for your help.
Rich -
Needs help to retrive the last row in a select query without using rownum
Hi ,
i need to retrive the last row from the select sub query without using rownum.
is there any other way to retrive the last row other than the below query.
is that the ROWNUM=1 will always retrive the 1 row of the select query ?
select from*
*(select ename from employee where dept_id=5 order by desc) where rownum=1;*
Please advise.
thanks for your help advance,
regards,
Senthur957595 wrote:
Actually my problem is ithat while selecting the parents hiearchy of the child data using
CONNECT BY PRIOIR query
I need the immediate parent of my child data.
For example my connect BY query returns
AAA --- ROOT
BBB --PARENT -2
CCC --PARENT-1
DDD IS my input child to the connect by query
Immediate parent of my child data "DDD" ---> CCC(parent -1)
i want the data "CCC" from the select query,for that i am taking the last row of the query with rownum.
I got to hear that using ROWNUM to retrive the data will leads to some problem.It is a like a magic number.I am not sure what the problem will be.
So confusing with using this rownum in my query.
Please advice!!!It's not quite clear what you're wanting, but perhaps this may help?
you can select the PRIOR values to get the parent details if you want...
SQL> ed
Wrote file afiedt.buf
1 select empno, lpad(' ',(level-1)*2,' ')||ename as ename, prior empno as mgr
2 from emp
3 connect by mgr = prior empno
4* start with mgr is null
SQL> /
EMPNO ENAME MGR
7839 KING
7566 JONES 7839
7788 SCOTT 7566
7876 ADAMS 7788
7902 FORD 7566
7369 SMITH 7902
7698 BLAKE 7839
7499 ALLEN 7698
7521 WARD 7698
7654 MARTIN 7698
7844 TURNER 7698
7900 JAMES 7698
7782 CLARK 7839
7934 MILLER 7782
14 rows selected.(ok, not the best of examples as the mgr is already known for a row, but it demonstrates you can select prior data) -
SQL Query not using Composite Index
Hi,
Please look at the below query:
SELECT pde.participant_uid
,pde.award_code
,pde.award_type
,SUM(decode(pde.distribution_type
,'FORFEITURE'
,pde.forfeited_quantity *
pde.sold_price * cc.rate
,pde.distributed_quantity *
pde.sold_price * cc.rate)) AS gross_Amt_pref_Curr
FROM part_distribution_exec pde
,currency_conversion cc
,currency off_curr
WHERE pde.participant_uid = 4105
AND off_curr.currency_iso_code =
pde.offering_currency_iso_code
AND cc.from_currency_uid = off_curr.currency_uid
AND cc.to_currency_uid = 1
AND cc.latest_flag = 'Y'
GROUP BY pde.participant_uid
,pde.award_code
,pde.award_type
In oracle 9i, i"ve executed this above query, it takes 6 seconds and the cost is 616, this is due to non usage of the composite index, Currency_conversion_idx(From_currency_uid, To_currency_uid, Latest_flag). I wonder why this index is not used while executing the above query. So, I've dropped the index and recreated it. Now, the query is using this index. After inserting many rows or say in 1 days time, if the same query is executed, again the query is not using the index. So everyday, the index should be dropped and recreated.
I don't want this drop and recreation of index daily, I need a permanent solution for this.
Can anyone tell me, Why this index goes stale after a period of time???? Please take some time and Solve this issue.
-SankarHi David,
This is Sankar here. Thankyou for your reply.
I've got the plan table output for this problematic query, please go thro' it and help me out why the index CURRENCY_CONVERSION_IDX is used now and why it's not using while executing the query after a day or inserting some records...
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 26 | 15678 | 147 |
| 1 | TABLE ACCESS BY INDEX ROWID | PART_AWARD_PAYOUT_SCHEDULE | 1 | 89 | 2 |
|* 2 | INDEX UNIQUE SCAN | PART_AWARD_PAYOUT_SCHEDULE_PK1 | 61097 | | 1 |
| 3 | SORT AGGREGATE | | 1 | 67 | |
|* 4 | FILTER | | | | |
|* 5 | INDEX RANGE SCAN | PART_AWARD_PAYOUT_SCHEDULE_PK1 | 1 | 67 | 2 |
| 6 | SORT AGGREGATE | | 1 | 94 | |
|* 7 | FILTER | | | | |
|* 8 | TABLE ACCESS BY INDEX ROWID | PART_AWARD_PAYOUT_SCHEDULE | 1 | 94 | 3 |
|* 9 | INDEX RANGE SCAN | PART_AWARD_PAYOUT_SCHEDULE_PK1 | 1 | | 2 |
|* 10 | FILTER | | | | |
|* 11 | HASH JOIN | | 26 | 15678 | 95 |
|* 12 | HASH JOIN OUTER | | 26 | 11596 | 91 |
|* 13 | HASH JOIN | | 26 | 10218 | 86 |
| 14 | VIEW | | 1 | 82 | 4 |
| 15 | SORT GROUP BY | | 1 | 116 | 4 |
|* 16 | TABLE ACCESS BY INDEX ROWID | PART_AWARD_LEDGER | 1 | 116 | 2 |
|* 17 | INDEX RANGE SCAN | PARTICIPANT_UID_IDX | 1 | | 1 |
|* 18 | HASH JOIN OUTER | | 26 | 8086 | 82 |
|* 19 | HASH JOIN | | 26 | 6006 | 71 |
| 20 | NESTED LOOPS | | 36 | 5904 | 66 |
| 21 | NESTED LOOPS | | 1 | 115 | 65 |
| 22 | TABLE ACCESS BY INDEX ROWID | CURRENCY_CONVERSION | 18 | 756 | 2 |
|* 23 | INDEX RANGE SCAN | KLS_IDX_CURRENCY_CONV | 3 | | 1 |
| 24 | VIEW | | 1 | 73 | 4 |
| 25 | SORT GROUP BY | | 1 | 71 | 4 |
| 26 | TABLE ACCESS BY INDEX ROWID| PART_AWARD_VALUE | 1 | 71 | 2 |
|* 27 | INDEX RANGE SCAN | PAV_PARTICIPANT_UID_IDX | 1 | | 1 |
| 28 | TABLE ACCESS BY INDEX ROWID | PARTICIPANT_AWARD | 199 | 9751 | 1 |
|* 29 | INDEX UNIQUE SCAN | PARTICIPANT_AWARD_PK1 | 100 | | |
|* 30 | INDEX FAST FULL SCAN | PARTICIPANT_AWARD_TYPE_PK1 | 147 | 9849 | 4 |
| 31 | VIEW | | 1 | 80 | 10 |
| 32 | SORT GROUP BY | | 1 | 198 | 10 |
|* 33 | TABLE ACCESS BY INDEX ROWID | CURRENCY_CONVERSION | 1 | 42 | 2 |
| 34 | NESTED LOOPS | | 1 | 198 | 8 |
| 35 | NESTED LOOPS | | 2 | 312 | 4 |
| 36 | TABLE ACCESS BY INDEX ROWID| PART_DISTRIBUTION_EXEC | 2 | 276 | 2 |
|* 37 | INDEX RANGE SCAN | IND_PARTICIPANT_UID | 1 | | 1 |
| 38 | TABLE ACCESS BY INDEX ROWID| CURRENCY | 1 | 18 | 1 |
|* 39 | INDEX UNIQUE SCAN | CURRENCY_AK | 1 | | |
|* 40 | INDEX RANGE SCAN | CURRENCY_CONVERSION_AK | 2 | | 1 |
| 41 | VIEW | | 1 | 53 | 4 |
| 42 | SORT GROUP BY | | 1 | 62 | 4 |
|* 43 | TABLE ACCESS BY INDEX ROWID | PART_AWARD_VESTING | 1 | 62 | 2 |
|* 44 | INDEX RANGE SCAN | PAVES_PARTICIPANT_UID_IDX | 1 | | 1 |
| 45 | TABLE ACCESS FULL | AWARD | 1062 | 162K| 3 |
| 46 | TABLE ACCESS BY INDEX ROWID | CURRENCY | 1 | 18 | 2 |
|* 47 | INDEX UNIQUE SCAN | CURRENCY_AK | 102 | | 1 |
Predicate Information (identified by operation id):
2 - access("PAPS"."AWARD_CODE"=:B1 AND "PAPS"."PARTICIPANT_UID"=4105 AND "PAPS"."AWARD_TYPE"=:B2
"PAPS"."INSTALLMENT_NUM"=1)
4 - filter(4105=:B1)
5 - access("PAPS"."AWARD_CODE"=:B1 AND "PAPS"."PARTICIPANT_UID"=4105 AND "PAPS"."AWARD_TYPE"=:B2)
7 - filter(4105=:B1)
8 - filter("PAPS"."STATUS"='OPEN')
9 - access("PAPS"."AWARD_CODE"=:B1 AND "PAPS"."PARTICIPANT_UID"=4105 AND "PAPS"."AWARD_TYPE"=:B2)
10 - filter("CC_A_P_CURR"."FROM_CURRENCY_UID"= (SELECT /*+ */ "CURRENCY"."CURRENCY_UID" FROM
"EWAPDBO"."CURRENCY" "CURRENCY" WHERE "CURRENCY"."CURRENCY_ISO_CODE"=:B1))
11 - access("SYS_ALIAS_7"."AWARD_CODE"="A"."AWARD_CODE")
12 - access("SYS_ALIAS_7"."AWARD_CODE"="PVS"."AWARD_CODE"(+))
13 - access("SYS_ALIAS_8"."AWARD_CODE"="PALS"."AWARD_CODE" AND
"SYS_ALIAS_8"."AWARD_TYPE"="PALS"."AWARD_TYPE")
16 - filter(TRUNC("PAL1"."LEDGER_ENTRY_DATE")<=TRUNC(SYSDATE@!) AND "PAL1"."ALLOC_TYPE"='IPU')
17 - access("PAL1"."PARTICIPANT_UID"=4105)
filter("PAL1"."PARTICIPANT_UID"=4105)
18 - access("SYS_ALIAS_8"."AWARD_CODE"="PDES"."AWARD_CODE"(+) AND
"SYS_ALIAS_8"."AWARD_TYPE"="PDES"."AWARD_TYPE"(+))
19 - access("SYS_ALIAS_7"."AWARD_CODE"="SYS_ALIAS_8"."AWARD_CODE")
23 - access("CC_A_P_CURR"."TO_CURRENCY_UID"=1 AND "CC_A_P_CURR"."LATEST_FLAG"='Y')
27 - access("PAV"."PARTICIPANT_UID"=4105)
filter("PAV"."PARTICIPANT_UID"=4105)
29 - access("SYS_ALIAS_7"."AWARD_CODE"="SYS_ALIAS_9"."AWARD_CODE" AND
"SYS_ALIAS_7"."PARTICIPANT_UID"=4105)
30 - filter("SYS_ALIAS_8"."PARTICIPANT_UID"=4105)
33 - filter("CC"."LATEST_FLAG"='Y')
37 - access("PDE"."PARTICIPANT_UID"=4105)
filter("PDE"."PARTICIPANT_UID"=4105)
39 - access("OFF_CURR"."CURRENCY_ISO_CODE"="PDE"."OFFERING_CURRENCY_ISO_CODE")
40 - access("CC"."FROM_CURRENCY_UID"="OFF_CURR"."CURRENCY_UID" AND "CC"."TO_CURRENCY_UID"=1)
43 - filter("PV"."VESTING_DATE"<=SYSDATE@!)
44 - access("PV"."PARTICIPANT_UID"=4105)
filter("PV"."PARTICIPANT_UID"=4105)
47 - access("CURRENCY"."CURRENCY_ISO_CODE"=:B1)
Note: cpu costing is off
93 rows selected.
Please help me out...
-Sankar -
Hi guys,
I'm trying to logical database MSM to report on material master but for some reason the following message appears:
The query specifications cannot be used to generate a list,
i.e. the query will probably not return the list you desire.
If you still want to execute the query, please use the
"Generate" function.
Errors are like this :
Fields from parallel tables within a line
Line: 01
Field: Post to Inspection Stock
(MARCV-INSMK, table MARCV)
Field: Item category group from material master
(MVKE-MTPOS, table MVKE)
Any idea what is the reason why this happens?
Thanks and regards
Stefan
Edited by: Stefan Tzandev on Sep 15, 2008 1:44 PMHey Stefan,
I know this is a long shot, but were you able to figure it out. I am having the same problem as we speak. I tried rearanging the fields according to the heirchy, it now works, but has a really bad output. Hope to hear from you.
Best Regards,
Matthew Ong
Maybe you are looking for
-
I want to make a class that can detect these. How do I do this? I was thinking of using implementation of a Listener class but I'm not sure which and I'm not sure how.
-
I have seen similar questions--mostly from 4-6 years ago--but none are quite the same as mine. I tried to export a photo from the web to iPhoto for editing and received a message stating, "Which photo library do you want iPhoto to use? To open, iPho
-
ThinkCentre E73z integrated camera cannot be used in Skype
Hi, I have just finished the complete updating of the preinstalled windows7 professional on my new ThinkCentre E73z. This is the first use. I'm very disappointed. When I installed Skype it says that Skype can't detect any Webcam. They offer to buy on
-
[JS CS3]linking inline textframes
Hi, I've got an inline textframe with overflowing text, but this VG.myFirstTextFrame.nextTextFrame =VG.myNewFrame; doesn't work for some reason, well, I can't manage to link the overset textframe to another frame by hand by clicking on the red plus e
-
Ipod will not restore it times out
My son locked himself out of his ipod and I am attempting to restore it. I finally got itunes to recognize the ipod in restore mode. The problem is that during the software uodate download everthing times out and it asks for the passcode which I ob