Af:query with extra functionality
Hello everyone,
JDev: 11.1.1.3 (migrating to 11.1.1.5)
We are using the af:query component as our standard query module (seems logical).
Thanks to the Frank Nimphius "af:query component complex field validation" on the ADF Code Corner,
it is clear how to do validation in an af:query component.
What we want to do is the following : on an existing field, adding a link/icon that opens a popup that contains
a taskflow, which contains a more complex query (again with af:query ;-)). The result of the tf should return
into the field in the first af:query component.
Is something like this possible?
Thanks.
Filip Huysmans.
Filip,
no, you can't
Frank
Similar Messages
-
SQL Query With analytical function
Hi
Below is the scenario which i am looking for in sql query using analytical functions
I/p
Col1
50
0
-150
-200
300
-100
-300
500
-100
O/p
Col1 col2
50 0
0 0
-150 -100
-200 -200
300 0
-100 0
-300 -100
500 400
-100 0Any help really appreciated
Thanks in advance
Edited by: unique on Aug 10, 2010 4:53 AM
Edited by: unique on Aug 10, 2010 4:55 AM
Edited by: unique on Aug 10, 2010 4:55 AMOh,In this case,There is OLAP solution ;-)
OLAP samples of my homepage http://www.geocities.jp/oraclesqlpuzzle/oracle-sql1-olap.html
with work(SK,Val) as(
select 1, 50 from dual union
select 2, 0 from dual union
select 3,-150 from dual union
select 4,-200 from dual union
select 5, 300 from dual union
select 6,-100 from dual union
select 7,-300 from dual union
select 8, 500 from dual union
select 9,-100 from dual)
select SK,Val,GID,
case when Val > 0
then greatest(0,sum(Val) over(partition by GID))
else Least(0,Val+greatest(0,sum(Val) over(partition by GID
order by SK rows between unbounded preceding
and 1 preceding)))
end as COL3
from (select SK,Val,
sum(greatest(0,sign(Val))) over(order by SK) as GID
from work)
order by SK;
SK VAL GID COL3
1 50 1 0
2 0 1 0
3 -150 1 -100
4 -200 1 -200
5 300 2 0
6 -100 2 0
7 -300 2 -100
8 500 3 400
9 -100 3 0 -
Problem in Query with JOIN Function in OCRD CRD1 OCPR tables
Hello Dear Forum Users,
I want to make a query which shows me per business partner from OCRD - Addres; CRD1 - Delivery Address and from OCPR - Contactperson information
Is it possible to show it in one row per Business Partner. Now I get (the classic problem) of several rows and a duplication of the contact persons per (delivery) address.
My query is:
SELECT T0.[CardCode], T0.[CardName], T1.[Address], T1.[Street], T1.[ZipCode], T1.[City], T1.[Country], T1.[U_TelNr], T1.[U_MobNr], T1.[U_OpenTijd], T1.[U_LosIns_1], T1.[U_LosIns_2],T2.[Title], T2.[Name] as 'Voornaam', T2.[Address] as 'Achternaam', T2.[Position] as 'Functie', T2.[Tel1], T2.[Cellolar], T2.[E_MailL], T2.[BirthDate] FROM OCRD T0 LEFT OUTER JOIN CRD1 T1 ON T0.CardCode = T1.CardCode LEFT OUTER JOIN OCPR T2 ON T0.CardCode = T2.CardCode
Can you help me ?
Jos Dielemans - Maastricht
Edited by: J. Dielemans on Apr 29, 2011 4:28 PM
Changed the query with Left Outer JoinI have found the solution myself:
By using the Union All function I could combine two queries. Here is the result:
SELECT
T0.[CardCode], T0.[CardName], T1.[Address] , T1.[Street], T1.[ZipCode], T1.[City], T1.[Country], T1.[U_TelNr], T1.[U_OpenTijd] , T1.[U_LosIns_1] , T1.[U_LosIns_2]'
FROM OCRD T0 LEFT OUTER JOIN CRD1 T1 ON T0.CardCode = T1.CardCode
WHERE T0.[CardCode] >= 'D00000'
Union all
SELECT
T0.[CardCode], T0.[CardName], T2.[Position], T2.[Tel1], T2.[Title], T2.[Name], T2.[Address], T2.[Position], T2.[Tel1], T2.[Cellolar], T2.[E_MailL]
FROM OCRD T0 LEFT OUTER JOIN OCPR T2 ON T0.CardCode = T2.CardCode
WHERE T0.[CardCode] >= 'D00000'
Order by 1
Now i got the result I was looking for. -
Hi Experts,
I have tried the below query with sub select function. could any one help me to fix this ?
SELECT T0.[ItemCode], T0.[Dscription], T1.[OnHand],
(Select distinct sum(T0.InQty) from OINM where T0.ItemCode = OINM.ItemCode and T0.DocDate = '2012/08/18' ) as 'OB Stock'
FROM OINM T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode
WHERE T1.[OnHand] > 0 GROUP BY T0.[ItemCode], T0.[Dscription], T1.[OnHand]
thanks in advance,
Regards,
DwarakHi,
This is for your Query.
SELECT T0.[ItemCode], T0.[Dscription], T1.[OnHand],
(Select distinct sum(T0.InQty) from OINM t0 where T0.ItemCode = T0.ItemCode and T0.DocDate = '2012/08/18' ) as 'OB Stock'
FROM OINM T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode
WHERE T1.[OnHand] > 0 GROUP BY T0.[ItemCode], T0.[Dscription], T1.[OnHand]
Regards,
Kalaiyarasan.v -
Is that important column order in a query with row_number function
Hi folks,
I am using Oracle 11g R2 on HP-UX machine.
I have 2 types of query with row_number and I think they are same but output of each of them are different. I changed only column order in query2.
Query 1 :
(SELECT
"LOOKUP_INPUT_SUBQUERY"."CONTRACT_SK" "CONTRACT_SK",
"LOOKUP_INPUT_SUBQUERY"."SIMCARD_SK" "SIMCARD_SK"
FROM (
SELECT row_number ()
OVER (
PARTITION BY "R_CON_SUBS_SIMCARD_LK".
"CONTRACT_SK"
ORDER BY
"R_CON_SUBS_SIMCARD_LK"."START_DATE" DESC,
"R_CON_SUBS_SIMCARD_LK"."SEQ_NUM" DESC NULLS LAST) /* EXPRESSION_3.OUTGRP1.SIRA */
"SIRA",
"R_CON_SUBS_SIMCARD_LK"."CONTRACT_SK" "CONTRACT_SK",
"R_CON_SUBS_SIMCARD_LK"."SIMCARD_SK" "SIMCARD_SK"
FROM "SRC_OZRDS"."R_CON_SUBS_SIMCARD_LK" "R_CON_SUBS_SIMCARD_LK")
"LOOKUP_INPUT_SUBQUERY"
WHERE ("LOOKUP_INPUT_SUBQUERY"."SIRA" = 1))
Output of this like that :
CONTRACT_SK SIMCARD_SK
1 1
1 3
1 4
1 5
1 6
1 11
1 12
1 14
1 15
1 16
Query 2 :
(SELECT
"LOOKUP_INPUT_SUBQUERY"."CONTRACT_SK" "CONTRACT_SK",
"LOOKUP_INPUT_SUBQUERY"."SIMCARD_SK" "SIMCARD_SK"
FROM (
SELECT
"R_CON_SUBS_SIMCARD_LK"."CONTRACT_SK" "CONTRACT_SK",
"R_CON_SUBS_SIMCARD_LK"."SIMCARD_SK" "SIMCARD_SK",
row_number ()
OVER (
PARTITION BY "R_CON_SUBS_SIMCARD_LK".
"CONTRACT_SK"
ORDER BY
"R_CON_SUBS_SIMCARD_LK"."START_DATE" DESC,
"R_CON_SUBS_SIMCARD_LK"."SEQ_NUM" DESC NULLS LAST) /* EXPRESSION_3.OUTGRP1.SIRA */
"SIRA"
FROM "SRC_OZRDS"."R_CON_SUBS_SIMCARD_LK" "R_CON_SUBS_SIMCARD_LK")
"LOOKUP_INPUT_SUBQUERY"
WHERE ("LOOKUP_INPUT_SUBQUERY"."SIRA" = 1))
Output of this like that:
2 874812
7 70097256
8 18734091
9 158024
10 815397739
13 22657919
19 83177779
20 82579529
22 5829949
23 35348926
25 3865978
I expected the second output, because there are lots of contract sk but there is one contract_sk in first query result. i did not get the point. What is the problem ?user8649469 wrote:
I changed only column order in query2.So what else do you expect? If you order, for example, by last name, fist name don't you think rows will be returned in a different order (and therefore same row will have different row number) than ordering by first name, last name?
SY. -
Update of a table from a select query with aggregate functions.
Hello All,
I have problem here:
I have 2 tables A(a1, a2, a3, a4, a4....... ) and B( a1, a2, b1, b2, b3). I need to calculate the avg(a4-a3), Max(a4-a3) and Min(a4-a3) and insert it into table B. If the foreign keys a1, a2 already exist in table B, I need to do an update of the computed values into column b1, b2 and b3 respectively, for a1, a2.
Q1. Is it possible to do this with a single query ? I would prefer not to join A with B because the table A is very large. Also columns b1, b2 and b3 are non-nullable.
Q2. Also if a4 and a3 are timestamps what is the best way to find the average? A difference of timestamps yields INTERVAL DAY TO SECOND over which the avg function doesn't seem to work. The averages, max and min in my case would be less than a day and hence all I need is to get the data in the hh:mm:ss format.
As of now I'm using :
TO_CHAR(TO_DATE(ABS(MOD(TRUNC(AVG(extract(hour FROM (last_modified_date - created_date))*3600 +
extract( minute FROM (last_modified_date - created_date))*60 +
extract( second FROM (last_modified_date - created_date)))
),86400)),'sssss'),'hh24":"mi":"ss') AS avg_time,
But this is very long drawn. Something more compact and efficient would be nice.
Thanks in advance for your inputs.
Edited by: 847764 on Mar 27, 2011 5:35 PM847764 wrote:
Hi,
Thanks everyone for such fast replies. Malakshinov's example worked fine for me as far as updating the table goes. As for the timestamp computations, I'm posting additional info: Sorry, I don't understand.
If Malakshinov's example worked for updating the table, but you still have problems, does that mean you have to do something else besides update the table? If so, what?
Oracle version : Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
Here are the table details :
DESC Table A
Name Null Type
ID NOT NULL NUMBER
A1 NOT NULL VARCHAR2(4)
A2 NOT NULL VARCHAR2(40)
A3 NOT NULL VARCHAR2(40)
CREATED_DATE NOT NULL TIMESTAMP(6)
LAST_MODIFIED_DATE TIMESTAMP(6) DESCribing the tables can help clarify some things, but it's no substitute for posting CREATE TABLE and INSERT statements. With only a description of the table, nobody can re-create the problem or test their ideas. Please post CREATE TABLE and INSERT statements for both tables as they exist before the MERGE. If table b doen't contain any rows before the MERGE, then just say so, but you still need to post a CREATE TABLE statement for both tables, and INSERT statements for table a.
The objective is to compute the response times : avg (LAST_MODIFIED_DATE - CREATED_DATE), max (LAST_MODIFIED_DATE - CREATED_DATE) and min (LAST_MODIFIED_DATE - CREATED_DATE) grouped by A1 and A2 and store it in table B under AVG_T, MAX_T and MIN_T. Since AVG_T, MAX_T and MIN_T are only used for reporting purposes we have kept it as Varchar (though I think keeping it as timestamp would make more sense). I think a NUMBER would make more sense (the number of minutes, for example), or perhaps an INTERVAL DAY TO SECOND. If you stored a NUMBER, it would be easy to compute averages.
In table B the times are stored in the format : hh:mm:ss. We don't need milliseconds precision. If you don;'t need milliseconds, then you should use DATE instead of TIMESTAMP. The functions for manipulating DATEs are much better.
Hence I was calculating is as follows:
-- Avg Time
TO_CHAR(TO_DATE(ABS(MOD(TRUNC(AVG(extract(hour FROM (last_modified_date - created_date))*3600 +
extract( minute FROM (last_modified_date - created_date))*60 +
extract( second FROM (last_modified_date - created_date)))
),86400)),'sssss'),'hh24":"mi":"ss') AS avg_time,
--Max Time
extract (hour FROM MAX(last_modified_date - created_date))||':'||extract (minute FROM MAX(last_modified_date - created_date))||':'||TRUNC(extract (second FROM MAX(last_modified_date - created_date))) AS max_time,
--Min Time
extract (hour FROM MIN(last_modified_date - created_date))||':'||extract (minute FROM MIN(last_modified_date - created_date))||':'||TRUNC(extract (second FROM MIN(last_modified_date - created_date))) AS min_timeIs this something that has to be done before or after the MERGE?
Post the complete statement.
Is this part of a query? Where's the SELECT keyword?
Is this part of a DML operation? Where's the INSERT, or UPDATE, or MERGE keyword?
What are the exact results you want from this? Explain how you get those results.
Is the code above getting the right results? Are you just asking if there's a better way to get the same results?
You have to explain things very carefully. None of the people who want to help you are familiar with your application, or your needs.
I just noticed that my reply is horribly formatted - apologies! I'm just getting the hang of it.Whenever you post formatted text (such as query results) on this site, type these 6 characters:
\(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing. -
SQL query with object function
I want to write a function, which returns more than one value and to include those values into a SQL statement. For example I want to query the RDB with....
select t.id, my_function(t.id).value1 name, my_function(t.id).value2 address ....
from table_x t
where t.id between 1 and 10
and bitand(my_function(t,id)).sec_id,2)>3
Is it possible to do something like this?
I tried to use object and table of objects(my_type) to return value of my_type but when I used
select ......my_function(t.id).name,my_function(t.id).address ...
from table_x
where t.id=some_value;
the function was called twice(i expected this result, but i don't know how to avoid it).
Simple example
CREATE OR REPLACE TYPE l_test AS OBJECT
id NUMBER(10),
name varchar2(100),
a_date date
CREATE OR REPLACE FUNCTION test_f2(test_number IN NUMBER)
RETURN l_test
IS
a number;
BEGIN
select t_seq.nextval into a from dual;
return l_test(a,'test value ='||test_number,sysdate+test_number);
END;
select test_f2(i.id).id client_id, test_f2(i.id).name client_name from r_owners i
CLIENT_ID CLIENT_NAME
1 test value =1
3 test value =2
I want to be able to loop in cursor and use those values
All ideas are welcome!
Thanks,
Iassen HoubenovCheck it out...
SQL> CREATE OR REPLACE TYPE emp_add AS OBJECT
2 ( office VARCHAR2(50),
3 location VARCHAR2(50),
4 MEMBER FUNCTION get_office RETURN VARCHAR2,
5 MEMBER FUNCTION get_location RETURN VARCHAR2,
6 CONSTRUCTOR FUNCTION emp_add(id NUMBER) RETURN SELF AS RESULT,
7 CONSTRUCTOR FUNCTION emp_add(id NUMBER, office VARCHAR2,location VARCHAR2) RETURN
8 SELF AS RESULT
9 ) NOT FINAL;
10 /
Type created.
SQL> CREATE OR REPLACE TYPE BODY emp_add IS
2 MEMBER FUNCTION get_office RETURN VARCHAR2
3 IS
4 BEGIN
5 RETURN SELF.office;
6 END;
7 MEMBER FUNCTION get_location RETURN VARCHAR2
8 IS
9 BEGIN
10 RETURN SELF.location;
11 END;
12 CONSTRUCTOR FUNCTION emp_add(id NUMBER)
13 RETURN SELF AS RESULT
14 IS
15 BEGIN
16 SELECT dname, loc
17 INTO SELF.office, SELF.location
18 FROM dept
19 WHERE deptno = id;
20 RETURN;
21 END;
22 CONSTRUCTOR FUNCTION emp_add(id NUMBER, office VARCHAR2,location VARCHAR2)
23 RETURN SELF AS RESULT
24 IS
25 BEGIN
26 SELF.office := office;
27 SELF.location := location;
28 RETURN;
29 END;
30 END;
31 /
Type body created.
SQL> SELECT e.ename, e.d.office, e.d.location
2 FROM ( SELECT ename
3 , (SELECT emp_add(emp.deptno) FROM dual ) d
4 FROM emp ) e
5 /
ENAME D.OFFICE
D.LOCATION
SMITH RESEARCH
DALLAS
ALLEN SALES
CHICAGO
WARD SALES
CHICAGO
....Smoke me a kipper I'll be back before breakfast.
Cheers, APC -
Query with trim function running more than 15 hours..
Hi,
I have one select query which is running more than 15 hours.I have many trim() functions in that.and i have index for some columns for the tables that i used in that query.but it is not considering those indexes..
select
DISTINCT
trim(A.x) x,
trim(B.y) y,....... from A,B
Can anyone tell why this query is taking more time?and is there any other way for using the trim function?
Thanks in advance..Note the name of this forum is "SQL Developer *(Not for general SQL/PLSQL questions)*", so only for issues with the SQL Developer tool. Please post these questions under the dedicated [SQL And PL/SQL|https://forums.oracle.com/forums/forum.jspa?forumID=75] forum.
Regards,
K. -
Speed up query with analytic function
Hi
how can I speed up the query below ?
All time is in analytic function (WINDOW SORT)
Thanks for your help
11.2.0.1
Rows Row Source Operation
28987 HASH UNIQUE (cr=12677 pr=155778 pw=109730 time=25010 us cost=5502 size=3972960 card=14880)
1668196 WINDOW SORT (cr=12677 pr=155778 pw=109730 time=890411840 us cost=5502 size=3972960 card=14880)
1668196 HASH JOIN RIGHT OUTER (cr=12677 pr=0 pw=0 time=1069165 us cost=3787 size=3972960 card=14880)
30706 TABLE ACCESS FULL FLO_FML_EVENT (cr=270 pr=0 pw=0 time=7420 us cost=56 size=814158 card=30154)
194733 HASH JOIN RIGHT OUTER (cr=12407 pr=0 pw=0 time=571145 us cost=3730 size=3571200 card=14880)
613 VIEW (cr=342 pr=0 pw=0 time=489 us cost=71 size=23840 card=745)
613 HASH UNIQUE (cr=342 pr=0 pw=0 time=244 us cost=71 size=20115 card=745)
745 WINDOW SORT (cr=342 pr=0 pw=0 time=1736 us cost=71 size=20115 card=745)
745 MAT_VIEW ACCESS FULL MVECRF_CUR_QUERY (cr=342 pr=0 pw=0 time=1736 us cost=69 size=20115 card=745)
194733 HASH JOIN (cr=12065 pr=0 pw=0 time=431813 us cost=3658 size=3095040 card=14880)
43 MAT_VIEW ACCESS FULL MVECRF_VISIT_REVS (cr=3 pr=0 pw=0 time=0 us cost=2 size=946 card=43)
194733 HASH JOIN OUTER (cr=12062 pr=0 pw=0 time=292098 us cost=3656 size=2767680 card=14880)
194733 HASH JOIN OUTER (cr=10553 pr=0 pw=0 time=234394 us cost=2962 size=2574240 card=14880)
194733 HASH JOIN (cr=9999 pr=0 pw=0 time=379996 us cost=2570 size=2380800 card=14880)
30076 MAT_VIEW ACCESS FULL MVECRF_ACTIVATED_FORMS (cr=1817 pr=0 pw=0 time=28411 us cost=361 size=2000285 card=29855)
194733 HASH JOIN (cr=8182 pr=0 pw=0 time=209061 us cost=1613 size=9026301 card=97057)
628 MAT_VIEW ACCESS FULL MVECRF_STUDYVERSION_FORMS (cr=19 pr=0 pw=0 time=250 us cost=6 size=18212 card=628)
194733 MAT_VIEW ACCESS FULL MVECRF_FORMITEMS (cr=8163 pr=0 pw=0 time=80733 us cost=1606 size=12462912 card=194733)
132342 MAT_VIEW ACCESS FULL MVECRF_ITEM_SDV (cr=554 pr=0 pw=0 time=23678 us cost=112 size=1720446 card=132342)
221034 MAT_VIEW ACCESS FULL MVECRF_ITEMDATA (cr=1509 pr=0 pw=0 time=46459 us cost=299 size=2873442 card=221034)
SELECT
DISTINCT
'CL238093011' AS ETUDE,
FI.STUDYID,
FI.STUDYVERSIONID,
FI.SITEID,
FI.SUBJECTID,
FI.VISITID,
VR.VISITREFNAME,
FI.SUBJECTVISITID,
FI.FORMID,
FI.FORMINDEX,
SVF.FORMREFNAME,
SVF.FORMMNEMONIC AS FMLNOM,
EVENT_ITEM.EVENT AS EVENUM,
EVENT_ITEM.EVENT_ROW AS LIGNUM,
NULL AS CODVISEVE,
MIN(DID.MINENTEREDDATE)
OVER (
PARTITION BY FI.SUBJECTID, FI.VISITID, FI.FORMID, FI.FORMINDEX
AS ATTDAT1ERSAI,
MIN(IFSDV.ITEMFIRSTSDV)
OVER (
PARTITION BY FI.SUBJECTID, FI.VISITID, FI.FORMID, FI.FORMINDEX
AS ATTDAT1ERSDV,
MAX(IFSDV.ITEMFIRSTSDV)
OVER (
PARTITION BY FI.SUBJECTID, FI.VISITID, FI.FORMID, FI.FORMINDEX
AS ATTDATDERSDV,
DECODE (AF.SDVCOMPLETESTATE,
0,
'N',
1,
'Y')
AS ATTINDSDVCOP,
AF.FMINSDVCOMPLETESTATE AS ATTDAT1ERSDVCOP,
DECODE (AF.SDVPARTIALSTATE,
0,
'N',
1,
'Y')
AS ATTINDSDVPTL,
EVENT_ITEM.EVENT_RELECT AS ATTINDRVUMEDCOP,
DECODE (QUERY.NBQSTFML, NULL, 'N', 'Y') AS ATTINDQST,
DECODE (AF.MISSINGITEMSSTATE,
0,
'N',
1,
'Y')
AS ATTINDITMABS,
DECODE (AF.FROZENSTATE,
0,
'N',
1,
'Y')
AS ATTINDETACON,
AF.FMINFROZENSTATE AS ATTDAT1ERCON,
AF.FMAXFROZENSTATE AS ATTDATDERCON,
DECODE (AF.DELETEDSTATE,
0,
'N',
1,
'Y')
AS ATTINDETASPR,
EVENT_ITEM.ROW_DELETED AS ATTINDLIGSPR
FROM CL238093011.MVECRF_FORMITEMS FI,
CL238093011.MVECRF_STUDYVERSION_FORMS SVF,
CL238093011.MVECRF_ACTIVATED_FORMS AF,
CL238093011.MVECRF_ITEM_SDV IFSDV,
CL238093011.MVECRF_VISIT_REVS VR,
CL238093011.MVECRF_ITEMDATA DID,
(SELECT DISTINCT
SUBJECTID,
VISITID,
FORMID,
FORMINDEX,
COUNT (
DISTINCT QUERYID
OVER (
PARTITION BY SUBJECTID, VISITID, FORMID, FORMINDEX
NBQSTFML
FROM CL238093011.MVECRF_CUR_QUERY
WHERE QUERYSTATE IN (0, 1, 2)) QUERY,
CL238093011.FLO_FML_EVENT EVENT_ITEM
WHERE (AF.VISITDELETED IS NULL OR AF.VISITDELETED = 0)
AND AF.FORMTYPE NOT IN (4, 5, 6, 7, 8, 103)
AND (AF.DELETEDDYNAMICFORMSTATE IS NULL
OR AF.DELETEDDYNAMICFORMSTATE = 0)
AND FI.SUBJECTVISITID = AF.SUBJECTVISITID
AND FI.FORMID = AF.FORMID
AND FI.FORMREV = AF.FORMREV
AND FI.FORMINDEX = AF.FORMINDEX
AND FI.VISITID = VR.VISITID
AND FI.VISITREV = VR.VISITREV
AND FI.CONTEXTID = IFSDV.CONTEXTID(+)
AND FI.CONTEXTID = DID.CONTEXTID(+)
AND FI.SUBJECTID = QUERY.SUBJECTID(+)
AND FI.VISITID = QUERY.VISITID(+)
AND FI.FORMID = QUERY.FORMID(+)
AND FI.FORMINDEX = QUERY.FORMINDEX(+)
AND FI.STUDYVERSIONID = SVF.STUDYVERSIONID
AND FI.FORMID = SVF.FORMID
AND FI.VISITID = SVF.VISITID
AND FI.SUBJECTID = EVENT_ITEM.SUBJECTID(+)
AND FI.VISITID = EVENT_ITEM.VISITID(+)
AND FI.FORMID = EVENT_ITEM.FORMID(+)
AND FI.FORMINDEX = EVENT_ITEM.FORMINDEX(+)user12045475 wrote:
Hi
how can I speed up the query below ?
All time is in analytic function (WINDOW SORT)
Thanks for your help
11.2.0.1
Rows Row Source Operation
28987 HASH UNIQUE (cr=12677 pr=155778 pw=109730 time=25010 us cost=5502 size=3972960 card=14880)
1668196 WINDOW SORT (cr=12677 pr=155778 pw=109730 time=890411840 us cost=5502 size=3972960 card=14880)
1668196 HASH JOIN RIGHT OUTER (cr=12677 pr=0 pw=0 time=1069165 us cost=3787 size=3972960 card=14880)
30706 TABLE ACCESS FULL FLO_FML_EVENT (cr=270 pr=0 pw=0 time=7420 us cost=56 size=814158 card=30154)
194733 HASH JOIN RIGHT OUTER (cr=12407 pr=0 pw=0 time=571145 us cost=3730 size=3571200 card=14880)
613 VIEW (cr=342 pr=0 pw=0 time=489 us cost=71 size=23840 card=745)
613 HASH UNIQUE (cr=342 pr=0 pw=0 time=244 us cost=71 size=20115 card=745)
745 WINDOW SORT (cr=342 pr=0 pw=0 time=1736 us cost=71 size=20115 card=745)
745 MAT_VIEW ACCESS FULL MVECRF_CUR_QUERY (cr=342 pr=0 pw=0 time=1736 us cost=69 size=20115 card=745)
194733 HASH JOIN (cr=12065 pr=0 pw=0 time=431813 us cost=3658 size=3095040 card=14880)
43 MAT_VIEW ACCESS FULL MVECRF_VISIT_REVS (cr=3 pr=0 pw=0 time=0 us cost=2 size=946 card=43)
194733 HASH JOIN OUTER (cr=12062 pr=0 pw=0 time=292098 us cost=3656 size=2767680 card=14880)
194733 HASH JOIN OUTER (cr=10553 pr=0 pw=0 time=234394 us cost=2962 size=2574240 card=14880)
194733 HASH JOIN (cr=9999 pr=0 pw=0 time=379996 us cost=2570 size=2380800 card=14880)
30076 MAT_VIEW ACCESS FULL MVECRF_ACTIVATED_FORMS (cr=1817 pr=0 pw=0 time=28411 us cost=361 size=2000285 card=29855)
194733 HASH JOIN (cr=8182 pr=0 pw=0 time=209061 us cost=1613 size=9026301 card=97057)
628 MAT_VIEW ACCESS FULL MVECRF_STUDYVERSION_FORMS (cr=19 pr=0 pw=0 time=250 us cost=6 size=18212 card=628)
194733 MAT_VIEW ACCESS FULL MVECRF_FORMITEMS (cr=8163 pr=0 pw=0 time=80733 us cost=1606 size=12462912 card=194733)
132342 MAT_VIEW ACCESS FULL MVECRF_ITEM_SDV (cr=554 pr=0 pw=0 time=23678 us cost=112 size=1720446 card=132342)
221034 MAT_VIEW ACCESS FULL MVECRF_ITEMDATA (cr=1509 pr=0 pw=0 time=46459 us cost=299 size=2873442 card=221034)
SELECT
DISTINCT
'CL238093011' AS ETUDE,
FI.STUDYID,
FI.STUDYVERSIONID,
FI.SITEID,
FI.SUBJECTID,
FI.VISITID,
VR.VISITREFNAME,
FI.SUBJECTVISITID,
FI.FORMID,
FI.FORMINDEX,
SVF.FORMREFNAME,
SVF.FORMMNEMONIC AS FMLNOM,
EVENT_ITEM.EVENT AS EVENUM,
EVENT_ITEM.EVENT_ROW AS LIGNUM,
NULL AS CODVISEVE,
MIN(DID.MINENTEREDDATE)
OVER (
PARTITION BY FI.SUBJECTID, FI.VISITID, FI.FORMID, FI.FORMINDEX
AS ATTDAT1ERSAI,
MIN(IFSDV.ITEMFIRSTSDV)
OVER (
PARTITION BY FI.SUBJECTID, FI.VISITID, FI.FORMID, FI.FORMINDEX
AS ATTDAT1ERSDV,
MAX(IFSDV.ITEMFIRSTSDV)
OVER (
PARTITION BY FI.SUBJECTID, FI.VISITID, FI.FORMID, FI.FORMINDEX
AS ATTDATDERSDV,
DECODE (AF.SDVCOMPLETESTATE,
0,
'N',
1,
'Y')
AS ATTINDSDVCOP,
AF.FMINSDVCOMPLETESTATE AS ATTDAT1ERSDVCOP,
DECODE (AF.SDVPARTIALSTATE,
0,
'N',
1,
'Y')
AS ATTINDSDVPTL,
EVENT_ITEM.EVENT_RELECT AS ATTINDRVUMEDCOP,
DECODE (QUERY.NBQSTFML, NULL, 'N', 'Y') AS ATTINDQST,
DECODE (AF.MISSINGITEMSSTATE,
0,
'N',
1,
'Y')
AS ATTINDITMABS,
DECODE (AF.FROZENSTATE,
0,
'N',
1,
'Y')
AS ATTINDETACON,
AF.FMINFROZENSTATE AS ATTDAT1ERCON,
AF.FMAXFROZENSTATE AS ATTDATDERCON,
DECODE (AF.DELETEDSTATE,
0,
'N',
1,
'Y')
AS ATTINDETASPR,
EVENT_ITEM.ROW_DELETED AS ATTINDLIGSPR
FROM CL238093011.MVECRF_FORMITEMS FI,
CL238093011.MVECRF_STUDYVERSION_FORMS SVF,
CL238093011.MVECRF_ACTIVATED_FORMS AF,
CL238093011.MVECRF_ITEM_SDV IFSDV,
CL238093011.MVECRF_VISIT_REVS VR,
CL238093011.MVECRF_ITEMDATA DID,
(SELECT DISTINCT
SUBJECTID,
VISITID,
FORMID,
FORMINDEX,
COUNT (
DISTINCT QUERYID
OVER (
PARTITION BY SUBJECTID, VISITID, FORMID, FORMINDEX
NBQSTFML
FROM CL238093011.MVECRF_CUR_QUERY
WHERE QUERYSTATE IN (0, 1, 2)) QUERY,
CL238093011.FLO_FML_EVENT EVENT_ITEM
WHERE (AF.VISITDELETED IS NULL OR AF.VISITDELETED = 0)
AND AF.FORMTYPE NOT IN (4, 5, 6, 7, 8, 103)
AND (AF.DELETEDDYNAMICFORMSTATE IS NULL
OR AF.DELETEDDYNAMICFORMSTATE = 0)
AND FI.SUBJECTVISITID = AF.SUBJECTVISITID
AND FI.FORMID = AF.FORMID
AND FI.FORMREV = AF.FORMREV
AND FI.FORMINDEX = AF.FORMINDEX
AND FI.VISITID = VR.VISITID
AND FI.VISITREV = VR.VISITREV
AND FI.CONTEXTID = IFSDV.CONTEXTID(+)
AND FI.CONTEXTID = DID.CONTEXTID(+)
AND FI.SUBJECTID = QUERY.SUBJECTID(+)
AND FI.VISITID = QUERY.VISITID(+)
AND FI.FORMID = QUERY.FORMID(+)
AND FI.FORMINDEX = QUERY.FORMINDEX(+)
AND FI.STUDYVERSIONID = SVF.STUDYVERSIONID
AND FI.FORMID = SVF.FORMID
AND FI.VISITID = SVF.VISITID
AND FI.SUBJECTID = EVENT_ITEM.SUBJECTID(+)
AND FI.VISITID = EVENT_ITEM.VISITID(+)
AND FI.FORMID = EVENT_ITEM.FORMID(+)
AND FI.FORMINDEX = EVENT_ITEM.FORMINDEX(+)
Do you have the license for parallel query (may/may not help)? PQO can help with sorts ... -
Creating a query with group function and non group function
Could anyone help me with creating a query that contain single row function and multiple row function in Report6i.
what i want to do basically is to create a query that will display sum of certain columns according to a column in that tableYou can either calculate a sum yourself, or let Reports do it for you.
1. select sum(column) from table where ....
This will just display the sum, not the records.
2. Make a query: select column from table where ...
Create a summary field. You can do it manually or with the report wizard.
That will create a report like this:
Column
10
20
15
======
Sum 45 -
My table has columns A,B & C with data as below
A B C
X 1 1
1 X 1
1 1 X
Result should be all ‘Z’ inserted right to ‘X’ & must look like as below
A B C
X Z Z
1 X Z
1 1 X
Please check the below query & help me to modify the query as the result for column b is not correct.
select a,decode(b,'1','Z','X') b,decode(c,'1','Z','X') c
from test;try
With Data As
Select 'X' A,'1' B, '1' C From Dual Union All
Select '1','X','1' From Dual Union All
Select '1','1','X' From Dual
Select A, (Case When A ='X' And B='1' Then 'Z' Else B End) B,
(Case When (A='X' Or B='X') And C='1' Then 'Z' Else C end)C
from dataVivek L -
Maintenance Planning with extra functions
Hi Gurus,
I want to schedule plan with client requirement that,
once plan get due, clients maintenance respnsible person has to get SMS on his mobile & E-mail regarding due call.
Plz let me know, Is it possible?
Plz tell me steps to do it?
Thanks in Advance...
Regards,
Amol.Amol,
You develop a solution (ABAP and/or Workflow) which sends an SMS from the PM/CS order
PeteA -
Hi,
Please find below table structure and insert scritps. Requesting for vluable help.
create table temp2 (col1 number,col2 varchar2(10),col3 number,col4 varchar2(20));
insert into temp2 values (1,'a',100,'vvv');
insert into temp2 values (2,'b',200,'www');
insert into temp2 values (3,'c',300,'xxx');
insert into temp2 values (4,'d',400,'yyy');
insert into temp2 values (5,'e',500,'zzz');
insert into temp2 values (6,'f',600,'aaa');
insert into temp2 values (7,'g',700,'bbb');
insert into temp2 values (8,'h',800,'ccc');
I am trying to get same output, what we get from below UNION query with ANALYTICAL Function.
select * from temp2 where col1 in (1,2,3,4,5)
union
select * from temp2 where col1 in (1,2,5,6)
union
select * from temp2 where col1 in (1,2,7,8);
I am seeking help by this dummy example to understand the concept, how can we use analytical functional over UNION or OUTER JOINS.
In my exact query, I am using same table three times adding UNION clause. here also we scan temp2 three times, so for bulky tables using 'union' would be hampering query's performance
It means i go with three time scans of same table that is not performance oriented. With the help of above required concept, i will try to remove UNIONs from my exact query.
Thanks!!Thanks for your time BluShadow and sorry as i think i couldn't make my query clear.
I try it again. Below there are three queries, you may see all three queries are using same tables. Difference in all three queries are just few conditions, which makes all three queries diff with each other.
I know, u cant run below query in your database, but i think it will convey my doubt to you. I have mentioned no. of rows with each clause and total i am getting 67 rows as my output. (Reason may be first n third query's result set are the subset of Second Query dataset)
So i want to take all common rows as well as additional rows, if present in any of the query. This is getting easliy done with UNION clause but want to have it in other way as here my same is getting scanned again n again.
SELECT
START_TX.FX_TRAN_ID START_FX_TRAN_ID
,END_TX.FX_TRAN_ID END_FX_TRAN_ID
,START_TX.ENTERED_DT_TS
,USER
,START_TX.TRADE_DT
,START_TX.DEAL_NUMBER
,START_TX.FX_DEAL_TYPE
,START_TX.ORIENTATION_BUYSELL
,START_TX.BASE_CCY
,START_TX.BASE_CCY_AMT
,START_TX.SECONDARY_CCY
,START_TX.SECONDARY_CCY_AMT
,START_TX.MATURITY_DT
,START_TX.TRADE_RT
,START_TX.FORWARD_PTS
,START_TX.CORPORATE_PIPS
,START_TX.DEAL_OWNER_INITIALS
,START_TX.CORPORATE_DEALER
,START_TX.PROFIT_CENTER_CD
,START_TX.COUNTERPARTY_NM
,START_TX.COUNTERPARTY_NUMBER
FROM
(SELECT * FROM FX_TRANSACTIONS WHERE GMT_CONV_ENTERED_DT_TS >= TO_DATE('20-Nov-2013 4:00:01 AM','DD-Mon-YYYY HH:MI:SS AM')) START_TX
INNER JOIN
(SELECT * FROM FX_TRANSACTIONS WHERE GMT_CONV_ENTERED_DT_TS <= TO_DATE('20-Nov-2013 4:59:59 PM','DD-Mon-YYYY HH:MI:SS AM')) END_TX
ON START_TX.COUNTERPARTY_NM = END_TX.COUNTERPARTY_NM AND
START_TX.COUNTERPARTY_NUMBER = END_TX.COUNTERPARTY_NUMBER AND
START_TX.FX_DEAL_TYPE = END_TX.FX_DEAL_TYPE AND
START_TX.BASE_CCY = END_TX.BASE_CCY AND
START_TX.SECONDARY_CCY = END_TX.SECONDARY_CCY AND
NVL(START_TX.CORPORATE_DEALER,'nullX')=NVL(END_TX.CORPORATE_DEALER,'nullX') AND
START_TX.ORIENTATION_BUYSELL='B' AND
END_TX.ORIENTATION_BUYSELL='S' AND
START_TX.FX_TRAN_ID = 1850718 AND
(START_TX.BASE_CCY_AMT = END_TX.BASE_CCY_AMT
OR
START_TX.SECONDARY_CCY_AMT = END_TX.SECONDARY_CCY_AMT) -- 10 Rows
UNION
SELECT
START_TX.FX_TRAN_ID START_FX_TRAN_ID
,END_TX.FX_TRAN_ID END_FX_TRAN_ID
,START_TX.ENTERED_DT_TS
,USER
,START_TX.TRADE_DT
,START_TX.DEAL_NUMBER
,START_TX.FX_DEAL_TYPE
,START_TX.ORIENTATION_BUYSELL
,START_TX.BASE_CCY
,START_TX.BASE_CCY_AMT
,START_TX.SECONDARY_CCY
,START_TX.SECONDARY_CCY_AMT
,START_TX.MATURITY_DT
,START_TX.TRADE_RT
,START_TX.FORWARD_PTS
,START_TX.CORPORATE_PIPS
,START_TX.DEAL_OWNER_INITIALS
,START_TX.CORPORATE_DEALER
,START_TX.PROFIT_CENTER_CD
,START_TX.COUNTERPARTY_NM
,START_TX.COUNTERPARTY_NUMBER
FROM
(SELECT * FROM FX_TRANSACTIONS WHERE GMT_CONV_ENTERED_DT_TS >= TO_DATE('20-Nov-2013 4:00:01 AM','DD-Mon-YYYY HH:MI:SS AM')) START_TX
INNER JOIN
(SELECT * FROM FX_TRANSACTIONS WHERE GMT_CONV_ENTERED_DT_TS <= TO_DATE('20-Nov-2013 4:59:59 PM','DD-Mon-YYYY HH:MI:SS AM')) END_TX
ON START_TX.COUNTERPARTY_NM = END_TX.COUNTERPARTY_NM AND
START_TX.COUNTERPARTY_NUMBER = END_TX.COUNTERPARTY_NUMBER AND
START_TX.FX_DEAL_TYPE = END_TX.FX_DEAL_TYPE AND
START_TX.BASE_CCY = END_TX.BASE_CCY AND
START_TX.SECONDARY_CCY = END_TX.SECONDARY_CCY AND
NVL(START_TX.CORPORATE_DEALER,'nullX')=NVL(END_TX.CORPORATE_DEALER,'nullX') AND
START_TX.FX_TRAN_ID = 1850718 AND
START_TX.ORIENTATION_BUYSELL='B' AND
END_TX.ORIENTATION_BUYSELL='S' -- 67 Rows
UNION
SELECT
START_TX.FX_TRAN_ID START_FX_TRAN_ID
,END_TX.FX_TRAN_ID END_FX_TRAN_ID
,START_TX.ENTERED_DT_TS
,USER
,START_TX.TRADE_DT
,START_TX.DEAL_NUMBER
,START_TX.FX_DEAL_TYPE
,START_TX.ORIENTATION_BUYSELL
,START_TX.BASE_CCY
,START_TX.BASE_CCY_AMT
,START_TX.SECONDARY_CCY
,START_TX.SECONDARY_CCY_AMT
,START_TX.MATURITY_DT
,START_TX.TRADE_RT
,START_TX.FORWARD_PTS
,START_TX.CORPORATE_PIPS
,START_TX.DEAL_OWNER_INITIALS
,START_TX.CORPORATE_DEALER
,START_TX.PROFIT_CENTER_CD
,START_TX.COUNTERPARTY_NM
,START_TX.COUNTERPARTY_NUMBER
FROM
(SELECT * FROM FX_TRANSACTIONS WHERE GMT_CONV_ENTERED_DT_TS >= TO_DATE('20-Nov-2013 4:00:01 AM','DD-Mon-YYYY HH:MI:SS AM')) START_TX
INNER JOIN
(SELECT * FROM FX_TRANSACTIONS WHERE GMT_CONV_ENTERED_DT_TS <= TO_DATE('20-Nov-2013 4:59:59 PM','DD-Mon-YYYY HH:MI:SS AM')) END_TX
ON START_TX.COUNTERPARTY_NM = END_TX.COUNTERPARTY_NM AND
START_TX.COUNTERPARTY_NUMBER = END_TX.COUNTERPARTY_NUMBER AND
START_TX.FX_DEAL_TYPE = END_TX.FX_DEAL_TYPE AND
START_TX.BASE_CCY = END_TX.BASE_CCY AND
START_TX.SECONDARY_CCY = END_TX.SECONDARY_CCY AND
NVL(START_TX.CORPORATE_DEALER,'nullX')=NVL(END_TX.CORPORATE_DEALER,'nullX') AND
START_TX.ORIENTATION_BUYSELL='B' AND
END_TX.ORIENTATION_BUYSELL='S' AND
START_TX.FX_TRAN_ID = 1850718 AND
END_TX.BASE_CCY_AMT BETWEEN (START_TX.BASE_CCY_AMT - (START_TX.BASE_CCY_AMT * :PERC_DEV/100)) AND (START_TX.BASE_CCY_AMT + (START_TX.BASE_CCY_AMT * :PERC_DEV/100))
OR
END_TX.SECONDARY_CCY_AMT BETWEEN (START_TX.SECONDARY_CCY_AMT - (START_TX.SECONDARY_CCY_AMT*:PERC_DEV/100) ) AND (START_TX.SECONDARY_CCY_AMT + (START_TX.SECONDARY_CCY_AMT*:PERC_DEV/100))
); --- 10 Rows -
BEx query with variant from ABAP
Hello,
I'm looking for possibility to start BEx query with variant (variant is created with tx RSRT) from ABAP. There are some funktion modules, which start queries (launch excel), for example RSAH_LAUNCH_EXCEL or RSSEM_QUERY_LAUNCH, but they are ending with short dump, when there are variables in the query. Is there any standard FM, which starts the query with variant or accepts parameters?
regards,
KrzysztofHi,
the short dump was my fault, I've passed query name instead of genuniid to the RSAH_LAUNCH_EXCEL.
What I'm trying to do is to I'll start BEx query with parameters (I don't want to get selection-screen from the query, I need to fill it from ABAP).
Here is my example, which is not working.
DATA:
lv_query(30) TYPE c,
lv_genuniid TYPE rsrrepdir-genuniid,
ls_var TYPE rrx_var,
lt_var TYPE TABLE OF rrx_var.
lv_query = 'YB_MAKLER_DETAIL'.
CALL FUNCTION 'CONVERSION_EXIT_GENID_INPUT'
EXPORTING
input = lv_query
IMPORTING
output = lv_genuniid.
IF lv_genuniid = ''.
WRITE: / 'There is no Query', lv_query.
ELSE.
ls_var-vnam = 'YS_MKLE'.
ls_var-sign = 'I'.
ls_var-opt = 'EQ'.
ls_var-low = '0000005100'.
APPEND ls_var TO lt_var.
ls_var-vnam = 'YS_VTGJ'.
ls_var-sign = 'I'.
ls_var-opt = 'EQ'.
ls_var-low = '1999'.
APPEND ls_var TO lt_var.
CALL FUNCTION 'RSAH_LAUNCH_EXCEL'
EXPORTING
i_genuniid = lv_genuniid
I_OBJVERS = 'A'
i_hide_sapgui = 'X'
TABLES
I_T_VAR = lt_var.
ENDIF.
If parameter 'i_hide_sapgui' is empty, I'm getting empty selection-screen,
If parameter 'i_hide_sapgui' equals 'X' I'm getting selection-screen filled with values, which were used last time manualy, not with values from the internal table 'lt_var'.
Do you have any idea how to pass parameters to the query with this function module?
Regards,
Krzysztof -
Need complex query with joins and AGGREGATE functions.
Hello Everyone ;
Good Morning to all ;
I have 3 tables with 2 lakhs record. I need to check query performance.. How CBO rewrites my query in materialized view ?
I want to make complex join with AGGREGATE FUNCTION.
my table details
SQL> select from tab;*
TNAME TABTYPE CLUSTERID
DEPT TABLE
PAYROLL TABLE
EMP TABLE
SQL> desc emp
Name
EID
ENAME
EDOB
EGENDER
EQUAL
EGRADUATION
EDESIGNATION
ELEVEL
EDOMAIN_ID
EMOB_NO
SQL> desc dept
Name
EID
DNAME
DMANAGER
DCONTACT_NO
DPROJ_NAME
SQL> desc payroll
Name
EID
PF_NO
SAL_ACC_NO
SALARY
BONUS
I want to make complex query with joins and AGGREGATE functions.
Dept names are : IT , ITES , Accounts , Mgmt , Hr
GRADUATIONS are : Engineering , Arts , Accounts , business_applications
I want to select records who are working in IT and ITES and graduation should be "Engineering"
salary > 20000 and < = 22800 and bonus > 1000 and <= 1999 with count for males and females Separately ;
Please help me to make a such complex query with joins ..
Thanks in advance ..
Edited by: 969352 on May 25, 2013 11:34 AM969352 wrote:
why do you avoid providing requested & NEEDED details?I do NOT understand what do you expect ?
My Goal is :
1. When executing my own query i need to check expalin plan.please proceed to do so
http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_9010.htm#SQLRF01601
2. IF i enable query rewrite option .. i want to check explain plan ( how optimizer rewrites my query ) ? please proceed to do so
http://docs.oracle.com/cd/E11882_01/server.112/e16638/ex_plan.htm#PFGRF009
3. My only aim is QUERY PERFORMANCE with QUERY REWRITE clause in materialized view.It is an admirable goal.
Best Wishes on your quest for performance improvements.
Maybe you are looking for
-
We have several laptops that we need to install Vista on. We would prefer 64-bit so that we can really make use of the extra RAM these laptops have, however there is one program we require holding us back to 32-bit at the moment. Its the Cisco VPN Cl
-
BEx query based on virtual cube donu00B4t display a valid List of Value (LOV)
Hello I have a problem with an invalid LOV. The scenario is the following; There´s a BEx query based on a virtual cube. The query has an exit variable on caracteristic that is based on 0CALMONTH. At Universe Designer I simply create a connection, a u
-
How to get information about limitation Internal Memory on device
hallo .. have some question here, so please some person able to answer my questions 1. How to get Information about limitation internal memory on device 2. is possible to improve internal memory on Blackberry ( move apps on external memory ) 3. any
-
Error " TR should have atleast one line item "
Hi, While trying to create TO for the TR , system through the error " TR should have atleast one line item " but the TR have the line item. pls trhu some light. actually it properly working in development server but not working in production.
-
I currently have over 17,000 photos in iPhoto. I really need something more to organize my photos. I have downloaded the trial version of Aperture and have imported my iPhoto library (referenced). What are the advantages/disadvantages of reference