Dude, this query is frightening the children
We're using PlumBEALogicAquaWebCenterTree 6.1 on Oracle 10g on Solaris. This query is taking 11+ seconds to run. (It gets faster after the first time due to DB-level caching.) We only have about 20,000 users and around 250 communities. PTVGroupMembership has just under 1.4 million rows in it, which seems a little high for a portal of this size. Anyway, here's the scary query:
'/* MYPAGES_COMMUNITY_QUERY_AVAILABLE:ANSI */ SELECT c.Name, c.IsLocalized, c.ObjectID FROM PTComm
unities c, (SELECT DISTINCT c.ObjectID FROM PTCommunities c, PTCommSecurity cs, PTVGroupMembership gm WHERE cs.ObjectID=c.ObjectID AND c
s.ClassID=512 AND ((cs.GroupID=?) OR (gm.UserID=? AND cs.GroupID=gm.GroupID )) AND c.ObjectID NOT IN (SELECT c.ObjectID FROM PTCommunit
ies c, PTMyCommunities mc, PTCommSecurity cs, PTVGroupMembership gm WHERE c.ObjectID=mc.CommunityID AND cs.ObjectID=c.ObjectID AND cs.Cl
assID=512 AND ((mc.GroupID=? AND cs.GroupID=gm.GroupID AND gm.UserID=-mc.GroupID) OR (mc.GroupID=gm.GroupID AND gm.UserID=? AND cs.Grou
pID=gm.GroupID ))) ) tmp WHERE tmp.ObjectID=c.ObjectID ORDER BY LOWER(c.Name)'
This happens when people log into to the portal and display the home community. The use case: someone doesn't use the portal for a while, then they log in and it takes 15+ seconds, then they give up and never come back. Problem solved! They never use our system again because it's slower than a dog trapped in a La Brea tar pit. Oh yeah, and did I mention that the dog has no legs?
I'd like to talk to the person who wrote this query, but I've already called the three developers from Plumtree who still work at Oracle and all three of them vehemently denied writing this nasty bit of SQL. (I would have done the same thing if it were my query.)
Any suggestions?
We figured out that adding the part in bold makes the query run in .06 seconds. That's a big improvement from 11 seconds (or more):
'/* MYPAGES_COMMUNITY_QUERY_AVAILABLE:ANSI */ SELECT c.Name, c.IsLocalized, c.ObjectID FROM PTComm
unities c, (SELECT DISTINCT c.ObjectID FROM PTCommunities c, PTCommSecurity cs, PTVGroupMembership gm WHERE cs.ObjectID=c.ObjectID AND c
s.ClassID=512 AND ((cs.GroupID=? and gm.UserID IS NULL ) OR (gm.UserID=? AND cs.GroupID=gm.GroupID )) AND c.ObjectID NOT IN (SELECT c.ObjectID FROM PTCommunit
ies c, PTMyCommunities mc, PTCommSecurity cs, PTVGroupMembership gm WHERE c.ObjectID=mc.CommunityID AND cs.ObjectID=c.ObjectID AND cs.Cl
assID=512 AND ((mc.GroupID=? AND cs.GroupID=gm.GroupID AND gm.UserID=-mc.GroupID) OR (mc.GroupID=gm.GroupID AND gm.UserID=? AND cs.Grou
pID=gm.GroupID ))) ) tmp WHERE tmp.ObjectID=c.ObjectID ORDER BY LOWER(c.Name)'
Now the question is . . . do we wait for months (or years) for a patch or just hack the change in ourselves?
Similar Messages
-
Why is this query not using the index?
check out this query:-
SELECT CUST_PO_NUMBER, HEADER_ID, ORDER_TYPE, PO_DATE
FROM TABLE1
WHERE STATUS = 'N'
and here's the explain plan:-
1
2 -------------------------------------------------------------------------------------
3 | Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
4 -------------------------------------------------------------------------------------
5 | 0 | SELECT STATEMENT | | 2735K| 140M| 81036 (2)|
6 |* 1 | TABLE ACCESS FULL| TABLE1 | 2735K| 140M| 81036 (2)|
7 -------------------------------------------------------------------------------------
8
9 Predicate Information (identified by operation id):
10 ---------------------------------------------------
11
12 1 - filter("STATUS"='N')
There is already an index on this column, as is shown below:-
INDEX_NAME INDEX_TYPE UNIQUENESS TABLE_NAME COLUMN_NAME COLUMN_POSITION
1 TABLE1_IDX2 NORMAL NONUNIQUE TABLE1 STATUS 1
2 TABLE1_IDX NORMAL NONUNIQUE TABLE1 HEADER_ID 1
So why is this query not using the index on the 'STATUS' Column?
I've already tried using optimizer hints and regathering the stats on the table, but the execution plan still remains the same, i.e. it still uses a FTS.
I have tried this command also:-
exec dbms_stats.gather_table_stats('GECS','GEPS_CS_SALES_ORDER_HEADER',method_opt=>'for all indexed columns size auto',cascade=>true,degree=>4);
inspite of this, the query is still using a full table scan.
The table has around 55 Lakh records, across 60 columns. And because of the FTS, the query is taking a long time to execute. How do i make it use the index?
Please help.
Edited by: user10047779 on Mar 16, 2010 6:55 AMIf the cardinality is really as skewed as that, you may want to look at putting a histogram on the column (sounds like it would be in order, and that you don't have one).
create table skewed_a_lot
as
select
case when mod(level, 1000) = 0 then 'N' else 'Y' end as Flag,
level as col1
from dual connect by level <= 1000000;
create index skewed_a_lot_i01 on skewed_a_lot (flag);
exec dbms_stats.gather_table_stats(user, 'SKEWED_A_LOT', cascade => true, method_opt => 'for all indexed columns size auto');Is an example. -
Can you please explain how this query is fetching the rows?
here is a query to find the top 3 salaries. But the thing is that i am now able to understand how its working to get the correct data :How the data in the alias table P1 and P2 getting compared. Can you please explain in some steps.
SELECT MIN(P1.SAL) FROM PSAL P1, PSAL P2
WHERE P1.SAL >= P2.SAL
GROUP BY P2.SAL
HAVING COUNT (DISTINCT P1.SAL) <=3 ;
here is the data i used :
SQL> select * from psal;
NAME SAL
able 1000
baker 900
charles 900
delta 800
eddy 700
fred 700
george 700
george 700
Regards,
Renu... Please help me in understanding the query.
Your query looks like anything but a Top-N query.
If you run it in steps and analyze the output at the end of each step, then you should be able to understand what it does.
Given below is some brief information on the same:
test@ora>
test@ora> --
test@ora> -- Query 1 - using the non-equi (theta) join
test@ora> --
test@ora> with psal as (
2 select 'able' as name, 1000 as sal from dual union all
3 select 'baker', 900 from dual union all
4 select 'charles', 900 from dual union all
5 select 'delta', 800 from dual union all
6 select 'eddy', 700 from dual union all
7 select 'fred', 700 from dual union all
8 select 'george', 700 from dual union all
9 select 'george', 700 from dual)
10 --
11 SELECT p1.sal AS p1_sal, p1.NAME AS p1_name, p2.sal AS p2_sal,
12 p2.NAME AS p2_name
13 FROM psal p1, psal p2
14 WHERE p1.sal >= p2.sal;
P1_SAL P1_NAME P2_SAL P2_NAME
1000 able 1000 able
1000 able 900 baker
1000 able 900 charles
1000 able 800 delta
1000 able 700 eddy
1000 able 700 fred
1000 able 700 george
1000 able 700 george
900 baker 900 baker
900 baker 900 charles
900 baker 800 delta
900 baker 700 eddy
900 baker 700 fred
900 baker 700 george
900 baker 700 george
900 charles 900 baker
900 charles 900 charles
900 charles 800 delta
900 charles 700 eddy
900 charles 700 fred
900 charles 700 george
900 charles 700 george
800 delta 800 delta
800 delta 700 eddy
800 delta 700 fred
800 delta 700 george
800 delta 700 george
700 eddy 700 eddy
700 eddy 700 fred
700 eddy 700 george
700 eddy 700 george
700 fred 700 eddy
700 fred 700 fred
700 fred 700 george
700 fred 700 george
700 george 700 eddy
700 george 700 fred
700 george 700 george
700 george 700 george
700 george 700 eddy
700 george 700 fred
700 george 700 george
700 george 700 george
43 rows selected.
test@ora>
test@ora>This query joins PSAL with itself using a non equi-join. Take each row of PSAL p1 and see how it compares with PSAL p2. You'll see that:
- Row 1 with sal 1000 is >= to all sal values of p2, so it occurs 8 times
- Row 2 with sal 900 is >= to 9 sal values of p2, so it occurs 7 times
- Row 3: 7 times again... and so on.
- So, total no. of rows are: 8 + 7 + 7 + 5 + 4 + 4 + 4 + 4 = 43
test@ora>
test@ora> --
test@ora> -- Query 2 - add the GROUP BY
test@ora> --
test@ora> with psal as (
2 select 'able' as name, 1000 as sal from dual union all
3 select 'baker', 900 from dual union all
4 select 'charles', 900 from dual union all
5 select 'delta', 800 from dual union all
6 select 'eddy', 700 from dual union all
7 select 'fred', 700 from dual union all
8 select 'george', 700 from dual union all
9 select 'george', 700 from dual)
10 --
11 SELECT p2.sal AS p2_sal,
12 COUNT(*) as cnt,
13 COUNT(p1.sal) as cnt_p1_sal,
14 COUNT(DISTINCT p1.sal) as cnt_dist_p1_sal,
15 MIN(p1.sal) as min_p1_sal,
16 MAX(p1.sal) as max_p1_sal
17 FROM psal p1, psal p2
18 WHERE p1.sal >= p2.sal
19 GROUP BY p2.sal;
P2_SAL CNT CNT_P1_SAL CNT_DIST_P1_SAL MIN_P1_SAL MAX_P1_SAL
700 32 32 4 700 1000
800 4 4 3 800 1000
900 6 6 2 900 1000
1000 1 1 1 1000 1000
test@ora>
test@ora>Now, if you group by p2.sal in the output of query 1, and check the number of distinct p1.sal, min of p1.sal etc. you see that for p2.sal values - 800, 900 and 1000, there are 3 or less p1.sal values associated.
So, the last 3 rows are the ones you are interested in, essentially. As follows:
test@ora>
test@ora> --
test@ora> -- Query 3 - GROUP BY and HAVING
test@ora> --
test@ora> with psal as (
2 select 'able' as name, 1000 as sal from dual union all
3 select 'baker', 900 from dual union all
4 select 'charles', 900 from dual union all
5 select 'delta', 800 from dual union all
6 select 'eddy', 700 from dual union all
7 select 'fred', 700 from dual union all
8 select 'george', 700 from dual union all
9 select 'george', 700 from dual)
10 --
11 SELECT p2.sal AS p2_sal,
12 COUNT(*) as cnt,
13 COUNT(p1.sal) as cnt_p1_sal,
14 COUNT(DISTINCT p1.sal) as cnt_dist_p1_sal,
15 MIN(p1.sal) as min_p1_sal,
16 MAX(p1.sal) as max_p1_sal
17 FROM psal p1, psal p2
18 WHERE p1.sal >= p2.sal
19 GROUP BY p2.sal
20 HAVING COUNT(DISTINCT p1.sal) <= 3;
P2_SAL CNT CNT_P1_SAL CNT_DIST_P1_SAL MIN_P1_SAL MAX_P1_SAL
800 4 4 3 800 1000
900 6 6 2 900 1000
1000 1 1 1 1000 1000
test@ora>
test@ora>
test@ora>That's what you are doing in that query.
The thing is - in order to find out Top-N values, you simply need to scan that one table PSAL. So, joining it to itself is not necessary.
A much simpler query is as follows:
test@ora>
test@ora>
test@ora> --
test@ora> -- Top-3 salaries - distinct or not; using ROWNUM on ORDER BY
test@ora> --
test@ora> with psal as (
2 select 'able' as name, 1000 as sal from dual union all
3 select 'baker', 900 from dual union all
4 select 'charles', 900 from dual union all
5 select 'delta', 800 from dual union all
6 select 'eddy', 700 from dual union all
7 select 'fred', 700 from dual union all
8 select 'george', 700 from dual union all
9 select 'george', 700 from dual)
10 --
11 SELECT sal
12 FROM (
13 SELECT sal
14 FROM psal
15 ORDER BY sal DESC
16 )
17 WHERE rownum <= 3;
SAL
1000
900
900
test@ora>
test@ora>
test@ora>And for Top-3 distinct salaries:
test@ora>
test@ora> --
test@ora> -- Top-3 DISTINCT salaries; using ROWNUM on ORDER BY on DISTINCT
test@ora> --
test@ora> with psal as (
2 select 'able' as name, 1000 as sal from dual union all
3 select 'baker', 900 from dual union all
4 select 'charles', 900 from dual union all
5 select 'delta', 800 from dual union all
6 select 'eddy', 700 from dual union all
7 select 'fred', 700 from dual union all
8 select 'george', 700 from dual union all
9 select 'george', 700 from dual)
10 --
11 SELECT sal
12 FROM (
13 SELECT DISTINCT sal
14 FROM psal
15 ORDER BY sal DESC
16 )
17 WHERE rownum <= 3;
SAL
1000
900
800
test@ora>
test@ora>
test@ora>You may also want to check out the RANK and DENSE_RANK analytic functions.
RANK:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions123.htm#SQLRF00690
DENSE_RANK:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions043.htm#SQLRF00633
HTH
isotope -
How to modify this query to get the desired output format
I hv written a Query to display all the parent table names and their primary key columns(relevant to this foreign key of the child table).The query is given below...
SELECT DISTINCT(TABLE_NAME) AS PARENT_TABLE,COLUMN_NAME AS PARENT_COLUMN
FROM ALL_CONS_COLUMNS
WHERE CONSTRAINT_NAME IN (SELECT AC.R_CONSTRAINT_NAME
FROM ALL_CONSTRAINTS AC
WHERE AC.TABLE_NAME=TABLE_NAME
AND AC.TABLE_NAME='&TABLE'
AND AC.R_CONSTRAINT_NAME IS NOT NULL);
This query will display all the parent tables and their primary key columns.Now my problem is that how to modify this query to also display the foreign key column name of the child table.
I want the query result in the following format.The query should display the following columns.1)child table's name,2)child table's foreign key column name,3)the corresponding parent table's name,4)the parent table's primary key column name(which is the foreign key in the child table).
For Example I want the output as follows...
TAKE THE CASE OF SCOTT.EMP(AS INPUT TO YOUR QUERY)
CHILD_TABLE CHILD_COLUMN PARENT_TABLE PARENT_COLUMN
EMP DEPTNO DEPT DEPTNO
In this result I hv used alias name for the columns.The query should display this only for the foreign keys in the child table.In the query which I sent to you earlier will give the parent table and the parent column names,But I also want to append the child table and child column names there.
any help on how to tackle would be appreciated.Try this query
SELECT c.table_name child_table,
c.column_name child_column,
p.table_name parent_table,
p.column_name parent_column
FROM user_constraints a,user_constraints b,user_cons_columns c,
user_cons_columns p
WHERE a.r_constraint_name=b.constraint_name and
a.constraint_name=c.constraint_name and
b.constraint_name=p.constraint_name and
c.position=p.position
ORDER BY c.constraint_name,c.position
Anwar -
Is this query on XMLTYPE the most performant ?
Hello,
We are in 11gR2
and we built a process for loading XML files that I think are very complex (I hope so)
We about about 600 similar XML files to load every night.
The XML file is saved under a XMLTYPE table and we attached a XSD Schema on it.
One of the queries we built for selecting XMLTYPE data uses several outer joins on the XML. And I think I should find a way for increasing performance on the query
Here is the details (sometimes huge in volume) :
1) The query I would like to improve :
Depending on data in the XML file, the SELECT duration can go from 3 minutes to more than 4 hours !
select DISTINCT UPPER(t2.ressource_code)
, CASE WHEN ( t5.isWorkDay = 'false' AND t5.day IS NOT NULL
AND ( to_date( replace(t5.day, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS')
BETWEEN to_date( replace(t4.taux_start_date, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS')
AND to_date( replace(t4.taux_end_date, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS'))
THEN to_date( replace(t5.day, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS')
ELSE to_date( replace(t4.taux_start_date, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS') END day_start
, CASE WHEN ( t5.isWorkDay = 'false' AND t5.day IS NOT NULL
AND ( to_date( replace(t5.day, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS')
BETWEEN to_date( replace(t4.taux_start_date, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS')
AND to_date( replace(t4.taux_end_date, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS'))
THEN to_date( replace(t5.day, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS')+1
ELSE to_date( replace(t4.taux_end_date, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS') END day_finish
, DECODE( t5.isWorkDay, NULL, CASE WHEN (to_number( t4.rate)>0) THEN 'true' ELSE 'false' END, t5.isWorkDay) isWorkDay
, DECODE( t5.isWorkDay, NULL, TO_CHAR( to_date( replace(t4.taux_start_date, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS'), 'HH24:MI:SS'), t6.shift_start) shift_start
, DECODE( t5.isWorkDay, NULL, TO_CHAR( to_date( replace(t4.taux_end_date, 'T', ' '), 'YYYY-MM-DD HH24:MI:SS'), 'HH24:MI:SS'), t6.shift_finish) shift_finish
, DECODE( UPPER(t5.dayOfWeek), 'MON', 'LUNDI', 'TUE', 'MARDI', 'WED', 'MERCREDI', 'THU', 'JEUDI', 'FRI', 'VENDREDI', 'SAT', 'SAMEDI', 'SUN', 'DIMANCHE', NULL, NULL) dayOfWeek
, SYSDATE
, t1.tache_uid, t1.tache_code, t1.tache_desc
, t3.curve_name
, to_number( t4.rate) activity
FROM WORKBENCH_PROJECT_TABLE t
, xmltable( xmlNamespaces( default 'http://www.oracle.com/xsd/projet.xsd')
, '/WORKBENCH_PROJECT/Projects/Project/Tasks/Task' passing OBJECT_VALUE
columns tache_UID varchar2(70) path '@UID'
, tache_code varchar2(150) path '@taskID'
, tache_desc varchar2(150) path '@name'
, activites_xml xmltype path 'Assignments'
) t1
, xmltable( xmlNamespaces( default 'http://www.oracle.com/xsd/projet.xsd')
, '/Assignments/*' passing t1.activites_xml
columns ressource_code varchar2(50) path '@resourceID'
, curves_xml xmltype path 'Curve'
) t2
, xmltable( xmlNamespaces( default 'http://www.oracle.com/xsd/projet.xsd')
, '/Curve' passing t2.curves_xml
columns curve_name varchar2(50) path '@name'
, segments_xml xmltype path 'Segments'
) t3
, xmltable( xmlNamespaces( default 'http://www.oracle.com/xsd/projet.xsd')
, '/Segments/*' passing t3.segments_xml
columns rate varchar2(50) path '@rate'
, taux_start_date varchar2(20) path '@start'
, taux_end_date varchar2(20) path '@finish'
, calendar_days_xml xmltype path 'Calendar/Days'
) t4
, xmltable( xmlNamespaces( default 'http://www.oracle.com/xsd/projet.xsd')
, '/Days/*' passing t4.calendar_days_xml
columns dayOfWeek varchar2(50) path '@dayOfWeek'
, isWorkDay varchar2(20) path '@isWorkDay'
, DAY varchar2(20) path '@start'
, shift_xml xmltype path 'Shifts'
) (+) t5
, xmltable( xmlNamespaces( default 'http://www.oracle.com/xsd/projet.xsd')
, 'Shifts/Shift' passing t5.shift_xml
columns shift_start varchar2(20) path '@start'
, shift_finish varchar2(20) path '@finish'
) (+) t6; Here is the XSD schema :
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb"
xmlns="http://www.oracle.com/xsd/projet.xsd"
targetNamespace="http://www.oracle.com/xsd/projet.xsd"
elementFormDefault="unqualified"
xdb:storeVarrayAsTable="true">
<xsd:element name="WORKBENCH_PROJECT" xdb:defaultTable="WORKBENCH_PROJECT_TABLE">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="BaseCalendars"/>
<xsd:element ref="PoolResources"/>
<xsd:element ref="Projects"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="BaseCalendars" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Calendar" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="PoolResources" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="PoolResource" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="PoolResource" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Calendar"/>
<xsd:element ref="Curve"/>
<xsd:element ref="Notes" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="category" type="xsd:string"/>
<xsd:attribute name="emailAddress" type="xsd:string"/>
<xsd:attribute name="employmentType" type="xsd:integer"/>
<xsd:attribute name="description" type="xsd:string"/>
<xsd:attribute name="firstName" type="xsd:string"/>
<xsd:attribute name="fullName" type="xsd:string"/>
<xsd:attribute name="hireDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="inputTypeCode" type="xsd:integer"/>
<xsd:attribute name="isActive" type="xsd:boolean"/>
<xsd:attribute name="isExternal" type="xsd:boolean"/>
<xsd:attribute name="isRole" type="xsd:boolean"/>
<xsd:attribute name="lastName" type="xsd:string"/>
<xsd:attribute name="managerUserName" type="xsd:string"/>
<xsd:attribute name="modBy" type="xsd:string"/>
<xsd:attribute name="openForTimeEntry" type="xsd:boolean"/>
<xsd:attribute name="resourceId" type="xsd:string"/>
<xsd:attribute name="resourceType" type="xsd:integer"/>
<xsd:attribute name="roleID" type="xsd:string"/>
<xsd:attribute name="terminationDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="trackMode" type="xsd:integer"/>
<xsd:attribute name="userFlag1" type="xsd:boolean"/>
<xsd:attribute name="userFlag2" type="xsd:boolean"/>
<xsd:attribute name="userNumber1" type="xsd:decimal"/>
<xsd:attribute name="userNumber2" type="xsd:decimal"/>
<xsd:attribute name="userText1" type="xsd:string"/>
<xsd:attribute name="userText2" type="xsd:string"/>
<xsd:attribute name="userText3" type="xsd:string"/>
<xsd:attribute name="userText4" type="xsd:string"/>
<xsd:attribute name="userText5" type="xsd:string"/>
<xsd:attribute name="userText6" type="xsd:string"/>
<xsd:attribute name="userText7" type="xsd:string"/>
<xsd:attribute name="userText8" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Projects" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Project" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Project" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Baselines" minOccurs="0"/>
<xsd:element ref="Notes" minOccurs="0"/>
<xsd:element ref="Resources" minOccurs="0"/>
<xsd:element ref="Tasks" minOccurs="0"/>
<xsd:element ref="BaselineDetails" minOccurs="0"/>
<xsd:element ref="Dependencies" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="UID"/>
<xsd:attribute name="active" type="xsd:boolean"/>
<xsd:attribute name="asOf" type="xsd:NMTOKEN"/>
<xsd:attribute name="approved" type="xsd:boolean"/>
<xsd:attribute name="baseFinish" type="xsd:NMTOKEN"/>
<xsd:attribute name="baseStart" type="xsd:NMTOKEN"/>
<xsd:attribute name="baseTime" type="xsd:NMTOKEN"/>
<xsd:attribute name="budget" type="xsd:double"/>
<xsd:attribute name="closed" type="xsd:boolean"/>
<xsd:attribute name="cpmType" type="xsd:integer"/>
<xsd:attribute name="department" type="xsd:string"/>
<xsd:attribute name="description" type="xsd:string"/>
<xsd:attribute name="finish" type="xsd:NMTOKEN"/>
<xsd:attribute name="finishImposed" type="xsd:boolean"/>
<xsd:attribute name="format" type="xsd:integer"/>
<xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
<xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="openForTimeEntry" type="xsd:boolean"/>
<xsd:attribute name="priority" type="xsd:integer"/>
<xsd:attribute name="projectType" type="xsd:integer"/>
<xsd:attribute name="program" type="xsd:boolean"/>
<xsd:attribute name="projectID" type="xsd:string"/>
<xsd:attribute name="start" type="xsd:NMTOKEN"/>
<xsd:attribute name="startImposed" type="xsd:boolean"/>
<xsd:attribute name="status" type="xsd:integer"/>
<xsd:attribute name="trackMode" type="xsd:integer"/>
<xsd:attribute name="userText1" type="xsd:string"/>
<xsd:attribute name="userText2" type="xsd:string"/>
<xsd:attribute name="userText3" type="xsd:string"/>
<xsd:attribute name="userText4" type="xsd:string"/>
<xsd:attribute name="userText5" type="xsd:string"/>
<xsd:attribute name="userText6" type="xsd:string"/>
<xsd:attribute name="userText7" type="xsd:string"/>
<xsd:attribute name="userText8" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Baselines" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Baseline" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Baseline" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:attribute name="code" type="xsd:string"/>
<xsd:attribute name="current" type="xsd:boolean"/>
<xsd:attribute name="description"/>
<xsd:attribute name="name" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Resources" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Resource" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Resource" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Curve" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="BaselineDetails" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="availFrom" type="xsd:NMTOKEN"/>
<xsd:attribute name="availTo" type="xsd:NMTOKEN"/>
<xsd:attribute name="bookingStatus" type="xsd:integer"/>
<xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
<xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="openForTimeEntry" type="xsd:boolean"/>
<xsd:attribute name="requestStatus" type="xsd:integer"/>
<xsd:attribute name="resourceID" type="xsd:string"/>
<xsd:attribute name="roleID" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Tasks" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Task" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Task" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Assignments" minOccurs="0"/>
<xsd:element ref="BaselineDetails" minOccurs="0"/>
<xsd:element ref="Constraints" minOccurs="0"/>
<xsd:element ref="Notes" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="UID"/>
<xsd:attribute name="taskID" type="xsd:string"/>
<xsd:attribute name="baseFinish" type="xsd:NMTOKEN"/>
<xsd:attribute name="baseStart" type="xsd:NMTOKEN"/>
<xsd:attribute name="baseTime" type="xsd:NMTOKEN"/>
<xsd:attribute name="baselineDuration" type="xsd:decimal"/>
<xsd:attribute name="category" type="xsd:string"/>
<xsd:attribute name="critical" type="xsd:boolean"/>
<xsd:attribute name="earlyFinish" type="xsd:NMTOKEN"/>
<xsd:attribute name="earlyStart" type="xsd:NMTOKEN"/>
<xsd:attribute name="finish" type="xsd:NMTOKEN"/>
<xsd:attribute name="fixed" type="xsd:boolean"/>
<xsd:attribute name="guidelines" type="xsd:string"/>
<xsd:attribute name="key" type="xsd:boolean"/>
<xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
<xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="lateFinish" type="xsd:NMTOKEN"/>
<xsd:attribute name="lateStart" type="xsd:NMTOKEN"/>
<xsd:attribute name="locked" type="xsd:boolean"/>
<xsd:attribute name="methodID" type="xsd:string"/>
<xsd:attribute name="milestone" type="xsd:boolean"/>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="outlineLevel" type="xsd:integer"/>
<xsd:attribute name="percComp" type="xsd:decimal"/>
<xsd:attribute name="priority" type="xsd:string"/>
<xsd:attribute name="proxy" type="xsd:boolean"/>
<xsd:attribute name="shortName" type="xsd:string"/>
<xsd:attribute name="start" type="xsd:NMTOKEN"/>
<xsd:attribute name="status" type="xsd:integer"/>
<xsd:attribute name="summary" type="xsd:boolean"/>
<xsd:attribute name="totalSlack" type="xsd:double"/>
<xsd:attribute name="unplanned" type="xsd:boolean"/>
<xsd:attribute name="userText1" type="xsd:string"/>
<xsd:attribute name="userText2" type="xsd:string"/>
<xsd:attribute name="userText3" type="xsd:string"/>
<xsd:attribute name="userText4" type="xsd:string"/>
<xsd:attribute name="userText5" type="xsd:string"/>
<xsd:attribute name="userText6" type="xsd:string"/>
<xsd:attribute name="userText7" type="xsd:string"/>
<xsd:attribute name="userText8" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Assignments" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Assignment" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Assignment" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Curve" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="BaselineDetails" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="actualThrough" type="xsd:NMTOKEN"/>
<xsd:attribute name="actualWork" type="xsd:double"/>
<xsd:attribute name="baselineWork" type="xsd:double"/>
<xsd:attribute name="estMax" type="xsd:double"/>
<xsd:attribute name="estPattern" type="xsd:integer"/>
<xsd:attribute name="finish" type="xsd:NMTOKEN"/>
<xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
<xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="pendActSum" type="xsd:double"/>
<xsd:attribute name="pendEstSum" type="xsd:double"/>
<xsd:attribute name="remainingWork" type="xsd:double"/>
<xsd:attribute name="resourceID" type="xsd:string"/>
<xsd:attribute name="roleID" type="xsd:string"/>
<xsd:attribute name="start" type="xsd:NMTOKEN"/>
<xsd:attribute name="status" type="xsd:integer"/>
<xsd:attribute name="unplanned" type="xsd:boolean"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Constraints" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Constraint" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Constraint" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
<xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="time" type="xsd:NMTOKEN"/>
<xsd:attribute name="type" type="xsd:integer"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Notes" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Note" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Note" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:attribute name="category" type="xsd:string"/>
<xsd:attribute name="content" type="xsd:string"/>
<xsd:attribute name="createdBy" type="xsd:string"/>
<xsd:attribute name="createdDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
<xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Dependencies" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Dependency" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Dependency" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:attribute name="lag" type="xsd:decimal"/>
<xsd:attribute name="lagType" type="xsd:integer"/>
<xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
<xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="predecessorID" type="xsd:string"/>
<xsd:attribute name="predecessorUID"/>
<xsd:attribute name="startFinishType" type="xsd:integer"/>
<xsd:attribute name="successorID" type="xsd:string"/>
<xsd:attribute name="successorUID"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Calendar" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Days" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="baseCalendar"/>
<xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
<xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="name"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Days" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Day" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Day" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Shifts" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="dayOfWeek" type="xsd:string"/>
<xsd:attribute name="finish" type="xsd:NMTOKEN"/>
<xsd:attribute name="isWorkDay" type="xsd:boolean"/>
<xsd:attribute name="start" type="xsd:NMTOKEN"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Shifts" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Shift" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Shift" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:attribute name="finish" type="xsd:NMTOKEN"/>
<xsd:attribute name="start" type="xsd:NMTOKEN"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Curve" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Segments" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="default" type="xsd:double"/>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="type" type="xsd:integer"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Segments" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Segment" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Segment" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Calendar" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="finish" type="xsd:NMTOKEN"/>
<xsd:attribute name="rate" type="xsd:double"/>
<xsd:attribute name="start" type="xsd:NMTOKEN"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="BaselineDetails" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="BaselineDetail" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="BaselineDetail" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Curve" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="baselineCode" type="xsd:string"/>
<xsd:attribute name="costSum" type="xsd:double"/>
<xsd:attribute name="duration" type="xsd:double"/>
<xsd:attribute name="finish" type="xsd:NMTOKEN"/>
<xsd:attribute name="start" type="xsd:NMTOKEN"/>
<xsd:attribute name="usageSum" type="xsd:double"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>3) and one of the smallest XML ... (I can send you a bigger one, where you could notice the query duration )
"Your message exceeds the maximum length of 30000 characters."I can email you an XML file, I failed to upload the smallest XML file !!!!
Well, I hope that's clear enough ad that you could provide me help and advices
Thanks a lot in advance,
Olivierconnect / as sysdba
set define on
set timing on
-- Define variables for USERNAME, TABLESPACES and XMLDIR that represents the base directory where a 'xsd' directory
-- exists that contains the called XML schema used in this script to be registered that creates the XMLTYPE OR table
def USERNAME = cap
def PASSWORD = &USERNAME
-- def XMLDIR = 'C:\Temp'
def USER_TABSPACE = USERS
def TEMP_TABSPACE = TEMP
-- End declaritive section
drop user &USERNAME cascade
grant create any directory, drop any directory, connect, resource, create synonym, alter session, create view to &USERNAME identified by &PASSWORD
alter user &USERNAME default tablespace &USER_TABSPACE temporary tablespace &TEMP_TABSPACE
connect &USERNAME/&PASSWORD
-- create or replace directory XMLDIR as '&XMLDIR/xsd'
select * from v$version
DECLARE
V_XMLSCHEMA CLOB := '<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb"
xmlns="http://www.oracle.com/xsd/projet.xsd"
targetNamespace="http://www.oracle.com/xsd/projet.xsd"
elementFormDefault="unqualified"
xdb:storeVarrayAsTable="true">
<xsd:element name="WORKBENCH_PROJECT" xdb:defaultTable="WORKBENCH_PROJECT_TABLE">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="BaseCalendars"/>
<xsd:element ref="PoolResources"/>
<xsd:element ref="Projects"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="BaseCalendars" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Calendar" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="PoolResources" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="PoolResource" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="PoolResource" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Calendar"/>
<xsd:element ref="Curve"/>
<xsd:element ref="Notes" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="category" type="xsd:string"/>
<xsd:attribute name="emailAddress" type="xsd:string"/>
<xsd:attribute name="employmentType" type="xsd:integer"/>
<xsd:attribute name="description" type="xsd:string"/>
<xsd:attribute name="firstName" type="xsd:string"/>
<xsd:attribute name="fullName" type="xsd:string"/>
<xsd:attribute name="hireDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="inputTypeCode" type="xsd:integer"/>
<xsd:attribute name="isActive" type="xsd:boolean"/>
<xsd:attribute name="isExternal" type="xsd:boolean"/>
<xsd:attribute name="isRole" type="xsd:boolean"/>
<xsd:attribute name="lastName" type="xsd:string"/>
<xsd:attribute name="managerUserName" type="xsd:string"/>
<xsd:attribute name="modBy" type="xsd:string"/>
<xsd:attribute name="openForTimeEntry" type="xsd:boolean"/>
<xsd:attribute name="resourceId" type="xsd:string"/>
<xsd:attribute name="resourceType" type="xsd:integer"/>
<xsd:attribute name="roleID" type="xsd:string"/>
<xsd:attribute name="terminationDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="trackMode" type="xsd:integer"/>
<xsd:attribute name="userFlag1" type="xsd:boolean"/>
<xsd:attribute name="userFlag2" type="xsd:boolean"/>
<xsd:attribute name="userNumber1" type="xsd:decimal"/>
<xsd:attribute name="userNumber2" type="xsd:decimal"/>
<xsd:attribute name="userText1" type="xsd:string"/>
<xsd:attribute name="userText2" type="xsd:string"/>
<xsd:attribute name="userText3" type="xsd:string"/>
<xsd:attribute name="userText4" type="xsd:string"/>
<xsd:attribute name="userText5" type="xsd:string"/>
<xsd:attribute name="userText6" type="xsd:string"/>
<xsd:attribute name="userText7" type="xsd:string"/>
<xsd:attribute name="userText8" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Projects" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Project" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Project" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Baselines" minOccurs="0"/>
<xsd:element ref="Notes" minOccurs="0"/>
<xsd:element ref="Resources" minOccurs="0"/>
<xsd:element ref="Tasks" minOccurs="0"/>
<xsd:element ref="BaselineDetails" minOccurs="0"/>
<xsd:element ref="Dependencies" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="UID"/>
<xsd:attribute name="active" type="xsd:boolean"/>
<xsd:attribute name="asOf" type="xsd:NMTOKEN"/>
<xsd:attribute name="approved" type="xsd:boolean"/>
<xsd:attribute name="baseFinish" type="xsd:NMTOKEN"/>
<xsd:attribute name="baseStart" type="xsd:NMTOKEN"/>
<xsd:attribute name="baseTime" type="xsd:NMTOKEN"/>
<xsd:attribute name="budget" type="xsd:double"/>
<xsd:attribute name="closed" type="xsd:boolean"/>
<xsd:attribute name="cpmType" type="xsd:integer"/>
<xsd:attribute name="department" type="xsd:string"/>
<xsd:attribute name="description" type="xsd:string"/>
<xsd:attribute name="finish" type="xsd:NMTOKEN"/>
<xsd:attribute name="finishImposed" type="xsd:boolean"/>
<xsd:attribute name="format" type="xsd:integer"/>
<xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
<xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="openForTimeEntry" type="xsd:boolean"/>
<xsd:attribute name="priority" type="xsd:integer"/>
<xsd:attribute name="projectType" type="xsd:integer"/>
<xsd:attribute name="program" type="xsd:boolean"/>
<xsd:attribute name="projectID" type="xsd:string"/>
<xsd:attribute name="start" type="xsd:NMTOKEN"/>
<xsd:attribute name="startImposed" type="xsd:boolean"/>
<xsd:attribute name="status" type="xsd:integer"/>
<xsd:attribute name="trackMode" type="xsd:integer"/>
<xsd:attribute name="userText1" type="xsd:string"/>
<xsd:attribute name="userText2" type="xsd:string"/>
<xsd:attribute name="userText3" type="xsd:string"/>
<xsd:attribute name="userText4" type="xsd:string"/>
<xsd:attribute name="userText5" type="xsd:string"/>
<xsd:attribute name="userText6" type="xsd:string"/>
<xsd:attribute name="userText7" type="xsd:string"/>
<xsd:attribute name="userText8" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Baselines" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Baseline" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Baseline" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:attribute name="code" type="xsd:string"/>
<xsd:attribute name="current" type="xsd:boolean"/>
<xsd:attribute name="description"/>
<xsd:attribute name="name" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Resources" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Resource" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Resource" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Curve" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="BaselineDetails" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="availFrom" type="xsd:NMTOKEN"/>
<xsd:attribute name="availTo" type="xsd:NMTOKEN"/>
<xsd:attribute name="bookingStatus" type="xsd:integer"/>
<xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
<xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="openForTimeEntry" type="xsd:boolean"/>
<xsd:attribute name="requestStatus" type="xsd:integer"/>
<xsd:attribute name="resourceID" type="xsd:string"/>
<xsd:attribute name="roleID" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Tasks" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Task" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Task" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Assignments" minOccurs="0"/>
<xsd:element ref="BaselineDetails" minOccurs="0"/>
<xsd:element ref="Constraints" minOccurs="0"/>
<xsd:element ref="Notes" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="UID"/>
<xsd:attribute name="taskID" type="xsd:string"/>
<xsd:attribute name="baseFinish" type="xsd:NMTOKEN"/>
<xsd:attribute name="baseStart" type="xsd:NMTOKEN"/>
<xsd:attribute name="baseTime" type="xsd:NMTOKEN"/>
<xsd:attribute name="baselineDuration" type="xsd:decimal"/>
<xsd:attribute name="category" type="xsd:string"/>
<xsd:attribute name="critical" type="xsd:boolean"/>
<xsd:attribute name="earlyFinish" type="xsd:NMTOKEN"/>
<xsd:attribute name="earlyStart" type="xsd:NMTOKEN"/>
<xsd:attribute name="finish" type="xsd:NMTOKEN"/>
<xsd:attribute name="fixed" type="xsd:boolean"/>
<xsd:attribute name="guidelines" type="xsd:string"/>
<xsd:attribute name="key" type="xsd:boolean"/>
<xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
<xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="lateFinish" type="xsd:NMTOKEN"/>
<xsd:attribute name="lateStart" type="xsd:NMTOKEN"/>
<xsd:attribute name="locked" type="xsd:boolean"/>
<xsd:attribute name="methodID" type="xsd:string"/>
<xsd:attribute name="milestone" type="xsd:boolean"/>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="outlineLevel" type="xsd:integer"/>
<xsd:attribute name="percComp" type="xsd:decimal"/>
<xsd:attribute name="priority" type="xsd:string"/>
<xsd:attribute name="proxy" type="xsd:boolean"/>
<xsd:attribute name="shortName" type="xsd:string"/>
<xsd:attribute name="start" type="xsd:NMTOKEN"/>
<xsd:attribute name="status" type="xsd:integer"/>
<xsd:attribute name="summary" type="xsd:boolean"/>
<xsd:attribute name="totalSlack" type="xsd:double"/>
<xsd:attribute name="unplanned" type="xsd:boolean"/>
<xsd:attribute name="userText1" type="xsd:string"/>
<xsd:attribute name="userText2" type="xsd:string"/>
<xsd:attribute name="userText3" type="xsd:string"/>
<xsd:attribute name="userText4" type="xsd:string"/>
<xsd:attribute name="userText5" type="xsd:string"/>
<xsd:attribute name="userText6" type="xsd:string"/>
<xsd:attribute name="userText7" type="xsd:string"/>
<xsd:attribute name="userText8" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Assignments" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Assignment" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Assignment" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Curve" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element ref="BaselineDetails" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="actualThrough" type="xsd:NMTOKEN"/>
<xsd:attribute name="actualWork" type="xsd:double"/>
<xsd:attribute name="baselineWork" type="xsd:double"/>
<xsd:attribute name="estMax" type="xsd:double"/>
<xsd:attribute name="estPattern" type="xsd:integer"/>
<xsd:attribute name="finish" type="xsd:NMTOKEN"/>
<xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
<xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="pendActSum" type="xsd:double"/>
<xsd:attribute name="pendEstSum" type="xsd:double"/>
<xsd:attribute name="remainingWork" type="xsd:double"/>
<xsd:attribute name="resourceID" type="xsd:string"/>
<xsd:attribute name="roleID" type="xsd:string"/>
<xsd:attribute name="start" type="xsd:NMTOKEN"/>
<xsd:attribute name="status" type="xsd:integer"/>
<xsd:attribute name="unplanned" type="xsd:boolean"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Constraints" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Constraint" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Constraint" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
<xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="time" type="xsd:NMTOKEN"/>
<xsd:attribute name="type" type="xsd:integer"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Notes" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Note" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Note" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:attribute name="category" type="xsd:string"/>
<xsd:attribute name="content" type="xsd:string"/>
<xsd:attribute name="createdBy" type="xsd:string"/>
<xsd:attribute name="createdDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
<xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Dependencies" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Dependency" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Dependency" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:attribute name="lag" type="xsd:decimal"/>
<xsd:attribute name="lagType" type="xsd:integer"/>
<xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
<xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="predecessorID" type="xsd:string"/>
<xsd:attribute name="predecessorUID"/>
<xsd:attribute name="startFinishType" type="xsd:integer"/>
<xsd:attribute name="successorID" type="xsd:string"/>
<xsd:attribute name="successorUID"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Calendar" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Days" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="baseCalendar"/>
<xsd:attribute name="lastUpdatedBy" type="xsd:string"/>
<xsd:attribute name="lastUpdatedDate" type="xsd:NMTOKEN"/>
<xsd:attribute name="name"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Days" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Day" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Day" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Shifts" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="dayOfWeek" type="xsd:string"/>
<xsd:attribute name="finish" type="xsd:NMTOKEN"/>
<xsd:attribute name="isWorkDay" type="xsd:boolean"/>
<xsd:attribute name="start" type="xsd:NMTOKEN"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Shifts" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Shift" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Shift" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:attribute name="finish" type="xsd:NMTOKEN"/>
<xsd:attribute name="start" type="xsd:NMTOKEN"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Curve" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Segments" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="default" type="xsd:double"/>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="type" type="xsd:integer"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="Segments" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Segment" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Segment" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Calendar" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="finish" type="xsd:NMTOKEN"/>
<xsd:attribute name="rate" type="xsd:double"/>
<xsd:attribute name="start" type="xsd:NMTOKEN"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="BaselineDetails" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="BaselineDetail" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="BaselineDetail" xdb:defaultTable="">
<xsd:complexType xdb:maintainDOM="false">
<xsd:sequence>
<xsd:element ref="Curve" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="baselineCode" type="xsd:string"/>
<xsd:attribute name="costSum" type="xsd:double"/>
<xsd:attribute name="duration" type="xsd:double"/>
<xsd:attribute name="finish" type="xsd:NMTOKEN"/>
<xsd:attribute name="start" type="xsd:NMTOKEN"/>
<xsd:attribute name="usageSum" type="xsd:double"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>' ;
BEGIN
dbms_xmlschema.registerSchema
schemaurl => 'http://www.oracle.com/xsd/projet.xsd',
schemadoc => V_XMLSCHEMA,
local => TRUE,
genTypes => TRUE,
genBean => FALSE,
genTables => TRUE,
enablehierarchy => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE,
owner => user
END;
/ -
I am looking for only column compare for making my target table same as source table.
My query:
select case when column_name_s is null and column_name_t is not null
then 'alter table GRADE_CONVERSION drop ' || column_name_t || ';'
when column_name_s is not null and column_name_t is null
then 'alter table GRADE_CONVERSION add ' || column_name_s || ' ' || data_type_s ||';'
else 'alter table GRADE_CONVERSION modify ' || column_name_t || ' ' || data_type_t ||';'
end alterations
from (select s.column_name column_name_s,t.column_name column_name_t,
s.data_type data_type_s,t.data_type data_type_t
from (select column_id,column_name,data_type
from all_tab_cols@database
where owner = 'erhan'
and table_name = 'GRADE_CONVERSION'
) s
full outer join
(select column_id,column_name,data_type
from all_tab_cols@database
where owner = 'sarigul'
and table_name = 'GRADE_CONVERSION'
) t
on s.column_name = t.column_name
Tables:
Target table: GRADE_CONVERSION table in sarigul@database
LETTER_GRADE
VARCHAR2(2)
GRADE_POINT
NUMBER(3,2)
MAX_GRADE
NUMBER(3)
MIN_GRADE
NUMBER(3)
Source table: GRADE_CONVERSION table in erhan@database
LETTER_GRADE
VARCHAR2(2)
GRADE_POINT
NUMBER(3,2)
MAX_GRADE
NUMBER(3)
MIN_GRADE
NUMBER(3)
CREATED_BY
VARCHAR2(30)
CREATED_DATE
DATE
MODIFIED_BY
VARCHAR2(30)
MODIFIED_DATE
DATE
want to see the result similar to this *(please ignore the column names here this is just a plain exemple:)
Alter table Target_table modify BOOK_ID Varchar2 (4);
Alter table Target_table add ISBN_10 Varchar2(13), null;
Alter table Target_table drop TITLE;I am looking for only column compare for making my target table same as source table.
My query:
select case when column_name_s is null and column_name_t is not null
then 'alter table GRADE_CONVERSION drop ' || column_name_t || ';'
when column_name_s is not null and column_name_t is null
then 'alter table GRADE_CONVERSION add ' || column_name_s || ' ' || data_type_s ||';'
else 'alter table GRADE_CONVERSION modify ' || column_name_t || ' ' || data_type_t ||';'
end alterations
from (select s.column_name column_name_s,t.column_name column_name_t,
s.data_type data_type_s,t.data_type data_type_t
from (select column_id,column_name,data_type
from all_tab_cols@database
where owner = 'erhan'
and table_name = 'GRADE_CONVERSION'
) s
full outer join
(select column_id,column_name,data_type
from all_tab_cols@database
where owner = 'sarigul'
and table_name = 'GRADE_CONVERSION'
) t
on s.column_name = t.column_name
Tables:
Target table: GRADE_CONVERSION table in sarigul@database
LETTER_GRADE
VARCHAR2(2)
GRADE_POINT
NUMBER(3,2)
MAX_GRADE
NUMBER(3)
MIN_GRADE
NUMBER(3)
Source table: GRADE_CONVERSION table in erhan@database
LETTER_GRADE
VARCHAR2(2)
GRADE_POINT
NUMBER(3,2)
MAX_GRADE
NUMBER(3)
MIN_GRADE
NUMBER(3)
CREATED_BY
VARCHAR2(30)
CREATED_DATE
DATE
MODIFIED_BY
VARCHAR2(30)
MODIFIED_DATE
DATE
want to see the result similar to this *(please ignore the column names here this is just a plain exemple:)
Alter table Target_table modify BOOK_ID Varchar2 (4);
Alter table Target_table add ISBN_10 Varchar2(13), null;
Alter table Target_table drop TITLE; -
How to run this query to get the minutes between two hours?
Hi all,
Hope doing well,
sir i am running one query which is:
v_TotalHrsMin1 := LPAD((extract(minute from TO_TIMESTAMP (v_Temphrs,'HH24:mi:ss')) - extract(minute from TO_TIMESTAMP (v_Outtime1,'HH24:mi:ss'))), 2, '0');--select to_date(v_temphrs,'YYYY-MM-DD HH:mi:ss')-to_date(v_OutPunch,'YYYY-MM-DD HH:mi:ss')*1440;
in this v_TotalHrsMin1 is number datatype and v_Temphrs is varchar2 which is storing this value: 12:00:00
and v_Outtime1 is varchar2 which is storing 06:00:00
now i want the minute difference between both times
and insert into v_Totalmin1.
but getting null value in v_totalmin1.
thanks952646 wrote:
Hi Sir,
i used query like this: v_TotalHrsMin1 := extract(hour from time_interval) * 60 + extract(minute from time_interval) from (select to_timestamp(v_temphrs,'HH24:MI:SS')-to_timestamp(v_outtime1,'HH24:MI:SS') time_interval from dual);That is not a query - that is a PL/SQL assignment expression. You should learn the differences between SQL and PL/SQL and how they work together ;-)
When doing it in PL/SQL, you do not need a query at all. Why would you do a select from dual in the PL/SQL assignment.
But you should be able to take the SQL example I gave you and write the equivalent PL/SQL code.
We do not want to do your work for you - we want to teach you how to do it yourself.
You should try and understand the examples we give you - not just cut-and-paste it and cry for help when you are cut-and-pasting a SQL example into PL/SQL code.
Anyway - here's a way to do it in PL/SQL:
declare
v_outtime1 varchar2(8);
v_temphrs varchar2(8);
v_interval interval day to second;
v_totalhrsmin1 number;
begin
v_outtime1 := '06:00:00';
v_temphrs := '12:00:00';
v_interval := to_timestamp(v_temphrs,'HH24:MI:SS')-to_timestamp(v_outtime1,'HH24:MI:SS');
v_totalhrsmin1 := extract(hour from v_interval) * 60 + extract(minute from v_interval);
end;
/What's so difficult about taking my SQL example, understanding what the differenct functions do, and then write that piece of PL/SQL? ;-) -
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 this query ?
how to write this query ?
list the emp name who is working for the highest avg sal department.
I can use row_number over to get correct result. If we don't use this row_number function, just plain sql, how to do it ?
the row_number version is like this
select emp.* from emp ,
select deptno, row_number() over (order by avg(sal) desc) r from emp
group by deptno
)e
where e.r = 1
and emp.deptno = e.deptnoHi,
806540 wrote:
how to write this query ?
list the emp name who is working for the highest avg sal department.
I can use row_number over to get correct result. If we don't use this row_number function, just plain sql, how to do it ?ROW_NUMBER is just plain SQL, and has been since Oracle 8.1.
ROW_NUMBER (or its close relative, RANK) is the simplest and most efficient way to solve this problem. Why not do this the right way?
the row_number version is like this
select emp.* from emp ,
select deptno, row_number() over (order by avg(sal) desc) r from emp
group by deptno
)e
where e.r = 1
and emp.deptno = e.deptno
If there happens to be a tie (that is, two or more departments have the same average sal, and it is the highest), then the query above will only arbitrarily treat one of them (no telling which one) as the highest. Change ROW_NUMBER to RANK to get all departments with a claim to having the highest average sal.
You could use the ROWNUM pseudo-column instead of ROW_NUMBER, if all you want to do is avoid ROW_NUMBER.
Without using ROW_NUMBER or RANK, there are lots of ways involving other analytic functions, such as AVG and MAX.
If you really, really don't want to use analytic functions at all, you can do this:
SELECT *
FROM scott.emp
WHERE deptno IN (
SELECT deptno
FROM scott.emp
GROUP BY deptno
HAVING AVG (sal) = (
SELECT MAX (AVG (sal))
FROM scott.emp
GROUP BY deptno
; -
SQL query to get the Datetime 06 hours prior to the table Datetime value
Hi Experts,
I'm just trying to create a SQL query to get the Datetime which should be 06 hours prior to my Table column value(Executiontime),
Eg: my Executiontime(column) value is 07:00AM means, this query should fetch the detail of first VMName from table at 01:00AM,
SQL Table Name: TestTable
Columns: VMName(varchar),status(varchar) Executiontime(Datetime)
SQL Query : Select Top 1 VMName from
TestTable where convert(date,Exeutiontime)=convert(date,getdate()) and
status='0' and ExecutionTime > dateadd(hour,6,getdate())
Request someone to alter this Query to my requirement or give me the new one.
Regards,
Sundar
SundarHi All,
Thanks for your Prompt response. I tried the below queries, but still I don't have any luck. Actually the queries are returning the value before the condition met (say when the time difference is more than 06 hours). I want the
query to return exactly @ 06 hour difference or less than 06 hours,
Query 01: Select Top 1 VMName from TestTable where
convert(date,Exeutiontime)=convert(date,getdate())
and status='0'
and ExecutionTime >
dateadd(hour,-6,getdate())
Query 02: Select
Top 1 VMName from TestTable where
status='0'
and ExecutionTime >
dateadd(hour,-6,getdate())
Query 03: Select
Top 1 VMName from TestTable where status='0'
and ExecutionTime >
dateadd(hour,-6,ExecutionTime)
Can someone point out the mistake please.
Regards,
Sundar
Sundar -
GRC - SQL Query to retrive the Approver/Rejecter Names
Hello,
I was trying to write a sql query to retrive the name of the user who has approved or rejected a particular Approval Notification in GRC Flow rule.
This query should retrive the user , who has taken the action. This user name will be added to the Role, which inturn will be attached to the Approval Group
Thanks,
GowriBasically, We have GRC Flow rule, with a process flow written to send Notification
Here we have added a Approver Group with approval type as Wait for Approval and Vote Percentage as 100
Two users are added to the Role which inturn is added to the Approval Group. What is the SQL query to retrieve the Username who has Approval or Rejection for a notification?
Can anyone please help
Thanks,
Gowri -
Using "Object from this query" as a filter parameter
Hi Folks,
I am looking to find a solution to a requirement where I need to filter data in a report based on the current year. I do not want to use the BEx functionality for filtering and want to leverage the BObj query filters. My idea was to create a "variable" in the BObj query to get the current year and hopefully use that as a filter parameter for 'Object in this query". But The options "Object in this query" and "Result from another query" are greyed out. I am using BObj 4.0 patch 12.
Do any of you have suggestions on how to accomplish this.
Regards,
DonivHi,
prerequisite to using the operators you mention is to have 2 dataproviders queries first.
However, it might be that those kind of operators aren't implemented for the current BICS interface, same goes with Unions, OR operator.
I know you can do this with Relational UNX, but BEX direct access has shortcomings in the query panel.
might be worth to try this again if you can get your hands on FP03 ramp up. things change again , for the better, there.
Regards,
H -
Query for deleting the minimum updated record.
Hello Everybody,
I have table USER_RECENT_PROJECTS which has SIX columns USER_NAME,PROJECT_ID,CREATED_BY,CREATED_ON,UPDATED_BY
and UPDATED_ON.The purpose of having this table to get 5 recent PROJECTS
on which user has worked on.
I have trigger called RECENT_PRJ_TRIGG which IS FIRED when the data is inserted or updated on PROJECT table.After this trigger calls procedure PROC_USER_RECENT_PRJ and that procedure puts the data in this table.
It is inserting the data upto 5 records when the six records comes it deleting the record which is least UPDATED_ON from the table USER_RECENT_PROJECTS but the problem is it is deleting
the record from other user that i don't want.I want to delete the the record which is
least UPDATED_ON from particular user.
Please help me on this issue.
Here is the trigger
CREATE TRIGGER RECENT_PRJ_TRIGG
AFTER INSERT OR UPDATE ON PROJECT
FOR EACH ROW
DECLARE
NUMBER_OF_PROJECTS NUMBER:=0;
EXISTING_PROJECT_ID NUMBER:=0;
BEGIN
SELECT COUNT(*) INTO NUMBER_OF_PROJECTS FROM USER_RECENT_PROJECTS WHERE USER_NAME=:NEW.UPDATED_BY;
SELECT PROJECT_ID INTO EXISTING_PROJECT_ID FROM USER_RECENT_PROJECTS WHERE PROJECT_ID=:NEW.PROJECT_ID AND USER_NAME=:NEW.UPDATED_BY;
NVLX.PROC_USER_RECENT_PRJ(NUMBER_OF_PROJECTS,:NEW.PROJECT_ID,EXISTING_PROJECT_ID,:NEW.UPDATED_BY,:NEW.CREATED_BY,:NEW.CREATED_ON);
EXCEPTION
WHEN NO_DATA_FOUND THEN
NVLX.PROC_USER_RECENT_PRJ(NUMBER_OF_PROJECTS,:NEW.PROJECT_ID,0,:NEW.UPDATED_BY,:NEW.CREATED_BY,:NEW.CREATED_ON);
END;
And this is the procedure which is inserting the data
CREATE OR REPLACE PROCEDURE PROC_USER_RECENT_PRJ (
NUMBER_OF_PROJECTS IN NUMBER,
NEW_PROJECT_ID IN PROJECT.PROJECT_ID%TYPE,
EXISTING_PROJECT_ID IN USER_RECENT_PROJECTS.PROJECT_ID%TYPE,
USER_NAME IN CONTENT_USER.USER_NAME%TYPE,
CREATED_BY IN PROJECT.CREATED_BY%TYPE,
CREATED_ON IN PROJECT.CREATED_ON%TYPE)
IS
MAX_RECENT_PROJECTS NUMBER := 5;
BEGIN
IF NUMBER_OF_PROJECTS<=MAX_RECENT_PROJECTS AND EXISTING_PROJECT_ID=NEW_PROJECT_ID THEN
UPDATE USER_RECENT_PROJECTS SET USER_RECENT_PROJECTS.UPDATED_ON=SYSDATE,USER_RECENT_PROJECTS.UPDATED_BY=USER_NAME WHERE PROJECT_ID=EXISTING_PROJECT_ID
AND USER_RECENT_PROJECTS.USER_NAME=USER_NAME;
ELSE IF NUMBER_OF_PROJECTS<MAX_RECENT_PROJECTS AND EXISTING_PROJECT_ID!= NEW_PROJECT_ID THEN
INSERT INTO USER_RECENT_PROJECTS VALUES (USER_NAME,NEW_PROJECT_ID,CREATED_BY,CREATED_ON,USER_NAME,SYSDATE);
ELSE IF NUMBER_OF_PROJECTS=MAX_RECENT_PROJECTS AND EXISTING_PROJECT_ID!= NEW_PROJECT_ID THEN
DELETE FROM USER_RECENT_PROJECTS WHERE USER_RECENT_PROJECTS.PROJECT_ID IN(
SELECT PROJECT_ID FROM USER_RECENT_PROJECTS
WHERE UPDATED_ON=(SELECT MIN(UPDATED_ON) FROM USER_RECENT_PROJECTS
WHERE USER_RECENT_PROJECTS.USER_NAME=USER_NAME));
INSERT INTO USER_RECENT_PROJECTS VALUES (USER_NAME,NEW_PROJECT_ID,CREATED_BY,CREATED_ON,USER_NAME,SYSDATE);
END IF;
END IF;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NVLX.PROC_USER_RECENT_PRJ(NUMBER_OF_PROJECTS,NEW_PROJECT_ID,0,USER_NAME,CREATED_BY,CREATED_ON);
END PROC_USER_RECENT_PRJ;
Please help me on this issue.
Thanks in advance.....Thanks for your suggestion....
I am using the trigger for populating the data in USER_RECENT_PROJECTS.This
trigger is fired when data is INSERTED or UPDATED in PROJECT table.And that trigger will call the procedure PROC_USER_RECENT_PRJ.This is used
to put data in USER_RECENT_PROJECTS table.I am getting the problem in procedure the problem is upto five records it is inserting the record when i go for insert sixth record it should delete least UPDATED_ON and insert new record.But it is deleting the record from other user that i don't want.I want to delete the record from the paarticular user.I am using this query for deleting the record..
DELETE FROM USER_RECENT_PROJECTS WHERE USER_RECENT_PROJECTS.PROJECT_ID=(
SELECT PROJECT_ID FROM USER_RECENT_PROJECTS
WHERE UPDATED_ON=(SELECT MIN(UPDATED_ON) FROM USER_RECENT_PROJECTS WHERE USER_RECENT_PROJECTS.USER_NAME=USER_NAME)
AND USER_RECENT_PROJECTS.USER_NAME=USER_NAME
) AND USER_RECENT_PROJECTS.USER_NAME=USER_NAME;
when i fire this query individually it is deleting the proper record,but when i use it
inside procedure it is creating the problem it is deleting the record from other user.
Please suggest me other query for deletion.
Thanks in advance....... -
Any idea what this query is trying to do?
Do you guys have any idea what this query(used for report generation) is used for? I don't understand the WHERE clause of this query especially what the Pipe operators(|| ' 21:00:00') are used for?
SELECT c.course_id,
mph.subject
from courses c, main_pgm_hdr mph
where
c.classid=mph.classid
AND
TO_CHAR(MPH.CLOSE_DATE, 'mm/dd/yyyy hh24:mi:ss') >= TO_CHAR(TRUNC(SYSDATE, 'MM') - 1, 'mm/dd/yyyy')
|| ' 21:00:00'
AND TO_CHAR(MPH.CLOSE_DATE, 'mm/dd/yyyy hh24:mi:ss') <= TO_CHAR(SYSDATE, 'mm/dd/yyyy')
|| ' 20:59:59'Edited by: user10450365 on Jan 13, 2009 7:11 PMThey are trying to get the data having CLOSE_DATE between 20:59:59 and 21:00:00 for the present day. But the way its done is wrong. They have converted the date into Char and they are comparing. Its absolutely incorrect.
One way to do it would be
SELECT DISTINCT (PS.CARR_ID) AS CARRIER ,
MPH.SHPMT_NBR AS TRAILER ,
MPH.SHPMT_NBR AS SHPMT_NBR,
TO_CHAR(MPH.CREATE_DATE_TIME, 'mm/dd/yyyy hh24:mi:ss') AS LOADED ,
TO_CHAR(MPH.CLOSE_DATE, 'mm/dd/yyyy hh24:mi:ss') AS FINALIZED
FROM PARCL_SERV PS,
MANIF_PARCL_HDR MPH
WHERE PS.MANIF_TYPE = MPH.MANIF_TYPE
AND MPH.CLOSE_DATE >= TRUNC(sysdate)+(21/24)
AND MPH.CLOSE_DATE <= TRUNC(sysdate)+((20/24)+(59/1440)+(59/86400))Edited by: Karthick_Arp on Jan 13, 2009 1:27 AM -
Query to find the Views and synonyms that are accessing through db_link
HI all,
Oracle 10g
I need a Query to find the Views and synonyms that are accessing through db_link.
ie.
database A have the db_link to database B through a schema A
now i need to find what are the Synonyms and views that are accessing through db_link either directly or indirectly..
regards,
Deepak
Edited by: Deepak_DBA on Dec 10, 2010 5:38 PMOn the second database (B) use this query to find the SQL which used by the schema A (DB LINK USER). Check the SQL_FULLTEXT column.
select sql_fulltext,sql_id,module,parsing_schema_name,parsing_user_id,first_load_time,loads,users_executing,rows_processed,plsql_exec_time,sorts,fetches,invalidations,parse_calls,cpu_time,elapsed_time,disk_reads,buffer_gets
from V$sqlarea
where parsing_schema_name = 'A' --and to_char(first_load_time,'dd/mm/yyyy') like '%11/08/2007'
order by first_load_time desc;
Regards
Asif Kabir
Maybe you are looking for
-
When I open Facebook the print is very large and the page does not fit the screen so need to keep moving back and forth across to be able to read it. It was not like this before. Please can you find a solution for me Thank you
-
Resetting the transaction figures of an account
Hi Is it possible to reset the transaction data for one master record/account alone. I know that the TCode OBR1 would reset data, but for the entire company code. How can I reset the transaction data for one account - say a vendor account? Thanks in
-
I currently am working with Adobe Pro X I created a form using Adobe Live Cycle. When other users open the form and complete the fields they are promted to "save as". I would like the users to be able to simply save the document they have, then be ab
-
Hi, downloaded the jdev preview (10.13.0.2.223) for macos, configured a few connections and got: oracle.jdeveloper.cm.CMException: java.lang.NoClassDefFoundError: oracle/i18n/text/converter/CharacterConverterOGS at oracle.jdevimpl.cm.dt.browser.
-
Hi everyone, I set up my Belkin router using my old PC (which is now dead and buried). My Time Capsule is plugged into the Belkin router. I never bothered setting any security on my home network (i.e. its an open network), as we live in the middle of