Combination to_number To_char
Hi allI need to do the following
Code:
Select ´a´ * 3 double;
The result should be ´aaa´
I ve tried this
Code:
Select to_char (to_number (´a´)) * 3) double;
This doesn´t works correctly.
Can someone help me?
and what happens if I need to do:
Code:
Select (´name´) * 2 double;
where the result is to be ´namename´
Hope you can help out me.
Thank you
Kiekster
Hello
Welcome to the forum!
You can do something like this:
SELECT ename
, deptno
, RPAD ( ename
, LENGTH (ename) * deptno / 10
, ename
) AS ename_rep
FROM scott.emp
;
Output:
ENAME DEPTNO ENAME_REP
---------- ---------- ----------------------------------------
SMITH 20 SMITHSMITH
ALLEN 30 ALLENALLENALLEN
WARD 30 WARDWARDWARD
JONES 20 JONESJONES
MARTIN 30 MARTINMARTINMARTIN
BLAKE 30 BLAKEBLAKEBLAKE
CLARK 10 CLARK
SCOTT 20 SCOTTSCOTT
KING 10 KING
TURNER 30 TURNERTURNERTURNER
ADAMS 20 ADAMSADAMS
JAMES 30 JAMESJAMESJAMES
FORD 20 FORDFORD
MILLER 10 MILLER
As you can see, ename_rep is repeated ename. Everyone with deptno = 10 a name repeated only once, everyone with deptno = 20 a their name repeated 2 times and everyone with deptno = 30 a their name repeated 3 times.
Published by: Frank Kulash on October 22, 2012 15:01
Example changed to use scott.emp
Published by: Frank Kulash on October 22, 2012 15:06
Tags: Database
Similar Questions
-
Hi all
I little bit on (), TO_DATE (), () TO_NUMBER TO_CHAR confusion.
Can you please explain when to use which works with examples.
Thank you and best regards,
-
ORA-06502 use TO_NUMBER TO_CHAR
Hello
Oracle Database 10g 10.2.0.5.0.
I have the error in this code:
I have to use "TO_CHAR"... but my test is not failure, why? :nSuper_ NUMBER(6,2); ... dbms_output.put_line('Super: ' || TO_NUMBER(nSuper_,'FM9G990D90')); ...
Why 'a' step missed and 'b' in case of failure?--a) SET SERVEROUTPUT ON DECLARE nSuper_ NUMBER(6,2); BEGIN nSuper_ := 666.12; dbms_output.put_line('Super: ' || TO_NUMBER(nSuper_,'FM9G990D90')); END; / Super: 666,12 --b) SET SERVEROUTPUT ON DECLARE nSuper_ NUMBER(6,2); BEGIN nSuper_ := 6666.12; dbms_output.put_line('Super: ' || TO_NUMBER(nSuper_,'FM9G990D90')); END; / DECLARE * ERROR en línea 1: ORA-06502: PL/SQL: error numérico o de valor ORA-06512: en línea 5 --c) SET SERVEROUTPUT ON DECLARE nSuper_ NUMBER(6,2); BEGIN nSuper_ := 6666.12; dbms_output.put_line('Super: ' || TO_CHAR(nSuper_,'FM9G990D90')); END; / Super: 6.666,12
Hello
jortri wrote:
Why 'a' step missed and 'b' in case of failure?Because Oracle RDBMS is (too) soft on you for the conversion of 'simple' like that (but that does not mean that you will get errors...).
To_number function takes as input a string.
You send her a number, then Oracle does this: + "Ok this guy is sending a number in a TO_NUMBER function when it must be a string, we will do an implicit conversion for him in a transparent way" +. "
In fact, your to_number (my_number_variable, 'FM9G990D90') becomes this:to_number( to_char(my_number_variable) ,'FM9G990D90')
But, as you can see, the function to_char is not given any format, so that it uses your default session, which might be a different way to the mask you provide to to_number function.
Please run this to understand what your failure to_number function receives as input:
select 6666.12 number_implicitly_converted from dual;
By default, on my computer it shows this:
Scott@my11g SQL>select 6666.12 number_implicitly_converted from dual; NUMBER_IMPLICITLY_CONVERTED --------------------------- 6666.12
Now, if I use it as input of your with your format mask to_number function:
Scott@my11g SQL>select TO_NUMBER('6666.12','FM9G990D90') back_to_number from dual; select TO_NUMBER('6666.12','FM9G990D90') back_to_number from dual * ERROR at line 1: ORA-01722: invalid number
Tadammm!
Conclusion: Not to spoil use to_number/to_char/to_date functions.
:-) -
Hi all
I have the following:
Select TO_NUMBER (MYSTRING))
Select to_char (sysdate - (sysdate - 14.5232)) as DOUBLE MYSTRING)
TO_NUMBER (MYSTRING)
-------------------
14,5231944
But I want to have only:
TO_NUMBER (MYSTRING)
-------------------
14.52
Then:
Select TO_NUMBER (MYSTRING, ' 99.99 '))
Select to_char (sysdate - (sysdate - 14.5232)) as DOUBLE MYSTRING)
01722 00000 - "invalid number."
What's wrong?
Thank you.
(on the other hand: on what is the problem? >: maybe calling TO_NUMBER (TO_CHAR (a_number))? ;-))
You have a certain number (SYSDATE - (SYSDATE - 14.5232)), without having to go to a char and then return to the number if your goal is just to see 2 decimal places... You can use the ROUND function (or TRUNC, choose):
SELECT ROUND (SYSDATE - (SYSDATE - 14.5232), 2) FROM dual;
Best regards
Bruno
)
-
Hi friends,
I use oracle 10g and forms 6i with windows 2008 server
I have a request two with different where clause.
I need output like below format
HEADER IMPORT EXPORT
TEST 100 400
Select 'TEST' header, sum (Decode (t.type, 1, amount, amount 3,)) import.
of sales_dtls t
where to_char (t.sales_date, 'YYYYMM') = 201309
and item_code = 1
Select 'TEST' header, sum (Decode (t.type, 2, amount, amount 4)) export.
of sales_dtls t
where to_char (t.sales_date, 'YYYYMM') = 201309
and item_code = 2
Rgds
RDK
You can post a small example of data as well? (CREATE TABLE and INSERT INTO statements).
...
TO_CHAR (t.sales_date, 'YYYYMM') = 201309
Oh, and why you compare strings in numbers?
Always be explicit about the type of data conversions, do:
TO_NUMBER (to_char (t.Sales_Date, 'YYYYMM')) = 201309
or
TO_CHAR (t.sales_date, 'YYYYMM') = '201309'
Is sales_date column indexed, incidentally?
Then using a function (TO_CHAR), optimizer will take is more than the index into consideration...
Not tested, but could be useful to try:
Select header 'TEST '.
, sum (decode (t.type | t.item_code, 11, amount))
31, the amount
)
) import
, sum (decode (t.type | t.item_code, 22, amount))
42, sum)
) export
of sales_dtls t
where to_char (t.sales_date, 'yyyymm') = 201309
and item_code in (1, 2);
-
Creating indexes in to_char
Hello
Try to create inxde on concatentated columns and it puts to_char default, trying to make column of numeric index but same to_number highlighting does not to_number on
With the help of 11.2.03
A tried
create index MEDIA_PLIS_HANDLED_IDX on the MEDIA TO_NUMBER ((TO_CHAR (PLIS_HANDLED_YEAR) |)) LPAD (TO_CHAR (PLIS_HANDLED_WEEK), 2, '0')))
tablespace BI_DW_DATA
create index MEDIA_PLIS_HANDLED_IDX on MEDIA TO_NUMBER (PLIS_HANDLED_YEAR) | LPAD (PLIS_HANDLED_WEEK, 2, 0))
tablespace BI_DW_DATA
Any ideas how to avoid to_char leisure users seeking it has snumeric.
Thank youThe problem is with the function outside the parentheses - it is simply ignored.
It's a quirk of known syntax that does not raise an error.
SQL> create table t1 2 (yr number 3 ,wk number); Table created. SQL> create index i1 on t1 to_number(yr||lpad(wk,2,'0')); Index created. SQL> select column_expression from user_ind_expressions where index_name = 'I1'; COLUMN_EXPRESSION -------------------------------------------------------------------------------- TO_CHAR("YR")||LPAD(TO_CHAR("WK"),2,'0') SQL> drop index i1; Index dropped. SQL> create index i1 on t1 (to_number(yr||lpad(wk,2,'0'))); Index created. SQL> select column_expression from user_ind_expressions where index_name = 'I1'; COLUMN_EXPRESSION -------------------------------------------------------------------------------- TO_NUMBER(TO_CHAR("YR")||LPAD(TO_CHAR("WK"),2,'0')) SQL>
-
Hello
TO_NUMBER function difficult to understand,
Select to_number ('12,000', '9g999d99', 'nls_numeric_characters = "dg" ') of double
*
ERROR on line 1:
ORA-01722: invalid number
SQL > SELECT TO_NUMBER ('17,000, 23', '999G999D99',' nls_numeric_characters = ",".) ') twice;
TO_NUMBER('17.000,23','999G999D99','NLS_NUMERIC_CHARACTERS='',.''')
-------------------------------------------------------------------
17000.23
Don't show any error,
I'm not behind the to_number function... Please help me...797525 wrote:
HelloTO_NUMBER function difficult to understand,
Select to_number ('12,000', '9g999d99', 'nls_numeric_characters = "dg" ') of double
*
ERROR on line 1:
ORA-01722: invalid numberSQL > SELECT TO_NUMBER ('17,000, 23', '999G999D99',' nls_numeric_characters = ",".) ') twice;
TO_NUMBER('17.000,23','999G999D99','NLS_NUMERIC_CHARACTERS='',.''')
-------------------------------------------------------------------
17000.23Don't show any error,
I'm not behind the to_number function... Please help me...
I've tried a few others, and it seems that you quote your nls_numeric_chacacters bad...
SQL> select to_char('17000.45','999G999D99','nls_numeric_characters=dg') from dual; TO_CHAR('17 ----------- 17g000d45 SQL> select to_number(to_char('17000.45','999G999D99','nls_numeric_characters=dg'),'999G999D99','nls_numeric_characters=dg') from dual; TO_NUMBER(TO_CHAR('17000.45','999G999D99','NLS_NUMERIC_CHARACTERS=DG'),'999G999D -------------------------------------------------------------------------------- 17000.45
or to simplify
SQL> select to_number('17g000d45','999G999D99','nls_numeric_characters=dg') from dual; TO_NUMBER('17G000D45','999G999D99','NLS_NUMERIC_CHARACTERS=DG') --------------------------------------------------------------- 17000.45
If you want to display a number with the given separator (g & d), you must use the function to_char and to_number function not.
HtH
JohanPublished by: Johan Nilsson on April 4, 2011 06:03
-
How to use to_number function
Hello
How to convert Date value in numbers
For example: sysdate-> 3092008
You can me referring to the example query please on this...
Thank youSelect to_number (to_char (sysdate, 'ddmmyyyy')) of the double
or by check
Published by: user647181 on September 30, 2008 02:18
-
Subquery Factoring - cardinality estimate good but bad sql response times
This is Exadata 11.2.0.4.0 database, all tables have statistics of up to date. Cardinality estimation is good compared to the actual cardinality. It is a way to tune this sql to reduce its response time.
Sorry for the long sql and the execution plan.
WITH SUBWITH0 AS (SELECT D1.c1 AS c1 FROM ( (SELECT D1.c1 AS c1 FROM (SELECT DISTINCT T7171.CH_ID_SYM AS c1 FROM DW.TM_R_REP T7171 WHERE ( T7171.CHILD_REP_ID = 939 ) ) D1 UNION SELECT D1.c1 AS c1 FROM (SELECT DISTINCT T7167.MEMBER_KEY_SYM AS c1 FROM DW.PC_T_REP T7167 WHERE ( T7167.ANCESTOR_KEY = 939 ) ) D1 ) ) D1 ), SUBWITH1 AS (SELECT D1.c1 AS c1 FROM ( (SELECT D1.c1 AS c1 FROM (SELECT DISTINCT T7171.CH_ID_SYM AS c1 FROM DW.TM_R_REP T7171 WHERE ( T7171.CHILD_REP_ID = 939 ) ) D1 UNION SELECT D1.c1 AS c1 FROM (SELECT DISTINCT T7167.MEMBER_KEY_SYM AS c1 FROM DW.PC_T_REP T7167 WHERE ( T7167.ANCESTOR_KEY = 939 ) ) D1 ) ) D1 ), SUBWITH2 AS (SELECT DISTINCT T7171.CH_ID_SYM AS c1 FROM ( DW.PC_T_REP T7167 LEFT OUTER JOIN DW.TM_R_REP T7171 ON T7167.ANCESTOR_KEY = T7171.CHILD_REP_ID AND T7167.SALESYEARMONTH = T7171.SALES_YEAR_MONTH) LEFT OUTER JOIN DW.TM_REP T6715 ON T7171.CHILD_REP_ID_N = T6715.REP_ID WHERE ( CASE WHEN T7171.CHILD_REP_ID_N LIKE '9999%' THEN concat(concat('UNASSIGNED', lpad(' ', 2)), CAST(T7167.TERRITORY_ID AS VARCHAR ( 20 ) )) ELSE concat(concat(concat(concat(T6715.FIRST_NAME, lpad(' ', 2)), T6715.MIDDLE_NAME), lpad(' ', 2)), T6715.LAST_NAME) END = 'JOES CRAMER' AND T7171.SALES_YEAR_MONTH BETWEEN '201505' AND '201505' AND T7171.CH_ID_SYM IN (SELECT DISTINCT D1.c1 AS c1 FROM SUBWITH0 D1 ) ) ), SUBWITH3 AS (SELECT MEMBER_KEY_SYM AS c1 FROM DW.PC_T_REP T7167 WHERE ( IS_LEAF = 1 ) ), SAWITH0 AS (SELECT DISTINCT CASE WHEN T7171.CHILD_REP_ID_N LIKE '9999%' THEN concat(concat('UNASSIGNED', lpad(' ', 2)), CAST(T7167.TERRITORY_ID AS VARCHAR ( 20 ) )) ELSE concat(concat(concat(concat(T6715.FIRST_NAME, lpad(' ', 2)), T6715.MIDDLE_NAME), lpad(' ', 2)), T6715.LAST_NAME) END AS c1, T6715.REP_NUM AS c2, T7171.SALES_YEAR_MONTH AS c3, T7315.MONTH_NUMERIC AS c4, CASE WHEN T7171.CH_ID_SYM IN (SELECT D1.c1 AS c1 FROM SUBWITH3 D1 ) THEN 1 ELSE 0 END AS c5, CAST(T7171.PARENT_REP_ID AS CHARACTER ( 30 ) ) AS c6, T7171.CH_ID_SYM AS c7, T7171.PARENT_REP_ID_SYM AS c8 FROM DW.TIM_MON T7315 , ( ( DW.PC_T_REP T7167 LEFT OUTER JOIN ( (SELECT TO_NUMBER(TO_CHAR(L_OPP.CloseDate,'YYYYMM')) AS Sales_Year_Month, Tm_Rep.Rep_Id AS Rep_Id, L_OPP.Account_Name__C AS Account_Name__C, L_OPP.Closedate AS Closedate, L_OPP.Forecastcategory AS Forecastcategory, L_OPP.Forecastcategoryname AS Forecastcategoryname, L_User.NAME AS Opp_Owner_S_Sales_Org__C, L_OPP.Opportunity_Id__C AS Opportunity_Id__C, L_OPP.Renewal_Date__C AS Renewal_Date__C, L_OPP.Total_Incremental__C AS Total_Incremental__C, L_OPP.Offer_Code__C AS Offer_Code__C, L_OPP.ID AS Opportunity_ID, L_OPP.TERRITORYID AS TERRITORYID, L_OPP.ACCOUNTID AS ACCOUNTID, L_OPP.OWNERID AS OWNERID, L_OPP.TOTAL_RENEWAL__C AS TOTAL_RENEWAL__C, L_OPP.NAME AS NAME, L_OPP.STAGENAME AS STAGE_NAME, L_OPP.STAGE_DESCRIPTION__C AS STAGE_DESCRIPTION, NVL( CASE WHEN L_OPP.Forecastcategory = 'Closed' AND( OPP_C_DIM.OPPORTUNITIES_GROUP IS NULL ) THEN L_OPP.Total_Incremental__C END , 0) AS Closed_Oppurtunity, CASE WHEN L_OPP.Forecastcategory = 'Closed' AND ( OPP_C_DIM.OPPORTUNITIES_GROUP IS NULL ) THEN 'Closed_Oppurtunity_Drill' END AS Closed_Oppurtunity_Drill, NVL( CASE WHEN L_OPP.Forecastcategoryname IN ('Pipeline', 'Potential', 'Commit') AND ( OPP_C_DIM.OPPORTUNITIES_GROUP IS NULL ) THEN L_OPP.Total_Incremental__C END , 0) AS OPEN_Oppurtunity, CASE WHEN L_OPP.Forecastcategoryname IN ('Pipeline', 'Potential', 'Commit') AND ( OPP_C_DIM.OPPORTUNITIES_GROUP IS NULL ) THEN 'OPEN_Oppurtunity_Drill' END AS OPEN_Oppurtunity_Drill, NVL( CASE WHEN L_OPP.Forecastcategory = 'Closed' AND OPP_C_DIM.OPPORTUNITIES_GROUP ='RENEWAL1' THEN L_OPP.TOTAL_RENEWAL__C END , 0) AS Renewal_Year1_Closed_Opp, CASE WHEN L_OPP.Forecastcategory = 'Closed' AND OPP_C_DIM.OPPORTUNITIES_GROUP ='RENEWAL1' THEN 'Renewal_Year1_Closed_Opp_Drill' END AS Renewal_Year1_Closed_Opp_Drill, NVL( CASE WHEN L_OPP.Forecastcategory IN ('Pipeline', 'Forecast', 'BestCase') AND OPP_C_DIM.OPPORTUNITIES_GROUP ='RENEWAL1' THEN L_OPP.TOTAL_RENEWAL__C END , 0) AS Renewal_Year1_OPEN_Opp, CASE WHEN L_OPP.Forecastcategory IN ('Pipeline', 'Forecast', 'BestCase') AND OPP_C_DIM.OPPORTUNITIES_GROUP ='RENEWAL1' THEN 'Renewal_Year1_OPEN_Opp_Drill' END AS Renewal_Year1_OPEN_Opp_Drill, NVL( CASE WHEN L_OPP.Forecastcategory = 'Closed' AND OPP_C_DIM.OPPORTUNITIES_GROUP ='RENEWAL2' THEN L_OPP.TOTAL_RENEWAL__C END , 0) AS Renewal_Year2_Closed_Opp, CASE WHEN L_OPP.Forecastcategory = 'Closed' AND OPP_C_DIM.OPPORTUNITIES_GROUP ='RENEWAL2' THEN 'Renewal_Year2_Closed_Opp_Drill' END AS Renewal_Year2_Closed_Opp_Drill, NVL( CASE WHEN L_OPP.Forecastcategory IN ('Pipeline', 'Forecast', 'BestCase') AND OPP_C_DIM.OPPORTUNITIES_GROUP ='RENEWAL2' THEN L_OPP.TOTAL_RENEWAL__C END , 0) AS Renewal_Year2_OPEN_Opp, CASE WHEN L_OPP.Forecastcategory IN ('Pipeline', 'Forecast', 'BestCase') AND OPP_C_DIM.OPPORTUNITIES_GROUP ='RENEWAL2' THEN 'Renewal_Year2_OPEN_Opp_Drill' END AS Renewal_Year2_OPEN_Opp_Drill FROM DW.OPP_C_DIM RIGHT OUTER JOIN RT.L_OPP ON (TO_CHAR(OPP_C_DIM.OFFER_CODE) =TO_CHAR(L_OPP.Offer_Code__C) AND (TO_CHAR(L_OPP.CloseDate,'YYYYMM')) = TO_CHAR(OPP_C_DIM.PERIOD)) LEFT OUTER JOIN RT.L_User ON (L_OPP.Ownerid=L_User.Id) LEFT OUTER JOIN DW.Tm_Rep ON (Tm_Rep.Rep_Num='0' ||L_User.Rep_Employee_Number__C) )) T774110 ON T7167.MEMBER_KEY = T774110.Rep_Id AND T7167.SALESYEARMONTH = T774110.Sales_Year_Month) LEFT OUTER JOIN DW.TM_R_REP T7171 ON T7167.ANCESTOR_KEY = T7171.CHILD_REP_ID AND T7167.SALESYEARMONTH = T7171.SALES_YEAR_MONTH) LEFT OUTER JOIN DW.TM_REP T6715 ON T7171.CHILD_REP_ID_N = T6715.REP_ID WHERE ( T774110.Sales_Year_Month = T7315.YEAR_MONTH AND T7171.CH_ID_SYM IN (SELECT DISTINCT D1.c1 AS c1 FROM SUBWITH2 D1 ) AND T7171.SALES_YEAR_MONTH BETWEEN '201505' AND '201505' AND T7171.CH_ID_SYM IN (SELECT DISTINCT D1.c1 AS c1 FROM SUBWITH1 D1 ) ) ), SAWITH1 AS (SELECT SUM(T774110.Renewal_Year2_OPEN_Opp) AS c9, SUM(T774110.Renewal_Year2_Closed_Opp) AS c10, SUM(T774110.Renewal_Year1_OPEN_Opp) AS c11, SUM(T774110.Renewal_Year1_Closed_Opp) AS c12, SUM(T774110.OPEN_Oppurtunity) AS c13, SUM(T774110.Closed_Oppurtunity) AS c14, T7315.MONTH_NUMERIC AS c15, T7171.CH_ID_SYM AS c16 FROM DW.TIM_MON T7315 , ( RT.L_ACCOUNT T765190 LEFT OUTER JOIN ( DW.PC_T_REP T7167 LEFT OUTER JOIN ( (SELECT TO_NUMBER(TO_CHAR(L_OPP.CloseDate,'YYYYMM')) AS Sales_Year_Month, Tm_Rep.Rep_Id AS Rep_Id, L_OPP.Account_Name__C AS Account_Name__C, L_OPP.Closedate AS Closedate, L_OPP.Forecastcategory AS Forecastcategory, L_OPP.Forecastcategoryname AS Forecastcategoryname, L_User.NAME AS Opp_Owner_S_Sales_Org__C, L_OPP.Opportunity_Id__C AS Opportunity_Id__C, L_OPP.Renewal_Date__C AS Renewal_Date__C, L_OPP.Total_Incremental__C AS Total_Incremental__C, L_OPP.Offer_Code__C AS Offer_Code__C, L_OPP.ID AS Opportunity_ID, L_OPP.TERRITORYID AS TERRITORYID, L_OPP.ACCOUNTID AS ACCOUNTID, L_OPP.OWNERID AS OWNERID, L_OPP.TOTAL_RENEWAL__C AS TOTAL_RENEWAL__C, L_OPP.NAME AS NAME, L_OPP.STAGENAME AS STAGE_NAME, L_OPP.STAGE_DESCRIPTION__C AS STAGE_DESCRIPTION, NVL( CASE WHEN L_OPP.Forecastcategory = 'Closed' AND( OPP_C_DIM.OPPORTUNITIES_GROUP IS NULL ) THEN L_OPP.Total_Incremental__C END , 0) AS Closed_Oppurtunity, CASE WHEN L_OPP.Forecastcategory = 'Closed' AND ( OPP_C_DIM.OPPORTUNITIES_GROUP IS NULL ) THEN 'Closed_Oppurtunity_Drill' END AS Closed_Oppurtunity_Drill, NVL( CASE WHEN L_OPP.Forecastcategoryname IN ('Pipeline', 'Potential', 'Commit') AND ( OPP_C_DIM.OPPORTUNITIES_GROUP IS NULL ) THEN L_OPP.Total_Incremental__C END , 0) AS OPEN_Oppurtunity, CASE WHEN L_OPP.Forecastcategoryname IN ('Pipeline', 'Potential', 'Commit') AND ( OPP_C_DIM.OPPORTUNITIES_GROUP IS NULL ) THEN 'OPEN_Oppurtunity_Drill' END AS OPEN_Oppurtunity_Drill, NVL( CASE WHEN L_OPP.Forecastcategory = 'Closed' AND OPP_C_DIM.OPPORTUNITIES_GROUP ='RENEWAL1' THEN L_OPP.TOTAL_RENEWAL__C END , 0) AS Renewal_Year1_Closed_Opp, CASE WHEN L_OPP.Forecastcategory = 'Closed' AND OPP_C_DIM.OPPORTUNITIES_GROUP ='RENEWAL1' THEN 'Renewal_Year1_Closed_Opp_Drill' END AS Renewal_Year1_Closed_Opp_Drill, NVL( CASE WHEN L_OPP.Forecastcategory IN ('Pipeline', 'Forecast', 'BestCase') AND OPP_C_DIM.OPPORTUNITIES_GROUP ='RENEWAL1' THEN L_OPP.TOTAL_RENEWAL__C END , 0) AS Renewal_Year1_OPEN_Opp, CASE WHEN L_OPP.Forecastcategory IN ('Pipeline', 'Forecast', 'BestCase') AND OPP_C_DIM.OPPORTUNITIES_GROUP ='RENEWAL1' THEN 'Renewal_Year1_OPEN_Opp_Drill' END AS Renewal_Year1_OPEN_Opp_Drill, NVL( CASE WHEN L_OPP.Forecastcategory = 'Closed' AND OPP_C_DIM.OPPORTUNITIES_GROUP ='RENEWAL2' THEN L_OPP.TOTAL_RENEWAL__C END , 0) AS Renewal_Year2_Closed_Opp, CASE WHEN L_OPP.Forecastcategory = 'Closed' AND OPP_C_DIM.OPPORTUNITIES_GROUP ='RENEWAL2' THEN 'Renewal_Year2_Closed_Opp_Drill' END AS Renewal_Year2_Closed_Opp_Drill, NVL( CASE WHEN L_OPP.Forecastcategory IN ('Pipeline', 'Forecast', 'BestCase') AND OPP_C_DIM.OPPORTUNITIES_GROUP ='RENEWAL2' THEN L_OPP.TOTAL_RENEWAL__C END , 0) AS Renewal_Year2_OPEN_Opp, CASE WHEN L_OPP.Forecastcategory IN ('Pipeline', 'Forecast', 'BestCase') AND OPP_C_DIM.OPPORTUNITIES_GROUP ='RENEWAL2' THEN 'Renewal_Year2_OPEN_Opp_Drill' END AS Renewal_Year2_OPEN_Opp_Drill FROM DW.OPP_C_DIM RIGHT OUTER JOIN RT.L_OPP ON (TO_CHAR(OPP_C_DIM.OFFER_CODE) =TO_CHAR(L_OPP.Offer_Code__C) AND (TO_CHAR(L_OPP.CloseDate,'YYYYMM')) = TO_CHAR(OPP_C_DIM.PERIOD)) LEFT OUTER JOIN RT.L_User ON (L_OPP.Ownerid=L_User.Id) LEFT OUTER JOIN DW.Tm_Rep ON (Tm_Rep.Rep_Num='0' ||L_User.Rep_Employee_Number__C) )) T774110 ON T7167.MEMBER_KEY = T774110.Rep_Id AND T7167.SALESYEARMONTH = T774110.Sales_Year_Month) ON T765190.ID = T774110.ACCOUNTID) LEFT OUTER JOIN DW.TM_R_REP T7171 ON T7167.ANCESTOR_KEY = T7171.CHILD_REP_ID AND T7167.SALESYEARMONTH = T7171.SALES_YEAR_MONTH WHERE ( T774110.Sales_Year_Month = T7315.YEAR_MONTH AND T7171.CH_ID_SYM IN (SELECT DISTINCT D1.c1 AS c1 FROM SUBWITH2 D1 ) AND T7171.SALES_YEAR_MONTH BETWEEN '201505' AND '201505' AND T7171.CH_ID_SYM IN (SELECT DISTINCT D1.c1 AS c1 FROM SUBWITH1 D1 ) ) GROUP BY T7171.CH_ID_SYM, T7315.MONTH_NUMERIC ) SELECT DISTINCT D2.c9 AS c1, D2.c10 AS c2, D2.c11 AS c3, D2.c12 AS c4, D2.c13 AS c5, D2.c14 AS c6, D1.c1 AS c7, D1.c2 AS c8, D1.c3 AS c9, D1.c4 AS c10, D1.c5 AS c11, D1.c6 AS c12, D1.c7 AS c13, D1.c8 AS c14 FROM SAWITH0 D1 INNER JOIN SAWITH1 D2 ON SYS_OP_MAP_NONNULL(D2.c15) = SYS_OP_MAP_NONNULL(D1.c4) AND SYS_OP_MAP_NONNULL(D2.c16) = SYS_OP_MAP_NONNULL(D1.c7) ORDER BY c10, c13
SQL in real time, followed by the details with the Predicate Section of dbms_xplan.display_cursor shot
Global stats
==============================================================================================================================
| Elapsed. CPU | E/S | Request | Cluster | Others | Pick up | Buffer | Read | Read | Write | Write | Cell |
| Time (s) | Time (s) | Waiting (s) | Waiting (s) | Waiting (s) | Waiting (s) | Calls | Gets | Reqs | Bytes | Reqs | Bytes | Unloading |
==============================================================================================================================
| 152. 146. 3.73 | 0.08 | 0.04 | 2.04 | 2. 16 M | 5223. 1 GB | 1. 200KB | 95,11% |
==============================================================================================================================
SQL details surveillance Plan (Plan hash value = 442312180)
===============================================================================================================================================================================================================================================
| ID | Operation | Name | Lines | Cost | Time | Start | Execs | Lines | Read | Read | Cell | MEM | Activity | Activity detail |
| | | | (Estimated) | | Active (s) | Active | | (Real) | Reqs | Bytes | Unloading | (Max) | (%) | (Number of samples).
===============================================================================================================================================================================================================================================
| 0 | SELECT STATEMENT | | | | 1. 152. 1. 0 | | | | | 0.65 | Cpu (1) |
| 1. RANGE OF PARTITION ALL THE | | 1. 3892 | | | 1. | | | | | | |
| 2. ACCESS STORAGE FULL FIRST RANKS TABLE. PC_T_REP | 1. 3892 | | | 37. | 74. 19 MB | 78.45% | 17 M | | |
| 3. TRANSFORMATION OF THE TEMPORARY TABLE. | | | 1. 152. 1. 1. | | | | | |
| 4. LOAD SELECT ACE | | | | 1. + 5 | 1. 1. | | | 278K | | |
| 5. VIEW | | 105. 3980 | 1. + 5 | 1. 13637 | | | | | | |
| 6. SORT UNIQUE | | 105. 3980 | 1. + 5 | 1. 13637 | | | | 757K | | |
| 7. UNION-ALL | | | | 1. + 5 | 1. 14033. | | | | | |
| 8. STORE TABLE FULL ACCESS | TM_R_REP | 22. 88. 1. + 5 | 1. 36. | | | | | |
| 9. RANGE OF PARTITION ALL THE | | 83. 3890. 1. + 5 | 1. 13997. | | | | | |
| 10. STORE TABLE FULL ACCESS | PC_T_REP | 83. 3890. 6. + 0 | 37. 13997. | | | 2 M | 0.65 | Smart cell table scan (1) |
| 11. LOAD SELECT ACE | | | | 1. + 5 | 1. 1. | | | 278K | | |
| 12. HASH UNIQUE | | 1. 4166. 1. + 5 | 1. 1. | | | 479K | | |
| 13. HASH JOIN | | 1. 4165 | 1. + 5 | 1. 444. | | | 1 M | | |
| 14. JOIN FILTER PART CREATE | : BF0000 | 3. 4075 | 1. + 5 | 1. 549. | | | | | |
| 15. OUTER HASH JOIN | | 3. 4075 | 1. + 5 | 1. 549. | | | 1 M | | |
| 16. HASH JOIN | | 3. 4068 | 1. + 5 | 1. 549. | | | 2 M | | |
| 17. VIEW | | 105. 3980 | 1. + 5 | 1. 13637 | | | | | | |
| 18. SORT UNIQUE | | 105. 3980 | 1. + 5 | 1. 13637 | | | | 757K | | |
| 19. UNION-ALL | | | | 1. + 5 | 1. 14033. | | | | | |
| 20. STORE TABLE FULL ACCESS | TM_R_REP | 22. 88. 1. + 5 | 1. 36. | | | | | |
| 21. RANGE OF PARTITION ALL THE | | 83. 3890. 1. + 5 | 1. 13997. | | | | | |
| 22. STORE TABLE FULL ACCESS | PC_T_REP | 83. 3890. 1. + 5 | 37. 13997. | | | 2 M | | |
| 23. STORE TABLE FULL ACCESS | TM_R_REP | 1884 | 88. 1. + 5 | 1. 1929 | | | | | | |
| 24. STORE TABLE FULL ACCESS | TM_REP | 7136 | 7. 1. + 5 | 1. 7137 | | | | | | |
| 25. RANGE OF SINGLE PARTITION | | 7449. 90. 1. + 5 | 1. 7449. | | | | | |
| 26. STORE TABLE FULL ACCESS | PC_T_REP | 7449. 90. 1. + 5 | 1. 7449. | | | | | |
| 27. SORT UNIQUE | | 1. 26032 | 1. 152. 1. 1. | | | 2048 | | |
| 28. OUTER HASH JOIN | | 1. 26031 | 72. + 81 | 1. 8238 | | | | 4 M | | |
| 29. FILTER | | | | 74. + 79 | 1. 8238 | | | | | 1.96 | Cpu (3) |
| 30. NESTED EXTERNAL LOOPS | | 1. 26027 | 72. + 81 | 1. 15 M | | | | | 3.27 | Cpu (5) |
| 31. HASH JOIN | | 1. 26026 | 72. + 81 | 1. 15 M | | | | 447K | 18.95 | Cpu (29) |
| 32. OUTER HASH JOIN | | 1. 13213 | 1. + 81 | 1. 332. | | | 452K | | |
| 33. HASH JOIN | | 1. 13206 | 1. + 81 | 1. 332. | | | 1 M | | |
| 34. HASH JOIN | | 1. 13199. 1. + 81 | 1. 444. | | | 434K | | |
| 35. HASH JOIN | | 1. 13197. 1. + 81 | 1. 444. | | | 290K | | |
| 36. JOIN CREATE FILTER | : BF0000 | 1. 13195. 1. + 81 | 1. 444. | | | | | |
| 37. HASH JOIN | | 1. 13195. 1. + 81 | 1. 444. | | | 2 M | | |
| 38. THE CARTESIAN MERGE JOIN. | 27. 13107 | 1. + 81 | 1. 7449. | | | | | |
| 39. HASH JOIN | | 1. 13017. 77. + 5 | 1. 1. | | | 750K | | |
| 40. STORE TABLE FULL ACCESS | TIM_MON | 1. 4. 1. + 5 | 1. 1. | | | | | |
| 41. VIEW | | 1. 13013. 1. + 81 | 1. 1. | | | | | |
| 42. HASH GROUP BY. | 1. 13013. 1. + 81 | 1. 1. | | | 482K | | |
| 43. OUTER HASH JOIN | | 1. 13012. 77. + 5 | 1. 8238 | | | | 4 M | | |
| 44. NESTED LOOPS | | 1. 13008. 77. + 5 | 1. 8238 | | | | | | |
| 45. FILTER | | | | 77. + 5 | 1. 8238 | | | | | 2.61 | Cpu (4) |
| 46. NESTED EXTERNAL LOOPS | | 1. 13007. 77. + 5 | 1. 15 M | | | | | 4.58. Cpu (7) |
| 47. HASH JOIN | | 1. 13006. 77. + 5 | 1. 15 M | | | | 424K | 11.76. Cpu (18) |
| 48. HASH JOIN | | 1. 193. 1. + 5 | 1. 332. | | | 1 M | | |
| 49. HASH JOIN | | 1. 186. 1. + 5 | 1. 444. | | | 420K | | |
| 50. HASH JOIN | | 4. 184. 1. + 5 | 1. 444. | | | 290K | | |
| 51. JOIN CREATE FILTER | : BF0002 | 1. 94. 1. + 5 | 1. 1. | | | | | |
| 52. JOIN FILTER PART CREATE | : BF0001 | 1. 94. 1. + 5 | 1. 1. | | | | | |
| 53. HASH JOIN | | 1. 94. 1. + 5 | 1. 1. | | | 290K | | |
| 54. JOIN CREATE FILTER | : BF0003 | 1. 6. 1. + 5 | 1. 1. | | | | | |
| 55. THE CARTESIAN MERGE JOIN. | 1. 6. 1. + 5 | 1. 1. | | | | | |
| 56. STORE TABLE FULL ACCESS | TIM_MON | 1. 4. 1. + 5 | 1. 1. | | | | | |
| 57. KIND OF BUFFER. | 1. 2. 1. + 5 | 1. 1. | | | 2048 | | |
| 58. VIEW | VW_NSO_1 | 1. 2. 1. + 5 | 1. 1. | | | | | |
| 59. UNIQUE HASH | | 1. | 1. + 5 | 1. 1. | | | 485K | | |
| 60. VIEW | | 1. 2. 1. + 5 | 1. 1. | | | | | |
| 61. STORE TABLE FULL ACCESS | SYS_TEMP_0FD9D71E1_B445AE36 | 1. 2. 1. + 5 | 1. 1. | | | | | |
| 62. USE OF JOIN FILTER | : BF0003 | 1884 | 88. 1. + 5 | 1. 1. | | | | | |
| 63. STORE TABLE FULL ACCESS | TM_R_REP | 1884 | 88. 1. + 5 | 1. 1. | | | | | |
| 64. USE OF JOIN FILTER | : BF0002 | 7449. 90. 1. + 5 | 1. 444. | | | | | |
| 65. RANGE OF SINGLE PARTITION | | 7449. 90. 5. + 1 | 1. 444. | | | | 0.65 | Cpu (1) |
| 66. STORE TABLE FULL ACCESS | PC_T_REP | 7449. 90. 1. + 5 | 1. 444. | | | | | |
| 67. VIEW | | 105. 2. 1. + 5 | 1. 13637 | | | | | | |
| 68. STORE TABLE FULL ACCESS | SYS_TEMP_0FD9D71E0_B445AE36 | 105. 2. 1. + 5 | 1. 13637 | | | | | | |
| 69. STORE TABLE FULL ACCESS | TM_REP | 7136 | 7. 1. + 5 | 1. 7137 | | | | | | |
| 70. STORE TABLE FULL ACCESS | L_OP | 19382 | 12813 | 77. + 5 | 1. 43879 | 565. 551 MB | 98.18% | 15 M | | |
| 71. TABLE ACCESS BY INDEX ROWID | L_US | 1. 1. 79. + 3 | 15 M | 15 M | 26. 208KO | | | 19.61 | Cpu (30) |
| 72. INDEX UNIQUE SCAN | L_US_PK | 1. | 77. + 5 | 15 M | 15 M | 2. 16384. | | 9 h 15 | Cpu (14) |
| 73. INDEX UNIQUE SCAN | L_A_PK | 1. 1. 151. + 2 | 8238 | 8238 | 3269 | 26 MB | | | 2.61 | Cpu (1) |
| | | | | | | | | | | | | | | monobloc cell physical read (3) |
| 74. STORE TABLE FULL ACCESS | OPP_C_DIM | 2304 | 4. 1. + 81 | 1. 2304 | 3. 112 KB | | | | |
| 75. KIND OF BUFFER. | 7449. 13107 | 1. + 81 | 1. 7449. | | | 370K | | |
| 76. RANGE OF SINGLE PARTITION | | 7449. 90. 1. + 81 | 1. 7449. | | | | | |
| 77. STORE TABLE FULL ACCESS | PC_T_REP | 7449. 90. 1. + 81 | 1. 7449. | | | | | |
| 78. STORE TABLE FULL ACCESS | TM_R_REP | 1884 | 88. 1. + 81 | 1. 1929 | | | | | | |
| 79. VIEW | | 1. 2. 1. + 81 | 1. 1. | | | | | |
| 80. USE OF JOIN FILTER | : BF0000 | 1. 2. 1. + 81 | 1. 1. | | | | | |
| 81. STORE TABLE FULL ACCESS | SYS_TEMP_0FD9D71E1_B445AE36 | 1. 2. 1. + 81 | 1. 1. | | | | | |
| 82. VIEW | | 105. 2. 1. + 81 | 1. 13637 | | | | | | |
| 83. STORE TABLE FULL ACCESS | SYS_TEMP_0FD9D71E0_B445AE36 | 105. 2. 1. + 81 | 1. 13637 | | | | | | |
| 84. STORE TABLE FULL ACCESS | TM_REP | 7136 | 7. 1. + 81 | 1. 7137 | | | | | | |
| 85. STORE TABLE FULL ACCESS | TM_REP | 7136 | 7. 1. + 81 | 1. 7137 | | | | | | |
| 86. STORE TABLE FULL ACCESS | L_OP | 19382 | 12813 | 72. + 81 | 1. 43879 | 593. 577 MB | 98,44% | 15 M | | |
| 87. TABLE ACCESS BY INDEX ROWID | L_US | 1. 1. 72. + 81 | 15 M | 15 M | | | | | 13.73. Cpu (21) |
| 88. INDEX UNIQUE SCAN | L_US_PK | 1. | 73. + 80 | 15 M | 15 M | | | | | 9.80 | Cpu (15) |
| 89. STORE TABLE FULL ACCESS | OPP_C_DIM | 2304 | 4. 1. 152. 1. 2304 | | | | | | |
===============================================================================================================================================================================================================================================
Information of predicates (identified by the operation identity card):
---------------------------------------------------
2. (("MEMBER_KEY_SYM" =: B1 ET "IS_LEAF" = 1) filter)
8 - storage("T7171".") CHILD_REP_ID "= 939)
filter ("T7171". ("CHILD_REP_ID" = 939)
10 - storage("T7167".") ANCESTOR_KEY "= 939)
filter ("T7167". ("ANCESTOR_KEY" = 939)
13 - access("T7167".") SALESYEARMONTH "= 'T7171'." SALES_YEAR_MONTH' AND 'T7167 '. "ANCESTOR_KEY"= "T7171". ("' CHILD_REP_ID")
filter (CASE WHEN TO_CHAR ("T7171". "CHILD_REP_ID_N") AS 9999% ' THEN 'ALL UNASSIGNED' | " CAST ("T7167". ("TERRITORY_ID" AS A VARCHAR (20)) ELSE 'T6715 '. "" NAME "| "
'||" T6715 ". "" MIDDLE_NAME "| " '||" T6715 ". ("" LAST_NAME "END ="JOES CRAMER")
15 - access("T7171".") CHILD_REP_ID_N "= 'T6715'." REP_ID")
16 - access("T7171".") CH_ID_SYM '= 'D1'.' C1")
20 - storage("T7171".") CHILD_REP_ID "= 939)
filter ("T7171". ("CHILD_REP_ID" = 939)
22 - storage("T7167".") ANCESTOR_KEY "= 939)
filter ("T7167". ("ANCESTOR_KEY" = 939)
23 - storage("T7171".") SALES_YEAR_MONTH "= 201505)
filter ("T7171". ("SALES_YEAR_MONTH" = 201505)
26 - storage("T7167".") SALESYEARMONTH "= 201505)
filter ("T7167". ("SALESYEARMONTH" = 201505)
28 - access (TO_CHAR (INTERNAL_FUNCTION ("L_OP". "CLOSEDATE"), "YYYYMM") = TO_CHAR ("OPP_C_DIM". " PERIOD") AND
TO_CHAR ("OPP_C_DIM". "OFFER_CODE") = "L_OP". ("' OFFER_CODE__C")
29 - filter("TM_REP".") REP_NUM "=" 0"|" » « « « L_US «. » REP_EMPLOYEE_NUMBER__C')
31 - access("T7315".") YEAR_MONTH «= TO_NUMBER (TO_CHAR (INTERNAL_FUNCTION ("L_OP".» CLOSEDATE"),"YYYYMM")) AND
'T7167 '. «SALESYEARMONTH «= TO_NUMBER (TO_CHAR (INTERNAL_FUNCTION ("L_OP".» (((("" CLOSEDATE "),"YYYYMM")))
32 - access("T7171".") CHILD_REP_ID_N "= 'T6715'." REP_ID")
33 - access("T7167".") MEMBER_KEY "=" TM_REP. " ("" REP_ID ")
34 - access("T7171".") CH_ID_SYM '= 'D1'.' C1")
35 - access("T7171".") CH_ID_SYM '= 'D1'.' C1")
37 - access (SYS_OP_MAP_NONNULL ("D2". "C16") = SYS_OP_MAP_NONNULL ("T7171". " CH_ID_SYM") AND"T7167 ". "SALESYEARMONTH"= "T7171". "" SALES_YEAR_MONTH "AND
'T7167 '. "ANCESTOR_KEY"= "T7171". ("' CHILD_REP_ID")
39 - access (SYS_OP_MAP_NONNULL ("D2". "C15") = SYS_OP_MAP_NONNULL ("T7315". " MONTH_NUMERIC'))
40 - storage("T7315".") YEAR_MONTH "= 201505)
filter ("T7315". ("YEAR_MONTH" = 201505)
43 - access (TO_CHAR (INTERNAL_FUNCTION ("L_OP". "CLOSEDATE"), "YYYYMM") = TO_CHAR ("OPP_C_DIM". " PERIOD") AND
TO_CHAR ("OPP_C_DIM". "OFFER_CODE") = "L_OP". ("' OFFER_CODE__C")
45 - filter("TM_REP".") REP_NUM "=" 0"|" » « « « L_US «. » REP_EMPLOYEE_NUMBER__C')
47 - access("T7315".") YEAR_MONTH «= TO_NUMBER (TO_CHAR (INTERNAL_FUNCTION ("L_OP".» CLOSEDATE"),"YYYYMM")) AND
'T7167 '. «SALESYEARMONTH «= TO_NUMBER (TO_CHAR (INTERNAL_FUNCTION ("L_OP".» (((("" CLOSEDATE "),"YYYYMM")))
48 - access("T7167".") MEMBER_KEY "=" TM_REP. " ("" REP_ID ")
49 - access("T7171".") CH_ID_SYM '= 'D1'.' C1")
50 - access("T7167".") SALESYEARMONTH "= 'T7171'." SALES_YEAR_MONTH' AND 'T7167 '. "ANCESTOR_KEY"= "T7171". ("' CHILD_REP_ID")
53 - access("T7171".") CH_ID_SYM "=" C1")
56 - storage("T7315".") YEAR_MONTH "= 201505)
filter ("T7315". ("YEAR_MONTH" = 201505)
63 - storage (("T7171". "SALES_YEAR_MONTH" = 201505 AND SYS_OP_BLOOM_FILTER (: BF0000, "T7171" ".") CH_ID_SYM')))
filter (("T7171". "SALES_YEAR_MONTH" = 201505 AND SYS_OP_BLOOM_FILTER (: BF0000, "T7171" ".") CH_ID_SYM')))
66 - storage (("T7167". "SALESYEARMONTH" = 201505 AND SYS_OP_BLOOM_FILTER (: BF0000, "T7167" ".") SALESYEARMONTH', 'T7167 '. ((("" ANCESTOR_KEY ")))
filter (("T7167". "SALESYEARMONTH" = 201505 AND SYS_OP_BLOOM_FILTER (: BF0000, "T7167" ".") SALESYEARMONTH', 'T7167 '. ((("" ANCESTOR_KEY ")))
70 - storage ((TO_NUMBER (TO_CHAR (INTERNAL_FUNCTION ("L_OP". "CLOSEDATE"), "YYYYMM")) > = 201505 AND "
TO_NUMBER (TO_CHAR (INTERNAL_FUNCTION ("L_OP". "CLOSEDATE"), "YYYYMM")) (< = 201505)) "
filter ((TO_NUMBER (TO_CHAR (INTERNAL_FUNCTION ("L_OP". "CLOSEDATE"), "YYYYMM")) > = 201505 AND "
TO_NUMBER (TO_CHAR (INTERNAL_FUNCTION ("L_OP". "CLOSEDATE"), "YYYYMM")) (< = 201505)) "
72 - access("L_OP".") OWNERID "=" L_US. " (' ' ID ')
73 - access("T765190".") WITH THE ID "=" L_OP. " ("' ACCOUNTID ')
77 - storage("T7167".") SALESYEARMONTH "= 201505)
filter ("T7167". ("SALESYEARMONTH" = 201505)
78 - storage("T7171".") SALES_YEAR_MONTH "= 201505)
filter ("T7171". ("SALES_YEAR_MONTH" = 201505)
81 - storage (SYS_OP_BLOOM_FILTER (: BF0000, "C0"))
filter (SYS_OP_BLOOM_FILTER (: BF0000, "C0"))
86 - storage ((TO_NUMBER (TO_CHAR (INTERNAL_FUNCTION ("L_OP". "CLOSEDATE"), "YYYYMM")) > = 201505 AND "
TO_NUMBER (TO_CHAR (INTERNAL_FUNCTION ("L_OP". "CLOSEDATE"), "YYYYMM")) (< = 201505)) "
filter ((TO_NUMBER (TO_CHAR (INTERNAL_FUNCTION ("L_OP". "CLOSEDATE"), "YYYYMM")) > = 201505 AND "
TO_NUMBER (TO_CHAR (INTERNAL_FUNCTION ("L_OP". "CLOSEDATE"), "YYYYMM")) (< = 201505)) "
88 - access("L_OP".") OWNERID "=" L_US. " (' ' ID ')
Note
-----
-dynamic sample used for this survey (level = 4)
-Automatic DOP: calculated degree of parallelism is 1 because of the parallel threshold
Although the table meet statistical why dynamic sampling is to be used? Why 15 million times ID 71, 72, 87 and 88 are executed, curious because that is where most of the time is spent. How can we reduce this 15 million probes?
Suggestions to reduce the response time sql would be useful.
Post edited by: Yasu masking of sensitive information (literal value)
YASU says:
For educational purposes could you please clarify why the optimizer has evaluated the join condition in the functioning of the FILTER to 15 million lines?
This is unusual, but TM_REP is attached to another PC_T_REP table using a join operation, so maybe it's the explanation of why it is moved to a FILTER operation had been delayed - could also be a side effect of the combination of ANSI join processing (Oracle internally transforms ANSI joins in Oracle join syntax) and the transformation of outer join internally.
Very curious to know how this is possible, could you please give us the hint/tour, you can use to push the inner join down execution plan is evaluated as soon as possible to reduce the data to be processed? I have a sql plus, where the situation is almost similar - ranks of filtering 2 million to the hash JOIN operation and return 0 rows. I can post the details of sql here but not to mix different sql question in the same post. Please let me know if you would like to give the details of this sql in this same thread, or a different thread? I searched for this type of information, but to no avail, so could you please suggest how this is possible, if not for this long sql then at least please provide a few examples/suggestions?
Normally you can influence this through the appropriate join order, for example with the help of the LEADING indicator, for filter indicator PUSH_SUBQ subqueries can also be useful for filtering at the beginning. But here the comment of Franck is particularly important - by leaning on the Cartesian join this problem here should be less relevant.
As I already said I would recommend here from scratch and think that all that this query is supposed to average and the question why most outer joins is actually converted into inner joins - the current query example returns the correct result?
Randolf
-
to BIND the variable SUBSTITUTION
I have a code where I find dates START and end range for the past 3 years, the beginning Date must start on a Sunday and the end Date is at the end on Saturday using the weird system they have here:-)
the end usable VARIABLE must be in YYYYMMDD format as number, because that's how they set up Date here... can anything about...
So I thought to all the Dates, performing a combination of Variables of SUBSTITUTION AND LINKING, why I do like that it is because
I received an error when I used just the variables SUBSTITUTION (maximum 240 characters used on the START DATE of the year2, in)
switching to this, the error has disappeared), well that's what I thought he'll fix it.
But now, when I try to use and VARIABLE in SQL, I get an error that it cannot use BIND variables, so try to pass values to a SUBSTITUTION
afin_que this error disappears) - unless there is a better way?
If there is a better way to stay maybe everything inside SUBSTITUTION and don't imply any LINK, maybe it would be better, if you guys know a way around the 240 character error...
:-)
My variables are:
-find YEAR 1
SET LY_END_DATE_NUM = "TO_NUMBER (TO_CHAR (NEXT_DAY ((SYSDATE-7), 'SATURDAY'), 'YYYYMMDD'));
variable BIND_LY_END_DATE_N number;
run: BIND_LY_END_DATE_N: = & LY_END_DATE_NUM;
PRINT BIND_LY_END_DATE_N;
SET LY_START_DATE = ' TO_DATE (: BIND_LY_END_DATE_N, 'yyyy-mm-dd')-363;
SET LY_START_DATE_NUM = "TO_NUMBER (TO_CHAR (& LY_START_DATE, 'YYYYMMDD'));
variable BIND_LY_START_DATE_N number;
run: BIND_LY_START_DATE_N: = & LY_START_DATE_NUM;
PRINT BIND_LY_START_DATE_N;
-find YEAR 2
SET YRS2_END_DATE = ' TO_DATE (: BIND_LY_START_DATE_N, 'yyyy-mm-dd')-1;
SET YRS2_END_DATE_NUM = "TO_NUMBER (TO_CHAR (& YRS2_END_DATE, 'YYYYMMDD'));
variable BIND_YRS2_END_DATE_N number;
run: BIND_YRS2_END_DATE_N: = & YRS2_END_DATE_NUM;
PRINT BIND_YRS2_END_DATE_N;
SET YRS2_START_DATE = ' TO_DATE (: BIND_YRS2_END_DATE_N, 'yyyy-mm-dd')-363;
SET YRS2_START_DATE_NUM = "TO_NUMBER (TO_CHAR (& YRS2_START_DATE, 'YYYYMMDD'));
variable BIND_YRS2_START_DATE_N number;
run: BIND_YRS2_START_DATE_N: = & YRS2_START_DATE_NUM;
PRINT BIND_YRS2_START_DATE_N;
-find YEAR 3
SET YRS3_END_DATE = ' TO_DATE (: BIND_YRS2_START_DATE_N, 'yyyy-mm-dd')-1;
SET YRS3_END_DATE_NUM = "TO_NUMBER (TO_CHAR (& YRS3_END_DATE, 'YYYYMMDD'));
variable BIND_YRS3_END_DATE_N number;
run: BIND_YRS3_END_DATE_N: = & YRS3_END_DATE_NUM;
PRINT BIND_YRS3_END_DATE_N;
SET YRS3_START_DATE = ' TO_DATE (: BIND_YRS3_END_DATE_N, 'yyyy-mm-dd')-363;
SET YRS3_START_DATE_NUM = "TO_NUMBER (TO_CHAR (& YRS3_START_DATE, 'YYYYMMDD'));
variable BIND_YRS3_START_DATE_N number;
run: BIND_YRS3_START_DATE_N: = & YRS3_START_DATE_NUM;
PRINT BIND_YRS3_START_DATE_N;
Hello
Kodiak_Seattle wrote:
I have a code where I find dates START and end range for the past 3 years, the beginning Date must start on a Sunday and the end Date is at the end on Saturday using the weird system they have here:-)
the end usable VARIABLE must be in YYYYMMDD format as number, because that's how they set up Date here... can anything about...
So I thought to all the Dates, performing a combination of Variables of SUBSTITUTION AND LINKING, why I do like that it is because
I received an error when I used just the variables SUBSTITUTION (maximum 240 characters used on the START DATE of the year2, in)
switching to this, the error has disappeared), well that's what I thought he'll fix it.
But now, when I try to use & VARIABLE in SQL, I get an error that it cannot use BIND variables, so try to pass values to a SUBSTITUTION
afin_que this error disappears) - unless there is a better way?
If there is a better way to stay maybe everything inside SUBSTITUTION and don't imply any LINK, maybe it would be better, if you guys know a way around the 240 character error...
:-)
My variables are:
-find YEAR 1
SET LY_END_DATE_NUM = "TO_NUMBER (TO_CHAR (NEXT_DAY ((SYSDATE-7), 'SATURDAY'), 'YYYYMMDD'));
variable BIND_LY_END_DATE_N number;
run: BIND_LY_END_DATE_N: = & LY_END_DATE_NUM;
PRINT BIND_LY_END_DATE_N;
SET LY_START_DATE = ' TO_DATE (: BIND_LY_END_DATE_N, 'yyyy-mm-dd')-363;
SET LY_START_DATE_NUM = "TO_NUMBER (TO_CHAR (& LY_START_DATE, 'YYYYMMDD'));
variable BIND_LY_START_DATE_N number;
run: BIND_LY_START_DATE_N: = & LY_START_DATE_NUM;
PRINT BIND_LY_START_DATE_N;
-find YEAR 2
SET YRS2_END_DATE = ' TO_DATE (: BIND_LY_START_DATE_N, 'yyyy-mm-dd')-1;
SET YRS2_END_DATE_NUM = "TO_NUMBER (TO_CHAR (& YRS2_END_DATE, 'YYYYMMDD'));
variable BIND_YRS2_END_DATE_N number;
run: BIND_YRS2_END_DATE_N: = & YRS2_END_DATE_NUM;
PRINT BIND_YRS2_END_DATE_N;
SET YRS2_START_DATE = ' TO_DATE (: BIND_YRS2_END_DATE_N, 'yyyy-mm-dd')-363;
SET YRS2_START_DATE_NUM = "TO_NUMBER (TO_CHAR (& YRS2_START_DATE, 'YYYYMMDD'));
variable BIND_YRS2_START_DATE_N number;
run: BIND_YRS2_START_DATE_N: = & YRS2_START_DATE_NUM;
PRINT BIND_YRS2_START_DATE_N;
-find YEAR 3
SET YRS3_END_DATE = ' TO_DATE (: BIND_YRS2_START_DATE_N, 'yyyy-mm-dd')-1;
SET YRS3_END_DATE_NUM = "TO_NUMBER (TO_CHAR (& YRS3_END_DATE, 'YYYYMMDD'));
variable BIND_YRS3_END_DATE_N number;
run: BIND_YRS3_END_DATE_N: = & YRS3_END_DATE_NUM;
PRINT BIND_YRS3_END_DATE_N;
SET YRS3_START_DATE = ' TO_DATE (: BIND_YRS3_END_DATE_N, 'yyyy-mm-dd')-363;
SET YRS3_START_DATE_NUM = "TO_NUMBER (TO_CHAR (& YRS3_START_DATE, 'YYYYMMDD'));
variable BIND_YRS3_START_DATE_N number;
run: BIND_YRS3_START_DATE_N: = & YRS3_START_DATE_NUM;
PRINT BIND_YRS3_START_DATE_N;
Let me make sure I understand the problem.
One year, in this problem, is exactly 364 days.
You want the year that ended on the most recent Saturday (otherwise said, the year ending Saturday between 6 days ago and today) and two years ago.
You want the first date in each of those years and the last date each year, in the format YYYYMMDD.
Is this fair?
Here's a way to define variables of substitution (with names like year_1_start):
COLUMN y1_start new_value by year_1_start
COLUMN y1_end new_value by year_1_end
COLUMN y2_start new_value by year_2_start
COLUMN y2_end new_value by year_2_end
COLUMN y3_start new_value by year_3_start
COLUMN y3_end new_value by year_3_end
WITH got_y1e AS
(
SELECT NEXT_DAY (SYSDATE - 7 'SATURDAY') AS y1e
OF the double
)
SELECT TO_CHAR (y1e + 1 - (364 * 3), 'YYYYMMDD') AS y3_start
, TO_CHAR (y1e - (364 * 2), 'YYYYMMDD') AS y3_end
, TO_CHAR (y1e + 1 - (364 * 2), 'YYYYMMDD') AS y2_start
, TO_CHAR (y1e - 364, 'YYYYMMDD') AS y2_end
, TO_CHAR (y1e + 1-364, 'YYYYMMDD') AS y1_start
, TO_CHAR (y1e, 'YYYYMMDD') AS y1_end
OF got_y1e
;
If you prefer that bind variable, write an anonymous PL/SQL block and use the same logic to 6 variables.
-
I am trying to select the available time slots (in hours) between two date columns.
I use to CONNECT BY LEVEL with a not equal operator:
SELECT
(dates.start_date_time + (level - 1) / 24) start_date_time.
dates.examiner_id
dates.schedule_id
FROM (SELECT - bmv.schedule.common.data.AutoExaminerSchView)
schedule_id
start_date_time
end_date_time
examiner_id
exam_status
OF schedule_test
WHERE start_date_time > = TO_DATE (' 06/01/2014 7 "," MM/DD/YYYY HH24')-in the
AND end_date_time < = TO_DATE (' 01/10/2014-15 "," MM/DD/YYYY HH24')-week calendar
AND exam_status = 'AVAILABLE' - available calendar
ROWNUM AND < 2) dates
WHERE EXTRACT (HOUR OF NUMTODSINTERVAL (-before the end time (16:00)))
(dates.start_date_time + (level - 1) / 24)-TRUNC)
(dates.start_date_time_+_(niveau_-_1) / 24)), 'DAY')) < TO_NUMBER (TO_CHAR (dates.end_date_time, 'HH24'))
CONNECT BY dates.start_date_time + (level - 1) / 24 < = dates.end_date_time - each time between dates
ORDER BY (dates.start_date_time + (level - 1) /24),dates.examiner_id,dates.schedule_id;)
The docs say:
Operators other than the equal sign (=) are theoretically possible in CONNECT BY clauses. However, this can cause an infinite loop in the possible combinations.
My strategy works well for a record, but when there is more than one record the results become exponentially large.
The SQL script + attached implements the test data and executes two examples of queries.
Someone was able to demonstrate the correct way to select these data?
Pointers and help is appreciated.
You just need to add certain conditions in the connection by.
and prior schedule_id = schedule_id and prior dbms_random.value is not null
BTW, I don't think you need to where clause; You should be able to change the time period in the connection by to restrict lines as needed. You may need to add trunc (
, "hh") if needed (perhaps in select it the list too, if your start and end times are not always on time, but you want your report to be at the time). Maybe something like:
SELECT (dates.start_date_time + (LEVEL - 1) / 24) start_date_time, dates.examiner_id, dates.schedule_id FROM (SELECT -- bmv.schedule.common.data.AutoExaminerSchView schedule_id, start_date_time, end_date_time, examiner_id, exam_status FROM schedule_test WHERE start_date_time >= TO_DATE ('1/6/2014 7', 'MM/DD/YYYY HH24') -- during the AND end_date_time <= TO_DATE ('1/10/2014 15', 'MM/DD/YYYY HH24') -- scheduling week AND exam_status = 'AVAILABLE' -- with available schedule ) dates CONNECT BY dates.start_date_time + LEVEL / 24 <= dates.end_date_time -- each hour between dates and prior schedule_id = schedule_id and prior dbms_random.value is not null ORDER BY dates.start_date_time + LEVEL / 24, dates.examiner_id, dates.schedule_id;
-
How to avoid duplicates on a column with condition
Hi all
I need some advice here. At work, we have an Oracle APEX application that allow the user to add new records with the decision of the increment automatic number based on the year and the group name.
Said that if they add the first record, group name AA, for 2012, they get the decision number AA 1 2013 as their record casein displayed page of the report.
The second record of AA in 2013 will be AA 2 2013.
If we add about 20 records, it will be AA 20 2013.
The first record for 2014 will be AA 1 2014.
However, recently, we get a claim of the user on two files of the same name of group have the same number of the decision.
When I looked in the history table and find that the time gap between 2 record is about 0.1 seconds.
In addition, we have the correspondence table which allows the user admin update the sequence number start with the restraint that it must be greater than the maximum number of the current name of the current year.
This boot sequence number and the name of the group is stored together in a table.
And in some other case, the user can add a decision duplicate for related record number. (this is a new feature)
The current logic of the procedure to add the new record on the application are
_Get max record table with selected group name (decision_number) and the current year.
_INSERT in the folder table the new record came with the decision to number + 1
_ update sequence number of the number of the decision just added.
So instead of utitlising the process of editing the built-in automatic table of the APEX, I write a procedure that combine all three processes.
I have run some loop for continually perform this procedure, and it seems that it can generate autotically new decision unique number with time about 0.1 second difference.
However, when I increase the number of entry to 200 and let two users run 100 each.
If the time gap is about 0.01 second, double decision numbers are displayed.
What can I do to prevent duplicate?
I can't just apply a unique constraint here for three columns with condition because it can be duplicated in some special conditions. I don't know much about the use of lock and its impact.
This is the content of my procedure
create or replace
PROCEDURE add_new_case)
-ID just use the trigger
p_case_title IN varchar2,
p_year IN varchar2,
p_group_name IN VARCHAR2,
-decisionnumber here
p_case_file_number IN VARCHAR2,
-active
p_user in VARCHAR2
)
AS
NUMBER default_value;
caseCount NUMBER;
seqNumber NUMBER;
previousDecisionNumber NUMBER;
BEGIN
-execution immediate q '[alter session set nls_date_format = "dd/mm/yyyy"]';
SELECT count (*)
IN caseCount
OF CASE_RECORD
WHERE GROUP_ABBR = p_group_name
AND to_number (to_char (create_date, "yyyy")) = to_number (to_char (date_utils.get_current_date, "yyyy"));
SELECT max (decision_number)
IN previousDecisionNumber
OF CASE_RECORD
WHERE GROUP_ABBR = p_group_name
AND to_number (to_char (create_date, "yyyy")) = to_number (to_char (date_utils.get_current_date, "yyyy"));
IF p_group_name IS NULL
THEN seqNumber: = 0;
ON THE OTHER
SELECT Seq_number INTO seqNumber FROM GROUP_LOOKUP WHERE ABBREVIATION = p_group_name;
END IF;
IF caseCount > 0 THEN
default_value: largest = (seqNumber, previousdecisionnumber) + 1;
ON THE OTHER
default_value: = 1;
END IF;
INSERT INTO CASE_RECORD (case_title, decision_year, GROUP_ABBR, decision_number, case_file_number, active_yn, created_by, create_date)
VALUES (p_case_title, p_year, p_group_name, default_value, p_case_file_number, 'Y', p_user, sysdate);
-Need to update the sequence here also
UPDATE GROUP_LOOKUP
SET SEQ_NUMBER = default_value
WHERE the ABBREVIATION = p_group_name;
COMMIT;
EXCEPTION
WHILE OTHERS THEN
Logger.Error (p_message_text = > SQLERRM)
, p_message_code = > SQLCODE
, p_stack_trace = > dbms_utility.format_error_backtrace
);
LIFT;
END;
Many thanks in advance,
Ann
It's easier to solve for the case, while p_group_name is not null. In this case, you update a GROUP_LOOKUP line, so that you can select to update this line at the beginning, to prevent cases of two for the same group added at the same time. To do this, change the selection of GROUP_LOOKUP to:
SELECT Seq_number INTO seqNumber FROM GROUP_LOOKUP WHERE ABBREVIATION = p_group_name for an updated VERSION OF the SEQ_NUMBER;
and move this to be the first thing that did the procedure - before it has CASE_RECORD lines.
In the case when p_group_name is set to null, you have some object to be locked. I think the best you can do is to lock the entire table GROUP_LOOKUP:
the table lock in exclusive mode GROUP_LOOKUP wait 100;
The '100 expectation' means that he will wait until 100 seconds before giving up and trigger an error. in practice, that is expected to only wait a moment.
Exclusive mode allows others to read, but not to update the table.
UPDATES and the LOCK of the TABLE will be updates of other sessions wait for this transaction to validate. Queries from other sessions are not affected.
The locks are released when you commit or roll back.
-
date sorting with anychart (mm.yyyy) handset
Hello
[apex 4.2, Oracle 11 g]
I have a table in which I extracted the year and month and the two in combination (of type date). This is necessary to summarize the year for example in a chart.
I need the combination of month and year because people could do a query that passes through many years. For example: to 02.2012 to 03.2013.
My problem is that I don't know how to say anychart to sort dates.
I have already tried:
Apex now sorts:to_number(to_char(testdate,'YYYY')) as Year, to_number(to_char(testdate,'YYYY'))||to_number(to_char(testdate,'MM')) as Monthyear
20121,201212,20122
I wish that this Summit realizes on the agenda:
1.2012,2.2012,3.2012... 01.2013,02.2013.03.2013
The report itself is now four day collums concerning:
(1) date of (Type)
(2) (year (Type and number)
(3) (month (Type, number))
(4) Monthyear (varchar Type)
Hope you can help.Hello
I don't know if the anychart is sorting. But I'm also very new to apex and graphic.
Trying to sort the query result of the testdate manner with command.If this does not work, you can change your query:
TO_NUMBER (to_char (testdate, 'YYYY') | to_char (testdate, 'MM'))
so you'll get 201201, 201202, 201203,... so it can be sorted.brgds.
Andy -
A query with workingdays by month and per period
Can someone help me on how to build a SQL query that is difficult?
I work with SQL Oracle. It is intended to be calculated over a certain period, to find the working days of each month for each person.
I have a request to work to calculate the number of days 1 month less holidays
SELECT count (*) NUM_WORK_DAYS
De)
Select to_date (January 1, 2010 ", 'dd-mm-yyyy') + ROWNUM-1 day
Of object
Where ROWNUM < to_number (to_char (last_day (January 1, 2010 '), JJ ')) + 1).
Where to_number (to_char (day, 'd.')) between 1 and 5
And not exists (select NULL
Holiday
Where Holiday.hol = day)
There is a datetable with the following structure where I can get the periods:
DATES
YEAR | MONTH | WEEK | SD
2010 | 201002 | 201006 | 02/09/2010
All the required month are present
It is expected that the user gives a start and specify an end time.
I have a table of workingdays per person named
CALENDAR
CAL | MY | MAR | SEA | GAME | FRI | SAM | SUN
Nobody | THERE | THERE | N | THERE | THERE | N | N
And an array of holidays
HOLIDAY
CAL | HOL
Nobody | 01/01/2010
How can I combine the query for the business days and create a query that returns the number of workingdays by month for many people for several months? I will ask the user to give a start point and an end of period
I am aware that I ask a lot of your time, but I can't imagine the solution myself. Thanks in advance
GR,
ElsYou can change the query in this way:
with period as ( select DATE '&start_day' start_date, DATE '&end_day' end_date from dual), days as ( select start_date+level-1 day from dual,period connect by level <= end_date-start_date+1), mycal as ( select person, 'monday' day, mon works from calendar union all select person, 'tuesday' day, tue from calendar union all select person, 'wednesday' day, wed from calendar union all select person, 'thursday' day, thu from calendar union all select person, 'friday' day, fri from calendar union all select person, 'saturday' day, sat from calendar union all select person, 'sunday' day, sun from calendar ) select person, to_char(d.day,'yyyymm') month, count(0) from mycal c, days d where c.day = trim(to_char(d.day,'day')) and c.works='Y' and not exists (select 1 from holiday h where h.person=c.person and h.hol=d.day) group by person, to_char(d.day,'yyyymm');
Max
http://oracleitalia.WordPress.com -
If I have code like this:
... I fear that the random values assigned to line 3 of my code are not very random, because the seeding of randomization is made once (it seems) and therefore, all updates to the third line are hunted by a seed.begin select to_number(to_char(sysdate,'MMHH24DDMIYYYYSS'))/10000 into v_seed from dual; dbms_random.initialize(v_seed); update my_table set my_column=dbms_random.value(0,5500); commit; end;
So I changed the code to do this:
Now, the initialization is done within a loop, it seems to me that my random numbers should be much more random than they were. Of course, my code now works about 3000 times slower than it did before, too.declare cursor c1 is select colx from my_table; begin for x in c1 loop select to_number(to_char(sysdate,'MMHH24DDMIYYYYSS'))/10000 into v_seed from dual; dbms_random.initialize(v_seed); update my_table set my_column=dbms_random.value(0,5500) where colx=x.colx; commit; end loop; end;
Empirically, the results of this second bit of code actually look much more random than the first, even after execution of half a dozen. But who knows if it is authentic or not, given the nature of randomness?
My questions: am I right in thinking the first code example is a problem, producing suboptimal randomization due to the approach of one-seed-fits-all-updates?
Is it possible to combine the approach multi-semence, Super random of the second sort of code with the first effective let's-not-loop-unless-we-have-to approach?Add two pseudo-random numbers shouldn't make the result more random, no. It should very slightly reduce the randomness as make you more likely to get a number close to the mid range and less likely to get a number near the top or bottom of the range end.
Justin
Maybe you are looking for
-
bought the subscription of season for the tv series, but the episode is not available
is there a time limit for the new episodes when the season is purchased - the most recent episode aired on 3/16 Wednesday, but is not available in my shopping list, even if it is available for sale separately?
-
Fan kicks hard enough every minute on Satellite L30
Hello I use a laptop Satellite L30. One thing that I find annoying is that the fan is used strong enough every minute or so, then quieted down for a while. Using a temperature monitor that looks like the fan is used when the temperature exceeds about
-
I want to see bill by imei iphone because I don't know where he is
I want to see bill by imei iphone because I don't know where he is right now
-
ACQUISITION_START_TIME
Hello I'm trying to set ACQUISITION_START_TIME to Tektronix DPO3034 through interface USB with CVI.I managed to install the driver and can communicate with the oscilloscope.When I write the time-out value (3.5334E - 005) that's what I get from the Sp
-
Why am I receiving calls supposely microsoft customer service about my computer being hacked?
When I get a call the guy on the phone told me that he works for Microsoft and it want let me know they get reports from my computer. The issue is on my pc was hacked. The guy offers to "help me". Of course I do not provide information ask him or giv