Help with a union all statement
Hello
I am pulling a query much like this:
(select ID, Created_timestamp from snapshot1
where created_timestamp >= to_date ('8/15/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM')
and created_timestamp < to_date('8/18/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM'))
UNION ALL
(select ID, created_timestamp from snapshot2
where created_timestamp >= to_date ('8/15/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM')
and created_timestamp < to_date('8/18/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM'))
UNION ALL
(select ID, created_timestamp from data_history
where created_timestamp >= to_date ('8/15/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM')
and created_timestamp < to_date('8/18/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM'))
Is there an easier way to handle created_timestamp?
I would like to put it at the beginning so I only have to change it in one place.
I don't understand.
I try your with statement and get: "end_date" invalid identifier as an error
I start my query out:
WITH start_date as
(select to_date ('08/15/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM') from dual),
end_date as (select to_date ('08/18/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM) from dual)
select sales.id, start_date as callstart, end_date as callend
where sales.created_timestamp >= start_date
and sales.created_timestamp < end_date
UNION ALL
<<<<<<<here is where you take the last select statement and replace sales with manufacturing>>>>>>>>>>>>>
UNION ALL
<<<<<<<here is where you take the last select statement and replace sales with engineering>>>>>>>>>>>>>
and it still fails.
Similar Messages
-
Hi
The problem Im having is that I had a query on sales order tables that used to take a couple of minutes to run. The user wanted contract orders to be added to the query and these were stored in different tables to the sales orders. I carried out union all joins in views and then applied the query to the views. Unfortunately it now takes 30 minutes to run.
I apologise for the large post, I am just trying to provide enough information for someone to help me out.
Any help will be greatly appreciated.
Thanks
Stephen
The original query was:
SELECT
C_STD_COST.MAT, C_STD_COST.LAB, C_STD_COST.OHD, ITEM.PC, BILL_HDR.RATE,
BILL_SO.SO_SHIP_QTY, BILL_SO.SO_SHIP_EXT_AMT, AR_DOC.CUSTOMER,
BILL_SO.AR_DOC,
CUS_LOC.NAME, AR_DOC.CREATED_DATE, MEMO.TOT_ORD_QTY, MEMO.UNIT_PRICE,
MEMO.BOOK_RATE, AR_DOC.AR_DOC_TYPE, MEMO.MEMO_TYPE, BILL_SO.ITEM
FROM
AR_DOC, BILL_HDR, CUS_LOC, BILL_SO, ITEM, MEMO, C_STD_COST
WHERE
AR_DOC.AR_CCN=BILL_HDR.AR_CCN AND
AR_DOC.AR_DOC_TYPE=BILL_HDR.AR_DOC_TYPE AND
AR_DOC.AR_DOC=BILL_HDR.AR_DOC AND
AR_DOC.CUSTOMER=CUS_LOC.CUSTOMER AND
AR_DOC.CUS_AR_LOC=CUS_LOC.CUS_LOC AND
BILL_HDR.AR_CCN=BILL_SO.AR_CCN AND
BILL_HDR.AR_DOC_TYPE=BILL_SO.AR_DOC_TYPE AND
BILL_HDR.AR_DOC=BILL_SO.AR_DOC AND
BILL_SO.ITEM=ITEM.ITEM (+) AND
BILL_SO.REVISION=ITEM.REVISION (+) AND
BILL_SO.AR_DOC=MEMO.AR_DOC (+) AND
BILL_SO.AR_DOC_LINE=MEMO.MEMO_LINE (+) AND
BILL_SO.AR_CCN=MEMO.SALES_CCN (+) AND
BILL_SO.AR_DOC_TYPE=MEMO.MEMO_TYPE (+) AND
ITEM.ITEM=C_STD_COST.ITEM (+) AND
ITEM.REVISION=C_STD_COST.REVISION (+) AND
AR_DOC.CREATED_DATE>=TO_DATE ('30-05-2006 00:00:00', 'DD-MM-YYYY
HH24:MI:SS') AND
AR_DOC.CREATED_DATE<TO_DATE ('14-06-2006 00:00:00', 'DD-MM-YYYY
HH24:MI:SS')
ORDER BY
AR_DOC.CUSTOMER, ITEM.PCThe explain plan showed:
SELECT STATEMENT
SORT ORDER BY
MERGE JOIN OUTER
SORT JOIN
NESTED LOOPS OUTER
NESTED LOOPS
NESTED LOOPS
NESTED LOOPS
NESTED LOOPS OUTER
TABLE ACCESS FULL BILL_SO 4
TABLE ACCESS BY INDEX ROWID ITEM 5
INDEX UNIQUE SCAN PK_ITEM UNIQUE
TABLE ACCESS BY INDEX ROWID BILL_HDR 2
INDEX UNIQUE SCAN PK_BILL_HDR UNIQUE
TABLE ACCESS BY INDEX ROWID AR_DOC 1
INDEX UNIQUE SCAN PK_AR_DOC UNIQUE
TABLE ACCESS BY INDEX ROWID CUS_LOC 3
INDEX UNIQUE SCAN PK_CUS_LOC UNIQUE
TABLE ACCESS BY INDEX ROWID MEMO 6
INDEX RANGE SCAN PK_MEMO UNIQUE
SORT JOIN
TABLE ACCESS FULL COST_ITM 8The views I created were:
CREATE VIEW C_BILL_DET AS
SELECT
AR_CCN, AR_DOC_TYPE, AR_DOC, AR_DOC_LINE, ITEM,
REVISION, SO_SHIP_QTY, SO_SHIP_EXT_AMT, COST1
FROM
BILL_SO
UNION ALL
SELECT
AR_CCN, AR_DOC_TYPE, AR_DOC, AR_DOC_LINE, ITEM,
REVISION, SHIP_QTY, SHIP_EXT_AMT, COST1
FROM
CR_BLSH;
CREATE VIEW C_BILL_HDR AS
SELECT
AR_CCN, AR_DOC_TYPE, AR_DOC, RATE
FROM
BILL_HDR
UNION ALL
SELECT
AR_CCN, AR_DOC_TYPE, AR_DOC, RATE
FROM
CR_BLHD;The new query is:
SELECT
C_STD_COST.MAT, C_STD_COST.LAB, C_STD_COST.OHD, ITEM.PC, C_BILL_HDR.RATE,
C_BILL_DET.SO_SHIP_QTY, C_BILL_DET.SO_SHIP_EXT_AMT, AR_DOC.CUSTOMER,
C_BILL_DET.AR_DOC,
CUS_LOC.NAME, AR_DOC.CREATED_DATE, MEMO.TOT_ORD_QTY, MEMO.UNIT_PRICE,
MEMO.BOOK_RATE, AR_DOC.AR_DOC_TYPE, MEMO.MEMO_TYPE, C_BILL_DET.ITEM
FROM
AR_DOC, C_BILL_HDR, CUS_LOC, C_BILL_DET, ITEM, MEMO, C_STD_COST
WHERE
AR_DOC.AR_CCN=C_BILL_HDR.AR_CCN AND
AR_DOC.AR_DOC_TYPE=C_BILL_HDR.AR_DOC_TYPE AND
AR_DOC.AR_DOC=C_BILL_HDR.AR_DOC AND
AR_DOC.CUSTOMER=CUS_LOC.CUSTOMER AND
AR_DOC.CUS_AR_LOC=CUS_LOC.CUS_LOC AND
C_BILL_HDR.AR_CCN=C_BILL_DET.AR_CCN AND
C_BILL_HDR.AR_DOC_TYPE=C_BILL_DET.AR_DOC_TYPE AND
C_BILL_HDR.AR_DOC=C_BILL_DET.AR_DOC AND
C_BILL_DET.ITEM=ITEM.ITEM (+) AND
C_BILL_DET.REVISION=ITEM.REVISION (+) AND
C_BILL_DET.AR_DOC=MEMO.AR_DOC (+) AND
C_BILL_DET.AR_DOC_LINE=MEMO.MEMO_LINE (+) AND
C_BILL_DET.AR_CCN=MEMO.SALES_CCN (+) AND
C_BILL_DET.AR_DOC_TYPE=MEMO.MEMO_TYPE (+) AND
ITEM.ITEM=C_STD_COST.ITEM (+) AND
ITEM.REVISION=C_STD_COST.REVISION (+) AND
AR_DOC.CREATED_DATE>=TO_DATE ('30-05-2006 00:00:00', 'DD-MM-YYYY
HH24:MI:SS') AND
AR_DOC.CREATED_DATE<TO_DATE ('14-06-2006 00:00:00', 'DD-MM-YYYY
HH24:MI:SS')
ORDER BY
AR_DOC.CUSTOMER, ITEM.PCThe explain plan is:
SELECT STATEMENT
SORT ORDER BY
MERGE JOIN OUTER
SORT JOIN
NESTED LOOPS
NESTED LOOPS
MERGE JOIN
SORT JOIN
NESTED LOOPS OUTER
NESTED LOOPS OUTER
VIEW C_BILL_DET 4
UNION-ALL
TABLE ACCESS FULL BILL_SO 9
TABLE ACCESS FULL CR_BLSH 10
TABLE ACCESS BY INDEX ROWID ITEM 5
INDEX UNIQUE SCAN PK_ITEM UNIQUE
TABLE ACCESS BY INDEX ROWID MEMO 6
INDEX RANGE SCAN PK_MEMO UNIQUE
SORT JOIN
VIEW C_BILL_HDR 2
UNION-ALL
TABLE ACCESS FULL BILL_HDR 11
TABLE ACCESS FULL CR_BLHD 12
TABLE ACCESS BY INDEX ROWID AR_DOC 1
INDEX UNIQUE SCAN PK_AR_DOC UNIQUE
TABLE ACCESS BY INDEX ROWID CUS_LOC 3
INDEX UNIQUE SCAN PK_CUS_LOC UNIQUE
SORT JOIN
TABLE ACCESS FULL COST_ITM 8I don't understand.
I try your with statement and get: "end_date" invalid identifier as an error
I start my query out:
WITH start_date as
(select to_date ('08/15/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM') from dual),
end_date as (select to_date ('08/18/2007 12:00:00 AM','MM/DD/YYYY HH:MI:SS AM) from dual)
select sales.id, start_date as callstart, end_date as callend
where sales.created_timestamp >= start_date
and sales.created_timestamp < end_date
UNION ALL
<<<<<<<here is where you take the last select statement and replace sales with manufacturing>>>>>>>>>>>>>
UNION ALL
<<<<<<<here is where you take the last select statement and replace sales with engineering>>>>>>>>>>>>>
and it still fails. -
Re Creating a chart getting an error with a 'Union All' statement
Hi
I have some data to chart with the following fields;
Product , Jul-08 , Aug-08, Sep-08 etc ...... to Jan-10.
The PRODUCT field is text showing the numerous Product Names
The Jul-08 & other month fields have numbers per product that is to be aggregated for that month & plotted on the line graph.
My SQL to create the first point on the chart is as below;
select null link, PRODUCT label, SUM(JUL-08) "FFF"
from "SCHEMANAME"."TABLENAME"
WHERE PRODUCT = 'FFF'
GROUP by PRODUCT
ORDER BY PRODUCT
This works fine until I want add the second point of this line graph using a 'union all' join as follows;
select null link, PRODUCT label, SUM(JUL_08) "FFF"
from "SCHEMANAME"."TABLENAME"
WHERE PRODUCT = 'FFF'
UNION ALL
select null link, PRODUCT label, SUM(AUG_08) "FFF"
from "SCHEMANAME"."TABLENAME"
WHERE PRODUCT = 'FFF'
I can't work out how I can join the other months on the line graph in one series.
The error is as follows;
1 error has occurred
Failed to parse SQL query:
select null link, PRODUCT label, SUM(OCT_09) "NCDS - STD" from "BI_A_DATA"."CDW_VS_NCDS_CALLS" WHERE PRODUCT = 'NCDS - STD' UNION ALL select null link, PRODUCT label, SUM(NOV_09) "NCDS - LOCAL" from "BI_A_DATA"."CDW_VS_NCDS_CALLS" WHERE PRODUCT = 'NCDS - LOCAL'
ORA-00937: not a single-group group function
Certain queries can only be executed when running your application, if your query appears syntactically correct, you can save your query without validation (see options below query source).
Can anyone assist?
I want a continuous Line Graph that shows all the months from Jul-08 , Aug-08, Sep-08 etc ...... to Jan-10 for the same product.
I will then add other series for the other products, ThanksOK, I thought each month would be separated by the different months in each selct subquery, but I see what you mean.
I'm creating a line graph for various PRODUCTS that has a numeric value for each month, from JUL_08 ..... for a number of months.
I want a LINE graph that shows the different totals each month for that PRODUCT.
The error advises that there are more values in the SELECT statement than the expected and to use Use the following syntax:
SELECT LINK, LABEL, VALUE
FROM ...
I then went on to use the '[ ]' brackets to separate data but this didn't fix the problem.
I've changed the script to suit as per your 'PERIOD' addition but now have the error as per below;
error script
1 error has occurred
Invalid chart query: SELECT null link, PRODUCT label, PERIOD, SUM(ABC) FROM (SELECT null link, PRODUCT, 'JUL_08' PERIOD,SUM(JUL_08)ABC FROM BI_A_DATA.APEX_TEST WHERE PRODUCT = 'ABC' GROUP BY PRODUCT UNION ALL SELECT null link, PRODUCT, 'AUG_08' PERIOD,SUM(AUG_08)ABC FROM BI_A_DATA.APEX_TEST WHERE PRODUCT = 'ABC' GROUP BY PRODUCT UNION ALL SELECT null link, PRODUCT, 'SEP_08' PERIOD,SUM(SEP_08)ABC FROM BI_A_DATA.APEX_TEST WHERE PRODUCT = 'ABC' GROUP BY PRODUCT) GROUP BY link, PRODUCT, PERIOD
Use the following syntax:
SELECT LINK, LABEL, VALUE
FROM ...
Or use the following syntax for a query returning multiple series:
SELECT LINK, LABEL, VALUE1 [, VALUE2 [, VALUE3...]]
FROM ...
LINK URL
LABEL Text that displays along a chart axis.
VALUE1, VALUE2, VALUE3... Numeric columns that define the data values.
Note: The series names for Column and Line charts are derived from the column aliases used in the query.
My script amended;
SELECT null link, PRODUCT label, PERIOD, SUM(ABC)
FROM
(SELECT null link, PRODUCT, 'JUL_08' PERIOD,SUM(JUL_08)ABC
FROM BI_A_DATA.APEX_TEST
WHERE PRODUCT = 'ABC'
GROUP BY PRODUCT
UNION ALL
SELECT null link, PRODUCT, 'AUG_08' PERIOD,SUM(AUG_08)ABC
FROM BI_A_DATA.APEX_TEST
WHERE PRODUCT = 'ABC'
GROUP BY PRODUCT
UNION ALL
SELECT null link, PRODUCT, 'SEP_08' PERIOD,SUM(SEP_08)ABC
FROM BI_A_DATA.APEX_TEST
WHERE PRODUCT = 'ABC'
GROUP BY PRODUCT)
GROUP BY link, PRODUCT, PERIOD -
Help required on UNION ALL for select query
Hello all,
The execution plan for an SQL is impacted when another SELECT is concatenated with a UNION ALL. The two SELECTS are very efficient when run separately (< 100 buffer gets), but when run together (using a UNION ALL), the execution plan changes (for the first SELECT) and the buffer gets jumps to over 45000!
what customer says with the UNION ALL, Oracle instead of doing a Merge Scan (that allows the inner table to filter out the rows from the outer table), chooses to do a NL join. This results in a Unique Index scan for each one of the 15000 rows in the outer table, resulting in 46000 consistent gets.
Can you please suggest customer why plan changes when they use UNION ALL & also suggest better way of running query.
Please refer to below explain plan .
WITH THE UNIONS
===============
1 SELECT count(*)
2 FROM SOC_LIST SOC
3 WHERE
4 ( EXISTS( SELECT 1
5 FROM ELIGIBILITY_RELATION
6 WHERE SRC_CODE = 'SHDMM4215'
7 AND DEST_CODE = SOC.SOC
8 AND SRC_TYPE = 'P'
9 AND DEST_TYPE = 'S'))
10 UNION ALL
11 SELECT count(*)
12 FROM SOC_LIST SOC
13* WHERE ( = 'Y')
12:25:39 SQL> /
COUNT(*)
153
0
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=31 Card=2 Bytes=10)
1 0 UNION-ALL
2 1 SORT (AGGREGATE)
3 2 FILTER
4 3 TABLE ACCESS (FULL) OF 'SOC_LIST' (Cost=15 Card=749
Bytes=7490)
5 3 PARTITION HASH (SINGLE)
6 5 INDEX (UNIQUE SCAN) OF 'ELIGIBILITY_RELATION_PK' (
UNIQUE) (Cost=2 Card=1 Bytes=24)
7 1 SORT (AGGREGATE)
8 7 FILTER
9 8 TABLE ACCESS (FULL) OF 'SOC_LIST' (Cost=15 Card=1497
8)
Statistics
0 recursive calls
0 db block gets
46712 consistent gets <------large number
0 physical reads
0 redo size
215 bytes sent via SQL*Net to client
241 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
2 rows processed
12:25:40 SQL> ed
Wrote file C:/PADDY/AFIEDT.BUF
PART 1 of the UNION ALL
========================
1 SELECT count(*)
2 FROM SOC_LIST SOC
3 WHERE
4 ( EXISTS( SELECT 1
5 FROM ELIGIBILITY_RELATION
6 WHERE SRC_CODE = 'SHDMM4215'
7 AND DEST_CODE = SOC.SOC
8 AND SRC_TYPE = 'P'
9* AND DEST_TYPE = 'S'))
12:25:54 SQL> /
COUNT(*)
153
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=4 Card=1 Bytes=34)
1 0 SORT (AGGREGATE)
2 1 MERGE JOIN (SEMI) (Cost=4 Card=149 Bytes=5066)
3 2 INDEX (FULL SCAN) OF 'SOC_LIST_1IX' (NON-UNIQUE) (Cost
=41 Card=14978 Bytes=149780)
4 2 SORT (UNIQUE) (Cost=3 Card=149 Bytes=3576)
5 4 PARTITION HASH (ALL)
6 5 INDEX (RANGE SCAN) OF 'ELIGIBILITY_RELATION_PK' (U
NIQUE) (Cost=10 Card=149 Bytes=3576)
Statistics
0 recursive calls
0 db block gets
56 consistent gets
0 physical reads
0 redo size
218 bytes sent via SQL*Net to client
241 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
1 rows processed
12:25:55 SQL> ed
Wrote file C:/PADDY/AFIEDT.BUF
PART 2 of the UNION ALL
========================
1 SELECT count(*)
2 FROM SOC_LIST SOC
3* WHERE ( = 'Y')
12:26:15 SQL> /
COUNT(*)
0
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=15 Card=1)
1 0 SORT (AGGREGATE)
2 1 FILTER
3 2 TABLE ACCESS (FULL) OF 'SOC_LIST' (Cost=15 Card=14978)
Statistics
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
215 bytes sent via SQL*Net to client
241 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
12:26:20 SQL> spool off
Same results but with theUNION ALL, the buffergets is massive ...
Thanks
Krishnai am also attaching 10043/10053 trace file .
/opt/oracle/adm/STCUST/udump/stcust_ora_7919_10046_10053_trace_file.trc
*** TRACE DUMP CONTINUED FROM FILE ***
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
ORACLE_HOME = /opt/oracle/product/9.2.0.8
System name: HP-UX
Node name: rcihp009
Release: B.11.23
Version: U
Machine: 9000/800
Instance name: STCUST
Redo thread mounted by this instance: 1
Oracle process number: 152
Unix process pid: 7919, image: oracle@rcihp009 (TNS V1-V3)
*** 2013-06-10 13:32:48.943
*** SESSION ID:(533.15875) 2013-06-10 13:32:48.943
APPNAME mod='SQL*Plus' mh=3669949024 act='' ah=4029777240
=====================
PARSING IN CURSOR #1 len=69 dep=0 uid=33 oct=42 lid=33 tim=3017585934213 hv=2004533713 ad='4aa33998'
alter session set events '10046 trace name context forever, level 12'
END OF STMT
EXEC #1:c=0,e=209,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=4,tim=3017585933683
WAIT #1: nam='SQL*Net message to client' ela= 3 p1=1413697536 p2=1 p3=0
*** 2013-06-10 13:33:00.090
WAIT #1: nam='SQL*Net message from client' ela= 10884599 p1=1413697536 p2=1 p3=0
=====================
PARSING IN CURSOR #1 len=69 dep=0 uid=33 oct=42 lid=33 tim=3017596819944 hv=2030017677 ad='3af92970'
alter session set events '10053 trace name context forever, level 1'
END OF STMT
PARSE #1:c=0,e=484,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=4,tim=3017596819933
BINDS #1:
EXEC #1:c=0,e=160,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=3017596820180
WAIT #1: nam='SQL*Net message to client' ela= 3 p1=1413697536 p2=1 p3=0
*** 2013-06-10 13:33:50.197
WAIT #1: nam='SQL*Net message from client' ela= 48932344 p1=1413697536 p2=1 p3=0
PARAMETERS USED BY THE OPTIMIZER
OPTIMIZER_FEATURES_ENABLE = 9.2.0
OPTIMIZER_MODE/GOAL = Choose
_OPTIMIZER_PERCENT_PARALLEL = 101
HASH_AREA_SIZE = 131072
HASH_JOIN_ENABLED = TRUE
HASH_MULTIBLOCK_IO_COUNT = 0
SORT_AREA_SIZE = 65536
OPTIMIZER_SEARCH_LIMIT = 5
PARTITION_VIEW_ENABLED = FALSE
_ALWAYS_STAR_TRANSFORMATION = FALSE
_B_TREE_BITMAP_PLANS = TRUE
STAR_TRANSFORMATION_ENABLED = FALSE
_COMPLEX_VIEW_MERGING = TRUE
_PUSH_JOIN_PREDICATE = TRUE
PARALLEL_BROADCAST_ENABLED = TRUE
OPTIMIZER_MAX_PERMUTATIONS = 2000
OPTIMIZER_INDEX_CACHING = 0
_SYSTEM_INDEX_CACHING = 0
OPTIMIZER_INDEX_COST_ADJ = 1
OPTIMIZER_DYNAMIC_SAMPLING = 1
_OPTIMIZER_DYN_SMP_BLKS = 32
QUERY_REWRITE_ENABLED = TRUE
QUERY_REWRITE_INTEGRITY = ENFORCED
_INDEX_JOIN_ENABLED = TRUE
_SORT_ELIMINATION_COST_RATIO = 0
_OR_EXPAND_NVL_PREDICATE = TRUE
_NEW_INITIAL_JOIN_ORDERS = TRUE
ALWAYS_ANTI_JOIN = CHOOSE
ALWAYS_SEMI_JOIN = CHOOSE
_OPTIMIZER_MODE_FORCE = TRUE
_OPTIMIZER_UNDO_CHANGES = FALSE
_UNNEST_SUBQUERY = TRUE
_PUSH_JOIN_UNION_VIEW = TRUE
_FAST_FULL_SCAN_ENABLED = TRUE
_OPTIM_ENHANCE_NNULL_DETECTION = TRUE
_ORDERED_NESTED_LOOP = TRUE
_NESTED_LOOP_FUDGE = 100
_NO_OR_EXPANSION = FALSE
_QUERY_COST_REWRITE = TRUE
QUERY_REWRITE_EXPRESSION = TRUE
_IMPROVED_ROW_LENGTH_ENABLED = TRUE
_USE_NOSEGMENT_INDEXES = FALSE
_ENABLE_TYPE_DEP_SELECTIVITY = TRUE
_IMPROVED_OUTERJOIN_CARD = TRUE
_OPTIMIZER_ADJUST_FOR_NULLS = TRUE
_OPTIMIZER_CHOOSE_PERMUTATION = 0
_USE_COLUMN_STATS_FOR_FUNCTION = TRUE
_SUBQUERY_PRUNING_ENABLED = TRUE
_SUBQUERY_PRUNING_REDUCTION_FACTOR = 50
_SUBQUERY_PRUNING_COST_FACTOR = 20
_LIKE_WITH_BIND_AS_EQUALITY = FALSE
_TABLE_SCAN_COST_PLUS_ONE = TRUE
_SORTMERGE_INEQUALITY_JOIN_OFF = FALSE
_DEFAULT_NON_EQUALITY_SEL_CHECK = TRUE
_ONESIDE_COLSTAT_FOR_EQUIJOINS = TRUE
_OPTIMIZER_COST_MODEL = CHOOSE
_GSETS_ALWAYS_USE_TEMPTABLES = FALSE
DB_FILE_MULTIBLOCK_READ_COUNT = 128
_NEW_SORT_COST_ESTIMATE = TRUE
_GS_ANTI_SEMI_JOIN_ALLOWED = TRUE
_CPU_TO_IO = 0
_PRED_MOVE_AROUND = TRUE
BASE STATISTICAL INFORMATION
Table stats Table: SOC_LIST Alias: SOC
TOTAL :: CDN: 17584 NBLKS: 653 AVG_ROW_LEN: 260
Column: SOC Col#: 3 Table: SOC_LIST Alias: SOC
NDV: 17584 NULLS: 0 DENS: 5.6870e-05
NO HISTOGRAM: #BKT: 1 #VAL: 2
-- Index stats
INDEX NAME: I_SNAP$_SOC_LIST COL#: 1
TOTAL :: LVLS: 1 #LB: 64 #DK: 17487 LB/K: 1 DB/K: 1 CLUF: 699
INDEX NAME: SOC_LIST_1IX COL#: 3
TOTAL :: LVLS: 1 #LB: 47 #DK: 17487 LB/K: 1 DB/K: 1 CLUF: 14065
Table stats Table: ELIGIBILITY_RELATION Alias: ELIGIBILITY_RELATION
(Using composite stats)
TOTAL :: CDN: 11982220 NBLKS: 125493 AVG_ROW_LEN: 71
-- Index stats
INDEX NAME: ELIGIBILITY_RELATION_1IX COL#: 3 4 5
USING COMPOSITE STATS
TOTAL :: LVLS: 2 #LB: 38360 #DK: 4164 LB/K: 9 DB/K: 740 CLUF: 3081860
INDEX NAME: ELIGIBILITY_RELATION_PK COL#: 2 3 4 5
USING COMPOSITE STATS
TOTAL :: LVLS: 2 #LB: 50740 #DK: 11873160 LB/K: 1 DB/K: 1 CLUF: 9158280
INDEX NAME: I_SNAP$_ELIGIBILITY_RELATI COL#: 1
TOTAL :: LVLS: 2 #LB: 49600 #DK: 11953600 LB/K: 1 DB/K: 1 CLUF: 8833300
_OPTIMIZER_PERCENT_PARALLEL = 0
SINGLE TABLE ACCESS PATH
Column: SRC_CODE Col#: 2 Table: ELIGIBILITY_RELATION Alias: ELIGIBILITY_RELATION
NDV: 22087 NULLS: 0 DENS: 4.5276e-05
NO HISTOGRAM: #BKT: 1 #VAL: 2
Column: SRC_TYPE Col#: 3 Table: ELIGIBILITY_RELATION Alias: ELIGIBILITY_RELATION
NDV: 2 NULLS: 0 DENS: 5.0000e-01
NO HISTOGRAM: #BKT: 1 #VAL: 2
Column: DEST_TYPE Col#: 5 Table: ELIGIBILITY_RELATION Alias: ELIGIBILITY_RELATION
NDV: 2 NULLS: 0 DENS: 5.0000e-01
NO HISTOGRAM: #BKT: 1 #VAL: 2
TABLE: ELIGIBILITY_RELATION ORIG CDN: 11982220 ROUNDED CDN: 136 CMPTD CDN: 136
Access path: tsc Resc: 3072 Resp: 3072
Access path: index (iff)
Index: ELIGIBILITY_RELATION_PK
TABLE: ELIGIBILITY_RELATION
RSC_CPU: 0 RSC_IO: 1243
IX_SEL: 0.0000e+00 TB_SEL: 1.0000e+00
Access path: iff Resc: 1243 Resp: 1243
Skip scan: ss-sel 0 andv 11970
ss cost 119700
index io scan cost 19180
Access path: index (scan)
Index: ELIGIBILITY_RELATION_1IX
TABLE: ELIGIBILITY_RELATION
RSC_CPU: 0 RSC_IO: 789653
IX_SEL: 5.0000e-01 TB_SEL: 2.5000e-01
Skip scan: ss-sel 0 andv 11970
ss cost 11970
index io scan cost 2
Access path: index (index-only)
Index: ELIGIBILITY_RELATION_PK
TABLE: ELIGIBILITY_RELATION
RSC_CPU: 0 RSC_IO: 10
IX_SEL: 2.2638e-05 TB_SEL: 2.2638e-05
****** trying bitmap/domain indexes ******
****** finished trying bitmap/domain indexes ******
BEST_CST: 1.00 PATH: 4 Degree: 1
SINGLE TABLE ACCESS PATH
TABLE: SOC_LIST ORIG CDN: 17584 ROUNDED CDN: 17584 CMPTD CDN: 17584
Access path: tsc Resc: 18 Resp: 18
Access path: index (iff)
Index: SOC_LIST_1IX
TABLE: SOC_LIST
RSC_CPU: 0 RSC_IO: 3
IX_SEL: 0.0000e+00 TB_SEL: 1.0000e+00
Access path: iff Resc: 3 Resp: 3
Access path: index (no sta/stp keys)
Index: SOC_LIST_1IX
TABLE: SOC_LIST
RSC_CPU: 0 RSC_IO: 48
IX_SEL: 1.0000e+00 TB_SEL: 1.0000e+00
BEST_CST: 1.00 PATH: 4 Degree: 1
OPTIMIZER STATISTICS AND COMPUTATIONS
GENERAL PLANS
Join order[1]: SOC_LIST[SOC]#0 ELIGIBILITY_RELATION[ELIGIBILITY_RELATION]#1
Now joining: ELIGIBILITY_RELATION[ELIGIBILITY_RELATION]#1 *******
NL Join
Outer table: cost: 1 cdn: 17584 rcz: 10 resp: 1
Inner table: ELIGIBILITY_RELATION
Access path: tsc Resc: 768
Join: Resc: 13504513 Resp: 13504513
Access path: index (iff)
Index: ELIGIBILITY_RELATION_PK
TABLE: ELIGIBILITY_RELATION
RSC_CPU: 0 RSC_IO: 1243
IX_SEL: 0.0000e+00 TB_SEL: 1.0000e+00
Inner table: ELIGIBILITY_RELATION
Access path: iff Resc: 311
Join: Resc: 5464229 Resp: 5464229
Access path: index (unique)
Index: ELIGIBILITY_RELATION_PK
TABLE: ELIGIBILITY_RELATION
RSC_CPU: 0 RSC_IO: 1
IX_SEL: 8.3457e-08 TB_SEL: 8.3457e-08
Join: resc: 177 resp: 177
Access path: index (join index)
Index: ELIGIBILITY_RELATION_1IX
TABLE: ELIGIBILITY_RELATION
RSC_CPU: 0 RSC_IO: 750
IX_SEL: 0.0000e+00 TB_SEL: 2.0886e-05
Join: resc: 131881 resp: 131881
Access path: index (eq-unique)
Index: ELIGIBILITY_RELATION_PK
TABLE: ELIGIBILITY_RELATION
RSC_CPU: 0 RSC_IO: 1
IX_SEL: 0.0000e+00 TB_SEL: 0.0000e+00
Join: resc: 177 resp: 177
****** trying bitmap/domain indexes ******
Access path: index (join index)
Index: ELIGIBILITY_RELATION_1IX
TABLE: ELIGIBILITY_RELATION
RSC_CPU: 0 RSC_IO: 10
IX_SEL: 1.4217e-05 TB_SEL: 2.0886e-05
Join: resc: 1759 resp: 1759
Access path: index (index-only)
Index: ELIGIBILITY_RELATION_PK
TABLE: ELIGIBILITY_RELATION
RSC_CPU: 0 RSC_IO: 4
IX_SEL: 4.5276e-05 TB_SEL: 4.5276e-05
Join: resc: 704 resp: 704
SORT resource Sort statistics
Sort width: 11 Area size: 628736 Max Area size: 31457280 Degree: 1
Blocks to Sort: 2 Row size: 21 Rows: 543
Initial runs: 1 Merge passes: 1 IO Cost / pass: 3
Total IO sort cost: 2
Total CPU sort cost: 0
Total Temp space used: 0
****** finished trying bitmap/domain indexes ******
Best NL cost: 177 resp: 177
Semi-join cardinality: 135 = outer (17584) * sel (7.6774e-03) [flag=12]
SM Join
Outer table:
resc: 1 cdn: 17584 rcz: 10 deg: 1 resp: 1
Inner table: ELIGIBILITY_RELATION
resc: 1 cdn: 136 rcz: 24 deg: 1 resp: 1
using join:1 distribution:2 #groups:1
SORT resource Sort statistics
Sort width: 11 Area size: 628736 Max Area size: 31457280 Degree: 1
Blocks to Sort: 1 Row size: 37 Rows: 136
Initial runs: 1 Merge passes: 1 IO Cost / pass: 2
Total IO sort cost: 2
Total CPU sort cost: 0
Total Temp space used: 0
Merge join Cost: 4 Resp: 4
HA Join
Outer table:
resc: 1 cdn: 17584 rcz: 10 deg: 1 resp: 1
Inner table: ELIGIBILITY_RELATION
resc: 1 cdn: 136 rcz: 24 deg: 1 resp: 1
using join:8 distribution:2 #groups:1
Hash join one ptn Resc: 4 Deg: 1
hash_area: 154 (max=7680) buildfrag: 48 probefrag: 1 ppasses: 1
Hash join Resc: 6 Resp: 6
Join result: cost: 4 cdn: 135 rcz: 34
Best so far: TABLE#: 0 CST: 1 CDN: 17584 BYTES: 175840
Best so far: TABLE#: 1 CST: 4 CDN: 135 BYTES: 4590
Join order[2]: ELIGIBILITY_RELATION[ELIGIBILITY_RELATION]#1 SOC_LIST[SOC]#0
SORT resource Sort statistics
Sort width: 11 Area size: 628736 Max Area size: 31457280 Degree: 1
Blocks to Sort: 1 Row size: 37 Rows: 136
Initial runs: 1 Merge passes: 1 IO Cost / pass: 2
Total IO sort cost: 2
Total CPU sort cost: 0
Total Temp space used: 0
Now joining: SOC_LIST[SOC]#0 *******
NL Join
Outer table: cost: 3 cdn: 136 rcz: 24 resp: 2
Inner table: SOC_LIST
Access path: tsc Resc: 18
Join: Resc: 2450 Resp: 2450
Access path: index (iff)
Index: SOC_LIST_1IX
TABLE: SOC_LIST
RSC_CPU: 0 RSC_IO: 3
IX_SEL: 0.0000e+00 TB_SEL: 1.0000e+00
Inner table: SOC_LIST
Access path: iff Resc: 3
Join: Resc: 410 Resp: 410
Access path: index (join index)
Index: SOC_LIST_1IX
TABLE: SOC_LIST
RSC_CPU: 0 RSC_IO: 1
IX_SEL: 0.0000e+00 TB_SEL: 5.6870e-05
Join: resc: 4 resp: 4
Best NL cost: 4 resp: 4
Join cardinality: 136 = outer (136) * inner (17584) * sel (5.6870e-05) [flag=0]
SM Join
Outer table:
resc: 2 cdn: 136 rcz: 24 deg: 1 resp: 2
Inner table: SOC_LIST
resc: 1 cdn: 17584 rcz: 10 deg: 1 resp: 1
using join:1 distribution:2 #groups:1
SORT resource Sort statistics
Sort width: 11 Area size: 628736 Max Area size: 31457280 Degree: 1
Blocks to Sort: 1 Row size: 37 Rows: 136
Initial runs: 1 Merge passes: 1 IO Cost / pass: 2
Total IO sort cost: 2
Total CPU sort cost: 0
Total Temp space used: 0
SORT resource Sort statistics
Sort width: 11 Area size: 628736 Max Area size: 31457280 Degree: 1
Blocks to Sort: 46 Row size: 21 Rows: 17584
Initial runs: 1 Merge passes: 1 IO Cost / pass: 51
Total IO sort cost: 48
Total CPU sort cost: 0
Total Temp space used: 0
Merge join Cost: 54 Resp: 54
HA Join
Outer table:
resc: 2 cdn: 136 rcz: 24 deg: 1 resp: 2
Inner table: SOC_LIST
resc: 1 cdn: 17584 rcz: 10 deg: 1 resp: 1
using join:8 distribution:2 #groups:1
Hash join one ptn Resc: 1 Deg: 1
hash_area: 154 (max=7680) buildfrag: 1 probefrag: 48 ppasses: 1
Hash join Resc: 4 Resp: 4
Final - All Rows Plan:
JOIN ORDER: 1
CST: 4 CDN: 135 RSC: 4 RSP: 4 BYTES: 4590
IO-RSC: 4 IO-RSP: 4 CPU-RSC: 0 CPU-RSP: 0
QUERY
SELECT count(*)
FROM SOC_LIST SOC
WHERE
( EXISTS( SELECT 1
FROM ELIGIBILITY_RELATION
WHERE SRC_CODE = 'SHDMM4215'
AND DEST_CODE = SOC.SOC
AND SRC_TYPE = 'P'
AND DEST_TYPE = 'S'))
=====================
PARSING IN CURSOR #1 len=278 dep=0 uid=33 oct=3 lid=33 tim=3017645761269 hv=183981413 ad='492d5bb0'
SELECT count(*)
FROM SOC_LIST SOC
WHERE
( EXISTS( SELECT 1
FROM ELIGIBILITY_RELATION
WHERE SRC_CODE = 'SHDMM4215'
AND DEST_CODE = SOC.SOC
AND SRC_TYPE = 'P'
AND DEST_TYPE = 'S'))
END OF STMT
PARSE #1:c=10000,e=8343,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=4,tim=3017645761258
BINDS #1:
EXEC #1:c=0,e=529,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=3017645761970
WAIT #1: nam='SQL*Net message to client' ela= 3 p1=1413697536 p2=1 p3=0
WAIT #1: nam='db file sequential read' ela= 9290 p1=2535 p2=142378 p3=1
WAIT #1: nam='db file sequential read' ela= 2098 p1=2535 p2=142379 p3=1
WAIT #1: nam='db file sequential read' ela= 11574 p1=2535 p2=33834 p3=1
WAIT #1: nam='db file sequential read' ela= 10290 p1=2536 p2=60958 p3=1
WAIT #1: nam='db file sequential read' ela= 11469 p1=2535 p2=61232 p3=1
WAIT #1: nam='db file sequential read' ela= 378 p1=2535 p2=61233 p3=1
WAIT #1: nam='db file sequential read' ela= 5493 p1=2535 p2=39498 p3=1
WAIT #1: nam='db file sequential read' ela= 7397 p1=2536 p2=68185 p3=1
WAIT #1: nam='db file sequential read' ela= 10037 p1=2536 p2=68520 p3=1
WAIT #1: nam='db file sequential read' ela= 16125 p1=2535 p2=68809 p3=1
WAIT #1: nam='db file sequential read' ela= 12426 p1=2535 p2=45162 p3=1
WAIT #1: nam='db file sequential read' ela= 12447 p1=2535 p2=178335 p3=1
WAIT #1: nam='db file sequential read' ela= 5974 p1=2535 p2=178798 p3=1
WAIT #1: nam='db file sequential read' ela= 1247 p1=2535 p2=178799 p3=1
WAIT #1: nam='db file sequential read' ela= 11010 p1=2535 p2=50826 p3=1
WAIT #1: nam='db file sequential read' ela= 5421 p1=2536 p2=260451 p3=1
WAIT #1: nam='db file sequential read' ela= 8230 p1=2536 p2=261538 p3=1
WAIT #1: nam='db file sequential read' ela= 350 p1=2535 p2=142380 p3=1
WAIT #1: nam='db file sequential read' ela= 346 p1=2535 p2=142381 p3=1
WAIT #1: nam='db file sequential read' ela= 343 p1=2535 p2=142382 p3=1
WAIT #1: nam='db file sequential read' ela= 480 p1=2535 p2=142383 p3=1
WAIT #1: nam='db file sequential read' ela= 10237 p1=2535 p2=142384 p3=1
WAIT #1: nam='db file sequential read' ela= 324 p1=2535 p2=142385 p3=1
WAIT #1: nam='db file sequential read' ela= 359 p1=2535 p2=142386 p3=1
WAIT #1: nam='db file sequential read' ela= 361 p1=2535 p2=142387 p3=1
WAIT #1: nam='db file sequential read' ela= 375 p1=2535 p2=142388 p3=1
WAIT #1: nam='db file sequential read' ela= 425 p1=2535 p2=142389 p3=1
WAIT #1: nam='db file sequential read' ela= 540 p1=2535 p2=142390 p3=1
WAIT #1: nam='db file sequential read' ela= 368 p1=2535 p2=142391 p3=1
WAIT #1: nam='db file sequential read' ela= 479 p1=2535 p2=142392 p3=1
WAIT #1: nam='db file sequential read' ela= 450 p1=2535 p2=142393 p3=1
WAIT #1: nam='db file sequential read' ela= 307 p1=2535 p2=142394 p3=1
WAIT #1: nam='db file sequential read' ela= 324 p1=2535 p2=142395 p3=1
WAIT #1: nam='db file sequential read' ela= 396 p1=2535 p2=142396 p3=1
WAIT #1: nam='db file sequential read' ela= 376 p1=2535 p2=142397 p3=1
WAIT #1: nam='db file sequential read' ela= 295 p1=2535 p2=142398 p3=1
WAIT #1: nam='db file sequential read' ela= 391 p1=2535 p2=142399 p3=1
WAIT #1: nam='db file sequential read' ela= 396 p1=2535 p2=142400 p3=1
WAIT #1: nam='db file sequential read' ela= 344 p1=2535 p2=142401 p3=1
WAIT #1: nam='db file sequential read' ela= 337 p1=2535 p2=142402 p3=1
WAIT #1: nam='db file sequential read' ela= 360 p1=2535 p2=142403 p3=1
WAIT #1: nam='db file sequential read' ela= 402 p1=2535 p2=142404 p3=1
WAIT #1: nam='db file sequential read' ela= 343 p1=2535 p2=142405 p3=1
WAIT #1: nam='db file sequential read' ela= 408 p1=2535 p2=142406 p3=1
WAIT #1: nam='db file sequential read' ela= 388 p1=2535 p2=142407 p3=1
WAIT #1: nam='db file sequential read' ela= 400 p1=2535 p2=142408 p3=1
WAIT #1: nam='db file sequential read' ela= 7999 p1=2536 p2=617 p3=1
WAIT #1: nam='db file sequential read' ela= 520 p1=2536 p2=618 p3=1
WAIT #1: nam='db file sequential read' ela= 294 p1=2536 p2=619 p3=1
WAIT #1: nam='db file sequential read' ela= 311 p1=2536 p2=620 p3=1
WAIT #1: nam='db file sequential read' ela= 316 p1=2536 p2=621 p3=1
WAIT #1: nam='db file sequential read' ela= 306 p1=2536 p2=622 p3=1
WAIT #1: nam='db file sequential read' ela= 303 p1=2536 p2=623 p3=1
WAIT #1: nam='db file sequential read' ela= 1776 p1=2536 p2=624 p3=1
FETCH #1:c=50000,e=216800,p=54,cr=54,cu=0,mis=0,r=1,dep=0,og=4,tim=3017645978865
WAIT #1: nam='SQL*Net message from client' ela= 2802 p1=1413697536 p2=1 p3=0
FETCH #1:c=0,e=1,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,tim=3017645981803
WAIT #1: nam='SQL*Net message to client' ela= 1 p1=1413697536 p2=1 p3=0
*** 2013-06-10 13:34:28.160
WAIT #1: nam='SQL*Net message from client' ela= 36844121 p1=1413697536 p2=1 p3=0
STAT #1 id=1 cnt=1 pid=0 pos=1 obj=0 op='SORT AGGREGATE (cr=54 r=54 w=0 time=216788 us)'
STAT #1 id=2 cnt=157 pid=1 pos=1 obj=0 op='MERGE JOIN SEMI (cr=54 r=54 w=0 time=216734 us)'
STAT #1 id=3 cnt=14296 pid=2 pos=1 obj=5769123 op='INDEX FULL SCAN SOC_LIST_1IX (cr=39 r=39 w=0 time=55399 us)'
STAT #1 id=4 cnt=157 pid=2 pos=2 obj=0 op='SORT UNIQUE (cr=15 r=15 w=0 time=141933 us)'
STAT #1 id=5 cnt=286 pid=4 pos=1 obj=0 op='PARTITION HASH ALL PARTITION: 1 4 (cr=15 r=15 w=0 time=130847 us)'
STAT #1 id=6 cnt=286 pid=5 pos=1 obj=5401812 op='INDEX RANGE SCAN ELIGIBILITY_RELATION_PK PARTITION: 1 4 (cr=15 r=15 w=0 time=130716 us)'
QUERY
BEGIN := 'N'; END;
=====================
PARSING IN CURSOR #1 len=23 dep=0 uid=33 oct=47 lid=33 tim=3017682828223 hv=16287806 ad='464edb18'
BEGIN := 'N'; END;
END OF STMT
PARSE #1:c=0,e=1569,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=0,tim=3017682828214
BINDS #1:
bind 0: dty=96 mxl=01(01) mal=00 scl=00 pre=00 oacflg=03 oacfl2=200071100000000 size=8 offset=0
bfp=800003ffefe9f748 bln=01 avl=00 flg=05
WAIT #1: nam='SQL*Net message to client' ela= 3 p1=1413697536 p2=1 p3=0
EXEC #1:c=0,e=5494,p=0,cr=0,cu=0,mis=0,r=1,dep=0,og=4,tim=3017682833795
*** 2013-06-10 13:34:44.174
WAIT #1: nam='SQL*Net message from client' ela= 15630899 p1=1413697536 p2=1 p3=0
QUERY
SELECT count(*)
FROM SOC_LIST SOC
WHERE ( = 'Y')
=====================
PARSING IN CURSOR #1 len=65 dep=0 uid=33 oct=3 lid=33 tim=3017698466665 hv=900106749 ad='43145458'
SELECT count(*)
FROM SOC_LIST SOC
WHERE ( = 'Y')
END OF STMT
PARSE #1:c=0,e=1409,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=0,tim=3017698466654
PARAMETERS USED BY THE OPTIMIZER
OPTIMIZER_FEATURES_ENABLE = 9.2.0
OPTIMIZER_MODE/GOAL = Choose
_OPTIMIZER_PERCENT_PARALLEL = 101
HASH_AREA_SIZE = 131072
HASH_JOIN_ENABLED = TRUE
HASH_MULTIBLOCK_IO_COUNT = 0
SORT_AREA_SIZE = 65536
OPTIMIZER_SEARCH_LIMIT = 5
PARTITION_VIEW_ENABLED = FALSE
_ALWAYS_STAR_TRANSFORMATION = FALSE
_B_TREE_BITMAP_PLANS = TRUE
STAR_TRANSFORMATION_ENABLED = FALSE
_COMPLEX_VIEW_MERGING = TRUE
_PUSH_JOIN_PREDICATE = TRUE
PARALLEL_BROADCAST_ENABLED = TRUE
OPTIMIZER_MAX_PERMUTATIONS = 2000
OPTIMIZER_INDEX_CACHING = 0
_SYSTEM_INDEX_CACHING = 0
OPTIMIZER_INDEX_COST_ADJ = 1
OPTIMIZER_DYNAMIC_SAMPLING = 1
_OPTIMIZER_DYN_SMP_BLKS = 32
QUERY_REWRITE_ENABLED = TRUE
QUERY_REWRITE_INTEGRITY = ENFORCED
_INDEX_JOIN_ENABLED = TRUE
_SORT_ELIMINATION_COST_RATIO = 0
_OR_EXPAND_NVL_PREDICATE = TRUE
_NEW_INITIAL_JOIN_ORDERS = TRUE
ALWAYS_ANTI_JOIN = CHOOSE
ALWAYS_SEMI_JOIN = CHOOSE
_OPTIMIZER_MODE_FORCE = TRUE
_OPTIMIZER_UNDO_CHANGES = FALSE
_UNNEST_SUBQUERY = TRUE
_PUSH_JOIN_UNION_VIEW = TRUE
_FAST_FULL_SCAN_ENABLED = TRUE
_OPTIM_ENHANCE_NNULL_DETECTION = TRUE
_ORDERED_NESTED_LOOP = TRUE
_NESTED_LOOP_FUDGE = 100
_NO_OR_EXPANSION = FALSE
_QUERY_COST_REWRITE = TRUE
QUERY_REWRITE_EXPRESSION = TRUE
_IMPROVED_ROW_LENGTH_ENABLED = TRUE
_USE_NOSEGMENT_INDEXES = FALSE
_ENABLE_TYPE_DEP_SELECTIVITY = TRUE
_IMPROVED_OUTERJOIN_CARD = TRUE
_OPTIMIZER_ADJUST_FOR_NULLS = TRUE
_OPTIMIZER_CHOOSE_PERMUTATION = 0
_USE_COLUMN_STATS_FOR_FUNCTION = TRUE
_SUBQUERY_PRUNING_ENABLED = TRUE
_SUBQUERY_PRUNING_REDUCTION_FACTOR = 50
_SUBQUERY_PRUNING_COST_FACTOR = 20
_LIKE_WITH_BIND_AS_EQUALITY = FALSE
_TABLE_SCAN_COST_PLUS_ONE = TRUE
_SORTMERGE_INEQUALITY_JOIN_OFF = FALSE
_DEFAULT_NON_EQUALITY_SEL_CHECK = TRUE
_ONESIDE_COLSTAT_FOR_EQUIJOINS = TRUE
_OPTIMIZER_COST_MODEL = CHOOSE
_GSETS_ALWAYS_USE_TEMPTABLES = FALSE
DB_FILE_MULTIBLOCK_READ_COUNT = 128
_NEW_SORT_COST_ESTIMATE = TRUE
_GS_ANTI_SEMI_JOIN_ALLOWED = TRUE
_CPU_TO_IO = 0
_PRED_MOVE_AROUND = TRUE
BASE STATISTICAL INFORMATION
Table stats Table: SOC_LIST Alias: SOC
TOTAL :: CDN: 17584 NBLKS: 653 AVG_ROW_LEN: 260
-- Index stats
INDEX NAME: I_SNAP$_SOC_LIST COL#: 1
TOTAL :: LVLS: 1 #LB: 64 #DK: 17487 LB/K: 1 DB/K: 1 CLUF: 699
INDEX NAME: SOC_LIST_1IX COL#: 3
TOTAL :: LVLS: 1 #LB: 47 #DK: 17487 LB/K: 1 DB/K: 1 CLUF: 14065
_OPTIMIZER_PERCENT_PARALLEL = 0
SINGLE TABLE ACCESS PATH
TABLE: SOC_LIST ORIG CDN: 17584 ROUNDED CDN: 17584 CMPTD CDN: 17584
Access path: tsc Resc: 18 Resp: 18
****** trying bitmap/domain indexes ******
****** finished trying bitmap/domain indexes ******
BEST_CST: 18.00 PATH: 2 Degree: 1
OPTIMIZER STATISTICS AND COMPUTATIONS
GENERAL PLANS
Join order[1]: SOC_LIST[SOC]#0
Best so far: TABLE#: 0 CST: 18 CDN: 17584 BYTES: 0
Final - All Rows Plan:
JOIN ORDER: 1
CST: 18 CDN: 17584 RSC: 18 RSP: 18 BYTES: 0
IO-RSC: 18 IO-RSP: 18 CPU-RSC: 0 CPU-RSP: 0
BINDS #1:
bind 0: dty=96 mxl=32(01) mal=00 scl=00 pre=00 oacflg=03 oacfl2=0 size=32 offset=0
bfp=800003ffefea9490 bln=32 avl=01 flg=05
value="N"
EXEC #1:c=0,e=152,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=3017698469481
WAIT #1: nam='SQL*Net message to client' ela= 4 p1=1413697536 p2=1 p3=0
FETCH #1:c=10000,e=1506,p=0,cr=0,cu=0,mis=0,r=1,dep=0,og=4,tim=3017698471536
WAIT #1: nam='SQL*Net message from client' ela= 2607 p1=1413697536 p2=1 p3=0
FETCH #1:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,tim=3017698474268
WAIT #1: nam='SQL*Net message to client' ela= 1 p1=1413697536 p2=1 p3=0
*** 2013-06-10 13:35:07.656
WAIT #1: nam='SQL*Net message from client' ela= 22922584 p1=1413697536 p2=1 p3=0
STAT #1 id=1 cnt=1 pid=0 pos=1 obj=0 op='SORT AGGREGATE (cr=0 r=0 w=0 time=93 us)'
STAT #1 id=2 cnt=0 pid=1 pos=1 obj=0 op='FILTER (cr=0 r=0 w=0 time=29 us)'
STAT #1 id=3 cnt=0 pid=2 pos=1 obj=5769120 op='TABLE ACCESS FULL SOC_LIST '
=====================
PARSE ERROR #1:len=369 dep=0 uid=33 oct=0 lid=33 tim=3017721397730 err=900
exec := 'N'
SELEC ...
WAIT #1: nam='SQL*Net break/reset to client' ela= 2 p1=1413697536 p2=1 p3=0
WAIT #1: nam='SQL*Net break/reset to client' ela= 2403 p1=1413697536 p2=0 p3=0
WAIT #1: nam='SQL*Net message to client' ela= 3 p1=1413697536 p2=1 p3=0
*** 2013-06-10 13:35:24.017
WAIT #1: nam='SQL*Net message from client' ela= 15973854 p1=1413697536 p2=1 p3=0
QUERY
SELECT count(*)
FROM SOC_LIST SOC
WHERE
( EXISTS( SELECT 1
FROM ELIGIBILITY_RELATION
WHERE SRC_CODE = 'SHDMM4215'
AND DEST_CODE = SOC.SOC
AND SRC_TYPE = 'P'
AND DEST_TYPE = 'S'))
UNION ALL
SELECT count(*)
FROM SOC_LIST SOC
WHERE ( = 'Y')
=====================
PARSING IN CURSOR #1 len=353 dep=0 uid=33 oct=3 lid=33 tim=3017737377655 hv=4202798596 ad='45639568'
SELECT count(*)
FROM SOC_LIST SOC
WHERE
( EXISTS( SELECT 1
FROM ELIGIBILITY_RELATION
WHERE SRC_CODE = 'SHDMM4215'
AND DEST_CODE = SOC.SOC
AND SRC_TYPE = 'P'
AND DEST_TYPE = 'S'))
UNION ALL
SELECT count(*)
FROM SOC_LIST SOC
WHERE ( = 'Y')
END OF STMT
PARSE #1:c=0,e=2624,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=0,tim=3017737377644
PARAMETERS USED BY THE OPTIMIZER
OPTIMIZER_FEATURES_ENABLE = 9.2.0
OPTIMIZER_MODE/GOAL = Choose
_OPTIMIZER_PERCENT_PARALLEL = 101
HASH_AREA_SIZE = 131072
HASH_JOIN_ENABLED = TRUE
HASH_MULTIBLOCK_IO_COUNT = 0
SORT_AREA_SIZE = 65536
OPTIMIZER_SEARCH_LIMIT = 5
PARTITION_VIEW_ENABLED = FALSE
_ALWAYS_STAR_TRANSFORMATION = FALSE
_B_TREE_BITMAP_PLANS = TRUE
STAR_TRANSFORMATION_ENABLED = FALSE
_COMPLEX_VIEW_MERGING = TRUE
_PUSH_JOIN_PREDICATE = TRUE
PARALLEL_BROADCAST_ENABLED = TRUE
OPTIMIZER_MAX_PERMUTATIONS = 2000
OPTIMIZER_INDEX_CACHING = 0
_SYSTEM_INDEX_CACHING = 0
OPTIMIZER_INDEX_COST_ADJ = 1
OPTIMIZER_DYNAMIC_SAMPLING = 1
_OPTIMIZER_DYN_SMP_BLKS = 32
QUERY_REWRITE_ENABLED = TRUE
QUERY_REWRITE_INTEGRITY = ENFORCED
_INDEX_JOIN_ENABLED = TRUE
_SORT_ELIMINATION_COST_RATIO = 0
_OR_EXPAND_NVL_PREDICATE = TRUE
_NEW_INITIAL_JOIN_ORDERS = TRUE
ALWAYS_ANTI_JOIN = CHOOSE
ALWAYS_SEMI_JOIN = CHOOSE
_OPTIMIZER_MODE_FORCE = TRUE
_OPTIMIZER_UNDO_CHANGES = FALSE
_UNNEST_SUBQUERY = TRUE
_PUSH_JOIN_UNION_VIEW = TRUE
_FAST_FULL_SCAN_ENABLED = TRUE
_OPTIM_ENHANCE_NNULL_DETECTION = TRUE
_ORDERED_NESTED_LOOP = TRUE
_NESTED_LOOP_FUDGE = 100
_NO_OR_EXPANSION = FALSE
_QUERY_COST_REWRITE = TRUE
QUERY_REWRITE_EXPRESSION = TRUE
_IMPROVED_ROW_LENGTH_ENABLED = TRUE
_USE_NOSEGMENT_INDEXES = FALSE
_ENABLE_TYPE_DEP_SELECTIVITY = TRUE
_IMPROVED_OUTERJOIN_CARD = TRUE
_OPTIMIZER_ADJUST_FOR_NULLS = TRUE
_OPTIMIZER_CHOOSE_PERMUTATION = 0
_USE_COLUMN_STATS_FOR_FUNCTION = TRUE
_SUBQUERY_PRUNING_ENABLED = TRUE
_SUBQUERY_PRUNING_REDUCTION_FACTOR = 50
_SUBQUERY_PRUNING_COST_FACTOR = 20
_LIKE_WITH_BIND_AS_EQUALITY = FALSE
_TABLE_SCAN_COST_PLUS_ONE = TRUE
_SORTMERGE_INEQUALITY_JOIN_OFF = FALSE
_DEFAULT_NON_EQUALITY_SEL_CHECK = TRUE
_ONESIDE_COLSTAT_FOR_EQUIJOINS = TRUE
_OPTIMIZER_COST_MODEL = CHOOSE
_GSETS_ALWAYS_USE_TEMPTABLES = FALSE
DB_FILE_MULTIBLOCK_READ_COUNT = 128
_NEW_SORT_COST_ESTIMATE = TRUE
_GS_ANTI_SEMI_JOIN_ALLOWED = TRUE
_CPU_TO_IO = 0
_PRED_MOVE_AROUND = TRUE
BASE STATISTICAL INFORMATION
Table stats Table: ELIGIBILITY_RELATION Alias: ELIGIBILITY_RELATION
(Using composite stats)
(adjusted for partition skews)
ORIG STATS:: CDN: 11982220 NBLKS: 125493 AVG_ROW_LEN: 71
PARTCNT::
PRUNED: 4 ANALYZED: 4 UNANALYZED: 0
TOTAL :: CDN: 11982220 NBLKS: 125493 AVG_ROW_LEN: 71
-- Index stats
INDEX NAME: ELIGIBILITY_RELATION_1IX COL#: 3 4 5
USING COMPOSITE STATS
TOTAL :: LVLS: 2 #LB: 38360 #DK: 4164 LB/K: 9 DB/K: 740 CLUF: 3081860
INDEX NAME: ELIGIBILITY_RELATION_PK COL#: 2 3 4 5
USING COMPOSITE STATS
TOTAL :: LVLS: 2 #LB: 50740 #DK: 11873160 LB/K: 1 DB/K: 1 CLUF: 9158280
INDEX NAME: I_SNAP$_ELIGIBILITY_RELATI COL#: 1
TOTAL :: LVLS: 2 #LB: 49600 #DK: 11953600 LB/K: 1 DB/K: 1 CLUF: 8833300
_OPTIMIZER_PERCENT_PARALLEL = 0
SINGLE TABLE ACCESS PATH
Column: SRC_CODE Col#: 2 Table: ELIGIBILITY_RELATION Alias: ELIGIBILITY_RELATION
NDV: 22087 NULLS: 0 DENS: 4.5276e-05
NO HISTOGRAM: #BKT: 1 #VAL: 2
Column: DEST_CODE Col#: 4 Table: ELIGIBILITY_RELATION Alias: ELIGIBILITY_RELATION
NDV: 11970 NULLS: 0 DENS: 8.3542e-05
NO HISTOGRAM: #BKT: 1 #VAL: 2
Column: SRC_TYPE Col#: 3 Table: ELIGIBILITY_RELATION Alias: ELIGIBILITY_RELATION
NDV: 2 NULLS: 0 DENS: 5.0000e-01
NO HISTOGRAM: #BKT: 1 #VAL: 2
Column: DEST_TYPE Col#: 5 Table: ELIGIBILITY_RELATION Alias: ELIGIBILITY_RELATION
NDV: 2 NULLS: 0 DENS: 5.0000e-01
NO HISTOGRAM: #BKT: 1 #VAL: 2
TABLE: ELIGIBILITY_RELATION ORIG CDN: 11982220 ROUNDED CDN: 1 CMPTD CDN: 0
Access path: tsc Resc: 3072 Resp: 3072
Access path: index (iff)
Index: ELIGIBILITY_RELATION_PK
TABLE: ELIGIBILITY_RELATION
RSC_CPU: 0 RSC_IO: 1243
IX_SEL: 0.0000e+00 TB_SEL: 1.0000e+00
Access path: iff Resc: 1243 Resp: 1243
Access path: index (unique)
Index: ELIGIBILITY_RELATION_PK
TABLE: ELIGIBILITY_RELATION
RSC_CPU: 0 RSC_IO: 2
IX_SEL: 8.3457e-08 TB_SEL: 8.3457e-08
Access path: index (equal)
Index: ELIGIBILITY_RELATION_1IX
TABLE: ELIGIBILITY_RELATION
RSC_CPU: 0 RSC_IO: 68
IX_SEL: 0.0000e+00 TB_SEL: 2.0886e-05
Access path: index (eq-unique)
Index: ELIGIBILITY_RELATION_PK
TABLE: ELIGIBILITY_RELATION
RSC_CPU: 0 RSC_IO: 2
IX_SEL: 0.0000e+00 TB_SEL: 0.0000e+00
****** trying bitmap/domain indexes ******
Access path: index (equal)
Index: ELIGIBILITY_RELATION_1IX
TABLE: ELIGIBILITY_RELATION
RSC_CPU: 0 RSC_IO: 3
IX_SEL: 2.0886e-05 TB_SEL: 2.0886e-05
Access path: index (index-only)
Index: ELIGIBILITY_RELATION_PK
TABLE: ELIGIBILITY_RELATION
RSC_CPU: 0 RSC_IO: 5
IX_SEL: 4.5276e-05 TB_SEL: 4.5276e-05
SORT resource Sort statistics
Sort width: 11 Area size: 628736 Max Area size: 31457280 Degree: 1
Blocks to Sort: 2 Row size: 21 Rows: 543
Initial runs: 1 Merge passes: 1 IO Cost / pass: 3
Total IO sort cost: 2
Total CPU sort cost: 0
Total Temp space used: 0
****** finished trying bitmap/domain indexes ******
One row CDN: 1
BEST_CST: 1.00 PATH: 3 Degree: 1
OPTIMIZER STATISTICS AND COMPUTATIONS
GENERAL PLANS
Join order[1]: ELIGIBILITY_RELATION[ELIGIBILITY_RELATION]#0
Best so far: TABLE#: 0 CST: 1 CDN: 1 BYTES: 24
Final - First Rows Plan:
JOIN ORDER: 1
CST: 1 CDN: 1 RSC: 1 RSP: 1 BYTES: 24
IO-RSC: 1 IO-RSP: 1 CPU-RSC: 0 CPU-RSP: 0
First Rows Plan
PARAMETERS USED BY THE OPTIMIZER
OPTIMIZER_FEATURES_ENABLE = 9.2.0
OPTIMIZER_MODE/GOAL = Choose
_OPTIMIZER_PERCENT_PARALLEL = 101
HASH_AREA_SIZE = 131072
HASH_JOIN_ENABLED = TRUE
HASH_MULTIBLOCK_IO_COUNT = 0
SORT_AREA_SIZE = 65536
OPTIMIZER_SEARCH_LIMIT = 5
PARTITION_VIEW_ENABLED = FALSE
_ALWAYS_STAR_TRANSFORMATION = FALSE
_B_TREE_BITMAP_PLANS = TRUE
STAR_TRANSFORMATION_ENABLED = FALSE
_COMPLEX_VIEW_MERGING = TRUE
_PUSH_JOIN_PREDICATE = TRUE
PARALLEL_BROADCAST_ENABLED = TRUE
OPTIMIZER_MAX_PERMUTATIONS = 2000
OPTIMIZER_INDEX_CACHING = 0
_SYSTEM_INDEX_CACHING = 0
OPTIMIZER_INDEX_COST_ADJ = 1
OPTIMIZER_DYNAMIC_SAMPLING = 1
_OPTIMIZER_DYN_SMP_BLKS = 32
QUERY_REWRITE_ENABLED = TRUE
QUERY_REWRITE_INTEGRITY = ENFORCED
_INDEX_JOIN_ENABLED = TRUE
_SORT_ELIMINATION_COST_RATIO = 0
_OR_EXPAND_NVL_PREDICATE = TRUE
_NEW_INITIAL_JOIN_ORDERS = TRUE
ALWAYS_ANTI_JOIN = CHOOSE
ALWAYS_SEMI_JOIN = CHOOSE
_OPTIMIZER_MODE_FORCE = TRUE
_OPTIMIZER_UNDO_CHANGES = FALSE
_UNNEST_SUBQUERY = TRUE
_PUSH_JOIN_UNION_VIEW = TRUE
_FAST_FULL_SCAN_ENABLED = TRUE
_OPTIM_ENHANCE_NNULL_DETECTION = TRUE
_ORDERED_NESTED_LOOP = TRUE
_NESTED_LOOP_FUDGE = 100
_NO_OR_EXPANSION = FALSE
_QUERY_COST_REWRITE = TRUE
QUERY_REWRITE_EXPRESSION = TRUE
_IMPROVED_ROW_LENGTH_ENABLED = TRUE
_USE_NOSEGMENT_INDEXES = FALSE
_ENABLE_TYPE_DEP_SELECTIVITY = TRUE
_IMPROVED_OUTERJOIN_CARD = TRUE
_OPTIMIZER_ADJUST_FOR_NULLS = TRUE
_OPTIMIZER_CHOOSE_PERMUTATION = 0
_USE_COLUMN_STATS_FOR_FUNCTION = TRUE
_SUBQUERY_PRUNING_ENABLED = TRUE
_SUBQUERY_PRUNING_REDUCTION_FACTOR = 50
_SUBQUERY_PRUNING_COST_FACTOR = 20
_LIKE_WITH_BIND_AS_EQUALITY = FALSE
_TABLE_SCAN_COST_PLUS_ONE = TRUE
_SORTMERGE_INEQUALITY_JOIN_OFF = FALSE
_DEFAULT_NON_EQUALITY_SEL_CHECK = TRUE
_ONESIDE_COLSTAT_FOR_EQUIJOINS = TRUE
_OPTIMIZER_COST_MODEL = CHOOSE
_GSETS_ALWAYS_USE_TEMPTABLES = FALSE
DB_FILE_MULTIBLOCK_READ_COUNT = 128
_NEW_SORT_COST_ESTIMATE = TRUE
_GS_ANTI_SEMI_JOIN_ALLOWED = TRUE
_CPU_TO_IO = 0
_PRED_MOVE_AROUND = TRUE
BASE STATISTICAL INFORMATION
Table stats Table: SOC_LIST Alias: SYS_ALIAS_1
TOTAL :: CDN: 17584 NBLKS: 653 AVG_ROW_LEN: 260
-- Index stats
INDEX NAME: I_SNAP$_SOC_LIST COL#: 1
TOTAL :: LVLS: 1 #LB: 64 #DK: 17487 LB/K: 1 DB/K: 1 CLUF: 699
INDEX NAME: SOC_LIST_1IX COL#: 3
TOTAL :: LVLS: 1 #LB: 47 #DK: 17487 LB/K: 1 DB/K: 1 CLUF: 14065
_OPTIMIZER_PERCENT_PARALLEL = 0
SINGLE TABLE ACCESS PATH
TABLE: SOC_LIST ORIG CDN: 17584 ROUNDED CDN: 879 CMPTD CDN: 879
Access path: tsc Resc: 18 Resp: 18
****** trying bitmap/domain indexes ******
****** finished trying bitmap/domain indexes ******
BEST_CST: 18.00 PATH: 2 Degree: 1
OPTIMIZER STATISTICS AND COMPUTATIONS
GENERAL PLANS
Join order[1]: SOC_LIST[SYS_ALIAS_1]#0
Best so far: TABLE#: 0 CST: 18 CDN: 879 BYTES: 8790
Final - All Rows Plan:
JOIN ORDER: 1
CST: 18 CDN: 879 RSC: 18 RSP: 18 BYTES: 8790
IO-RSC: 18 IO-RSP: 18 CPU-RSC: 0 CPU-RSP: 0
PARAMETERS USED BY THE OPTIMIZER
OPTIMIZER_FEATURES_ENABLE = 9.2.0
OPTIMIZER_MODE/GOAL = Choose
_OPTIMIZER_PERCENT_PARALLEL = 101
HASH_AREA_SIZE = 131072
HASH_JOIN_ENABLED = TRUE
HASH_MULTIBLOCK_IO_COUNT = 0
SORT_AREA_SIZE = 65536
OPTIMIZER_SEARCH_LIMIT = 5
PARTITION_VIEW_ENABLED = FALSE
_ALWAYS_STAR_TRANSFORMATION = FALSE
_B_TREE_BITMAP_PLANS = TRUE
STAR_TRANSFORMATION_ENABLED = FALSE
_COMPLEX_VIEW_MERGING = TRUE
_PUSH_JOIN_PREDICATE = TRUE
PARALLEL_BROADCAST_ENABLED = TRUE
OPTIMIZER_MAX_PERMUTATIONS = 2000
OPTIMIZER_INDEX_CACHING = 0
_SYSTEM_INDEX_CACHING = 0
OPTIMIZER_INDEX_COST_ADJ = 1
OPTIMIZER_DYNAMIC_SAMPLING = 1
_OPTIMIZER_DYN_SMP_BLKS = 32
QUERY_REWRITE_ENABLED = TRUE
QUERY_REWRITE_INTEGRITY = ENFORCED
_INDEX_JOIN_ENABLED = TRUE
_SORT_ELIMINATION_COST_RATIO = 0
_OR_EXPAND_NVL_PREDICATE = TRUE
_NEW_INITIAL_JOIN_ORDERS = TRUE
ALWAYS_ANTI_JOIN = CHOOSE
ALWAYS_SEMI_JOIN = CHOOSE
_OPTIMIZER_MODE_FORCE = TRUE
_OPTIMIZER_UNDO_CHANGES = FALSE
_UNNEST_SUBQUERY = TRUE
_PUSH_JOIN_UNION_VIEW = TRUE
_FAST_FULL_SCAN_ENABLED = TRUE
_OPTIM_ENHANCE_NNULL_DETECTION = TRUE
_ORDERED_NESTED_LOOP = TRUE
_NESTED_LOOP_FUDGE = 100
_NO_OR_EXPANSION = FALSE
_QUERY_COST_REWRITE = TRUE
QUERY_REWRITE_EXPRESSION = TRUE
_IMPROVED_ROW_LENGTH_ENABLED = TRUE
_USE_NOSEGMENT_INDEXES = FALSE
_ENABLE_TYPE_DEP_SELECTIVITY = TRUE
_IMPROVED_OUTERJOIN_CARD = TRUE
_OPTIMIZER_ADJUST_FOR_NULLS = TRUE
_OPTIMIZER_CHOOSE_PERMUTATION = 0
_USE_COLUMN_STATS_FOR_FUNCTION = TRUE
_SUBQUERY_PRUNING_ENABLED = TRUE
_SUBQUERY_PRUNING_REDUCTION_FACTOR = 50
_SUBQUERY_PRUNING_COST_FACTOR = 20
_LIKE_WITH_BIND_AS_EQUALITY = FALSE
_TABLE_SCAN_COST_PLUS_ONE = TRUE
_SORTMERGE_INEQUALITY_JOIN_OFF = FALSE
_DEFAULT_NON_EQUALITY_SEL_CHECK = TRUE
_ONESIDE_COLSTAT_FOR_EQUIJOINS = TRUE
_OPTIMIZER_COST_MODEL = CHOOSE
_GSETS_ALWAYS_USE_TEMPTABLES = FALSE
DB_FILE_MULTIBLOCK_READ_COUNT = 128
_NEW_SORT_COST_ESTIMATE = TRUE
_GS_ANTI_SEMI_JOIN_ALLOWED = TRUE
_CPU_TO_IO = 0
_PRED_MOVE_AROUND = TRUE
BASE STATISTICAL INFORMATION
Table stats Table: SOC_LIST Alias: SOC
TOTAL :: CDN: 17584 NBLKS: 653 AVG_ROW_LEN: 260
-- Index stats
INDEX NAME: I_SNAP$_SOC_LIST COL#: 1
TOTAL :: LVLS: 1 #LB: 64 #DK: 17487 LB/K: 1 DB/K: 1 CLUF: 699
INDEX NAME: SOC_LIST_1IX COL#: 3
TOTAL :: LVLS: 1 #LB: 47 #DK: 17487 LB/K: 1 DB/K: 1 CLUF: 14065
_OPTIMIZER_PERCENT_PARALLEL = 0
SINGLE TABLE ACCESS PATH
TABLE: SOC_LIST ORIG CDN: 17584 ROUNDED CDN: 17584 CMPTD CDN: 17584
Access path: tsc Resc: 18 Resp: 18
****** trying bitmap/domain indexes ******
****** finished trying bitmap/domain indexes ******
BEST_CST: 18.00 PATH: 2 Degree: 1
OPTIMIZER STATISTICS AND COMPUTATIONS
GENERAL PLANS
Join order[1]: SOC_LIST[SOC]#0
Best so far: TABLE#: 0 CST: 18 CDN: 17584 BYTES: 0
Final - All Rows Plan:
JOIN ORDER: 1
CST: 18 CDN: 17584 RSC: 18 RSP: 18 BYTES: 0
IO-RSC: 18 IO-RSP: 18 CPU-RSC: 0 CPU-RSP: 0
BINDS #1:
bind 0: dty=96 mxl=32(01) mal=00 scl=00 pre=00 oacflg=03 oacfl2=0 size=32 offset=0
bfp=800003ffefea9490 bln=32 avl=01 flg=05
value="N"
EXEC #1:c=0,e=159,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=3017737385286
WAIT #1: nam='SQL*Net message to client' ela= 2 p1=1413697536 p2=1 p3=0
WAIT #1: nam='db file sequential read' ela= 9958 p1=586 p2=128001 p3=1
WAIT #1: nam='db file scattered read' ela= 619 p1=586 p2=128002 p3=4
WAIT #1: nam='db file sequential read' ela= 12880 p1=2535 p2=39498 p3=1
WAIT #1: nam='db file sequential read' ela= 39878 p1=2536 p2=68185 p3=1
WAIT #1: nam='db file sequential read' ela= 10240 p1=2536 p2=68520 p3=1
WAIT #1: nam='db file sequential read' ela= 15805 p1=2535 p2=45162 p3=1
WAIT #1: nam='db file sequential read' ela= 11733 p1=2535 p2=178335 p3=1
WAIT #1: nam='db file sequential read' ela= 11863 p1=2535 p2=178798 p3=1
WAIT #1: nam='db file sequential read' ela= 4886 p1=2535 p2=33834 p3=1
WAIT #1: nam='db file sequential read' ela= 12067 p1=2536 p2=60958 p3=1
WAIT #1: nam='db file sequential read' ela= 16496 p1=2535 p2=61232 p3=1
WAIT #1: nam='db file sequential read' ela= 8970 p1=2535 p2=50826 p3=1
WAIT #1: nam='db file sequential read' ela= 10940 p1=2536 p2=260451 p3=1
WAIT #1: nam='db file sequential read' ela= 8508 p1=2536 p2=261538 p3=1
WAIT #1: nam='db file scattered read' ela= 32000 p1=1613 p2=4622 p3=35
WAIT #1: nam='db file sequential read' ela= 1762 p1=2535 p2=178799 p3=1
WAIT #1: nam='db file sequential read' ela= 341 p1=2535 p2=61233 p3=1
WAIT #1: nam='db file scattered read' ela= 50494 p1=957 p2=230324 p3=35
WAIT #1: nam='db file scattered read' ela= 36716 p1=5 p2=588169 p3=35
WAIT #1: nam='db file scattered read' ela= 45241 p1=2326 p2=227427 p3=35
WAIT #1: nam='db file sequential read' ela= 11783 p1=2535 p2=68809 p3=1
WAIT #1: nam='db file scattered read' ela= 26720 p1=471 p2=102809 p3=35
WAIT #1: nam='db file scattered read' ela= 31074 p1=1496 p2=97015 p3=35
WAIT #1: nam='db file scattered read' ela= 39750 p1=586 p2=69452 p3=35
WAIT #1: nam='db file scattered read' ela= 30923 p1=1613 p2=8636 p3=35
WAIT #1: nam='db file scattered read' ela= 46328 p1=957 p2=67050 p3=35
WAIT #1: nam='db file scattered read' ela= 34570 p1=5 p2=362823 p3=35
WAIT #1: nam='db file scattered read' ela= 43343 p1=2326 p2=240311 p3=35
WAIT #1: nam='db file scattered read' ela= 30818 p1=471 p2=76417 p3=35
WAIT #1: nam='db file scattered read' ela= 19167 p1=1496 p2=480612 p3=35
WAIT #1: nam='db file scattered read' ela= 26405 p1=586 p2=193036 p3=35
WAIT #1: nam='db file scattered read' ela= 35374 p1=1613 p2=201565 p3=35
WAIT #1: nam='db file scattered read' ela= 14275 p1=957 p2=15804 p3=7
FETCH #1:c=190000,e=926019,p=552,cr=43429,cu=0,mis=0,r=1,dep=0,og=4,tim=3017738311433
WAIT #1: nam='SQL*Net message from client' ela= 2749 p1=1413697536 p2=1 p3=0
WAIT #1: nam='SQL*Net message to client' ela= 2 p1=1413697536 p2=1 p3=0
FETCH #1:c=0,e=79,p=0,cr=0,cu=0,mis=0,r=1,dep=0,og=4,tim=3017738314443
*** 2013-06-10 13:35:44.078
WAIT #1: nam='SQL*Net message from client' ela= 18650883 p1=1413697536 p2=1 p3=0
STAT #1 id=1 cnt=2 pid=0 pos=1 obj=0 op='UNION-ALL (cr=43429 r=552 w=0 time=926047 us)'
STAT #1 id=2 cnt=1 pid=1 pos=1 obj=0 op='SORT AGGREGATE (cr=43429 r=552 w=0 time=925989 us)'
STAT #1 id=3 cnt=157 pid=2 pos=1 obj=0 op='FILTER (cr=43429 r=552 w=0 time=925909 us)'
STAT #1 id=4 cnt=14296 pid=3 pos=1 obj=5769120 op='TABLE ACCESS FULL SOC_LIST (cr=541 r=537 w=0 time=579577 us)'
STAT #1 id=5 cnt=157 pid=3 pos=2 obj=0 op='PARTITION HASH SINGLE PARTITION: KEY KEY (cr=42888 r=15 w=0 time=285564 us)'
STAT #1 id=6 cnt=157 pid=5 pos=1 obj=5401812 op='INDEX UNIQUE SCAN ELIGIBILITY_RELATION_PK PARTITION: KEY KEY (cr=42888 r=15 w=0 time=265355 us)'
STAT #1 id=7 cnt=1 pid=1 pos=2 obj=0 op='SORT AGGREGATE (cr=0 r=0 w=0 time=4 us)'
STAT #1 id=8 cnt=0 pid=7 pos=1 obj=0 op='FILTER (cr=0 r=0 w=0 time=1 us)'
STAT #1 id=9 cnt=0 pid=8 pos=1 obj=5769120 op='TABLE ACCESS FULL SOC_LIST '
QUERY
select 'close cursor' from dual
=====================
PARSING IN CURSOR #1 len=31 dep=0 uid=33 oct=3 lid=33 tim=3017756967074 hv=3487944275 ad='48de6a60'
select 'close cursor' from dual
END OF STMT
PARSE #1:c=0,e=986,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=4,tim=3017756967063
BINDS #1:
EXEC #1:c=0,e=47,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=3017756967278
WAIT #1: nam='SQL*Net message to client' ela= 3 p1=1413697536 p2=1 p3=0
FETCH #1:c=0,e=134,p=0,cr=3,cu=0,mis=0,r=1,dep=0,og=4,tim=3017756967515
WAIT #1: nam='SQL*Net message from client' ela= 2682 p1=1413697536 p2=1 p3=0
FETCH #1:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,tim=3017756970325
WAIT #1: nam='SQL*Net message to client' ela= 1 p1=1413697536 p2=1 p3=0
*** 2013-06-10 13:35:57.804
WAIT #1: nam='SQL*Net message from client' ela= 13399621 p1=1413697536 p2=1 p3=0
=====================
PARSING IN CURSOR #3 len=116 dep=1 uid=0 oct=3 lid=0 tim=3017770371839 hv=431456802 ad='39fbad80'
select o.owner#,o.name,o.namespace,o.remoteowner,o.linkname,o.subname,o.dataobj#,o.flags from obj$ o where o.obj#=:1
END OF STMT
PARSE #3:c=0,e=1249,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=0,tim=3017770371828
BINDS #3:
bind 0: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=08 oacfl2=1 size=24 offset=0
bfp=800003ffefea7a90 bln=22 avl=03 flg=05
value=172
EXEC #3:c=0,e=666,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=4,tim=3017770372725
WAIT #3: nam='db file sequential read' ela= 10318 p1=1 p2=978 p3=1
WAIT #3: nam='db file sequential read' ela= 10292 p1=1 p2=318 p3=1
FETCH #3:c=10000,e=21071,p=2,cr=3,cu=0,mis=0,r=1,dep=1,og=4,tim=3017770393830
STAT #1 id=1 cnt=1 pid=0 pos=1 obj=172 op='TABLE ACCESS FULL DUAL (cr=3 r=0 w=0 time=121 us)'
QUERY
ALTER SESSION SET EVENTS '10053 trace name context off'
=====================
PARSING IN CURSOR #1 len=55 dep=0 uid=33 oct=42 lid=33 tim=3017770394351 hv=3500836485 ad='3bed84c8'
ALTER SESSION SET EVENTS '10053 trace name context off'
END OF STMT
PARSE #1:c=0,e=227,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=4,tim=3017770394344
BINDS #1:
EXEC #1:c=0,e=177,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=3017770394624
WAIT #1: nam='SQL*Net message to client' ela= 4 p1=1413697536 p2=1 p3=0
*** 2013-06-10 13:36:13.139
WAIT #1: nam='SQL*Net message from client' ela= 14951473 p1=1413697536 p2=1 p3=0
=====================
PARSE ERROR #1:len=55 dep=0 uid=33 oct=42 lid=33 tim=3017785346905 err=911
ALTER SESSION SET EVENT=¿10046 trace name context off¿
WAIT #1: nam='SQL*Net break/reset to client' ela= 2 p1=1413697536 p2=1 p3=0
WAIT #1: nam='SQL*Net break/reset to client' ela= 2358 p1=1413697536 p2=0 p3=0
WAIT #1: nam='SQL*Net message to client' ela= 3 p1=1413697536 p2=1 p3=0
*** 2013-06-10 13:36:53.497
WAIT #1: nam='SQL*Net message from client' ela= 39408861 p1=1413697536 p2=1 p3=0
=====================
PARSE ERROR #1:len=56 dep=0 uid=33 oct=42 lid=33 tim=3017824759339 err=911
ALTER SESSION SET EVENTS ¿10046 trace name context off¿
WAIT #1: nam='SQL*Net break/reset to client' ela= 4 p1=1413697536 p2=1 p3=0
WAIT #1: nam='SQL*Net break/reset to client' ela= 2342 p1=1413697536 p2=0 p3=0
WAIT #1: nam='SQL*Net message to client' ela= 4 p1=1413697536 p2=1 p3=0
*** 2013-06-10 13:37:17.528
WAIT #1: nam='SQL*Net message from client' ela= 23463963 p1=1413697536 p2=1 p3=0
=====================
PARSE ERROR #1:len=57 dep=0 uid=33 oct=42 lid=33 tim=3017848226738 err=911
ALTER SESSION SET EVENTS '10043 trace name context off';
WAIT #1: nam='SQL*Net break/reset to client' ela= 1 p1=1413697536 p2=1 p3=0
WAIT #1: nam='SQL*Net break/reset to client' ela= 2305 p1=1413697536 p2=0 p3=0
WAIT #1: nam='SQL*Net message to client' ela= 3 p1=1413697536 p2=1 p3=0
WAIT #1: nam='SQL*Net message from client' ela= 9416071 p1=1413697536 p2=1 p3=0
=====================
PARSING IN CURSOR #1 len=55 dep=0 uid=33 oct=42 lid=33 tim=3017857646552 hv=2635134026 ad='4b92b7e8'
ALTER SESSION SET EVENTS '10043 trace name context off'
END OF STMT
PARSE #1:c=0,e=616,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=4,tim=3017857646541
BINDS #1:
EXEC #1:c=0,e=285,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=3017857647009
WAIT #1: nam='SQL*Net message to client' ela= 4 p1=1413697536 p2=1 p3=0
*** 2013-06-10 13:58:46.112
WAIT #1: nam='SQL*Net message from client' ela= 1248974802 p1=1413697536 p2=1 p3=0
XCTEND rlbk=0, rd_only=1 -
Whats wrong with the UNION ALL
Hi All
I have the following table and data
WITH sample_data AS
(SELECT '1' AS bin_data_id, '539' AS traffic_sample_id,
'1100' AS end_intv_time, '0' AS bin_1_data, '34' AS bin_2_data,
'19' AS bin_3_data
FROM DUAL
UNION ALL
SELECT '2', '539', '1200', '0', '65', '18'
FROM DUAL
UNION ALL
SELECT '3', '539', '1300', '0', '51', '17'
FROM DUAL
UNION ALL
SELECT '4', '539', '1400', '0', '65', '27'
FROM DUAL
UNION ALL
SELECT '5', '539', '1500', '0', '99', '48'
FROM DUAL
UNION ALL
SELECT '6', '539', '1600', '0', '426', '138'
FROM DUAL
UNION ALL
SELECT '7', '539', '1700', '0', '151', '62'
FROM DUAL
UNION ALL
SELECT '8', '539', '1800', '0', '80', '32'
FROM DUAL
UNION ALL
SELECT '9', '539', '1900', '0', '31', '11'
FROM DUAL
UNION ALL
SELECT '10', '539', '2000', '0', '37', '11'
FROM DUAL
UNION ALL
SELECT '11', '539', '2100', '0', '24', '9'
FROM DUAL
UNION ALL
SELECT '12', '539', '2200', '0', '16', '5'
FROM DUAL
UNION ALL
SELECT '13', '539', '2300', '0', '27', '12'
FROM DUAL
UNION ALL
SELECT '14', '539', '2400', '0', '55', '20'
FROM DUAL
UNION ALL
SELECT '15', '539', '0100', '0', '18', '9'
FROM DUAL
UNION ALL
SELECT '16', '539', '0200', '0', '134', '52'
FROM DUAL
UNION ALL
SELECT '17', '539', '0300', '0', '230', '69'
FROM DUAL
UNION ALL
SELECT '18', '539', '0400', '0', '15', '7'
FROM DUAL
UNION ALL
SELECT '19', '539', '0500', '0', '6', '5'
FROM DUAL
UNION ALL
SELECT '20', '539', '0600', '0', '47', '23'
FROM DUAL
UNION ALL
SELECT '21', '539', '0700', '0', '100', '41'
FROM DUAL
UNION ALL
SELECT '22', '539', '0800', '0', '196', '43'
FROM DUAL
UNION ALL
SELECT '23', '539', '0900', '0', '81', '20'
FROM DUAL
UNION ALL
SELECT '24', '539', '1000', '0', '58', '28'
FROM DUAL
UNION ALL
SELECT '25', '539', '1100', '0', '58', '24'
FROM DUAL
UNION ALL
SELECT '26', '539', '1200', '0', '60', '22'
FROM DUAL
UNION ALL
SELECT '27', '539', '1300', '0', '42', '18'
FROM DUAL
UNION ALL
SELECT '28', '539', '1400', '0', '53', '15'
FROM DUAL
UNION ALL
SELECT '29', '539', '1500', '0', '107', '43'
FROM DUAL
UNION ALL
SELECT '30', '539', '1600', '0', '441', '146'
FROM DUAL
UNION ALL
SELECT '31', '539', '1700', '0', '128', '34'
FROM DUAL
UNION ALL
SELECT '32', '539', '1800', '0', '67', '27'
FROM DUAL
UNION ALL
SELECT '33', '539', '1900', '0', '45', '22'
FROM DUAL
UNION ALL
SELECT '34', '539', '2000', '0', '24', '13'
FROM DUAL
UNION ALL
SELECT '35', '539', '2100', '0', '16', '11'
FROM DUAL
UNION ALL
SELECT '36', '539', '2200', '0', '28', '5'
FROM DUAL
UNION ALL
SELECT '37', '539', '2300', '0', '23', '8'
FROM DUAL
UNION ALL
SELECT '38', '539', '2400', '0', '73', '11'
FROM DUAL
UNION ALL
SELECT '39', '539', '0100', '0', '16', '3'
FROM DUAL
UNION ALL
SELECT '40', '539', '0200', '0', '243', '82'
FROM DUAL
UNION ALL
SELECT '41', '539', '0300', '0', '121', '55'
FROM DUAL
UNION ALL
SELECT '42', '539', '0400', '0', '17', '4'
FROM DUAL
UNION ALL
SELECT '43', '539', '0500', '0', '5', '5'
FROM DUAL
UNION ALL
SELECT '44', '539', '0600', '0', '41', '15'
FROM DUAL
UNION ALL
SELECT '45', '539', '0700', '0', '101', '34'
FROM DUAL
UNION ALL
SELECT '46', '539', '0800', '0', '184', '43'
FROM DUAL
UNION ALL
SELECT '47', '539', '0900', '0', '69', '15'
FROM DUAL
UNION ALL
SELECT '48', '539', '1000', '0', '51', '18'
FROM DUAL
UNION ALL
SELECT '49', '539', '1100', '0', '61', '25'
FROM DUAL)
SELECT *
FROM sample_data;Now i have 2 queries , the one below query is to just get the last bin_data_id per each traffic_sample_id
SELECT ROW_NUMBER () OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id)
AS rn_1,
COUNT (bin_data_id) OVER (PARTITION BY traffic_sample_id) AS cnt_1,TRAFFIC_SAMPLE_ID,bin_data_id,(END_INTV_TIME_1+100) AS END_INTV_TIME,BIN_1_DATA,BIN_2_DATA,BIN_3_DATA
FROM
SELECT ROW_NUMBER() OVER(ORDER BY TRAFFIC_SAMPLE_ID) AS RN,traffic_sample_id,
end_intv_time,
last_value(end_intv_time) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
AS END_INTV_TIME_1,
LAST_VALUE (bin_data_id) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
AS bin_data_id,
LAST_VALUE (bin_1_data) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
AS bin_1_data,
LAST_VALUE (bin_2_data) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
AS bin_2_data,
LAST_VALUE (bin_3_data) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
AS bin_3_data
FROM bin_data
WHERE RN=BIN_DATA_ID
and traffic_sample_id=539And now i'm doing the UNION ALL the above query with a different query as below
select rn_1,cnt_1,traffic_sample_id, bin_data_id, to_number(end_intv_time),bin_1_data,bin_2_data,bin_3_data
from
select ROW_NUMBER () OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id)
AS rn_1,
COUNT (bin_data_id) OVER (PARTITION BY traffic_sample_id) AS cnt_1,
traffic_sample_id, bin_data_id, end_intv_time, direction,bin_1_data,bin_2_data,bin_3_data
from
SELECT ROW_NUMBER () OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id)
AS rn,
COUNT (bin_data_id) OVER (PARTITION BY traffic_sample_id) AS cnt,
traffic_sample_id, bin_data_id, end_intv_time, direction,bin_1_data,bin_2_data,bin_3_data
FROM bin_data
where rn!=1
where traffic_sample_id=539
union all
SELECT ROW_NUMBER () OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id)
AS rn_1,
COUNT (bin_data_id) OVER (PARTITION BY traffic_sample_id) AS cnt_1,TRAFFIC_SAMPLE_ID,bin_data_id,(END_INTV_TIME_1+100) AS END_INTV_TIME,BIN_1_DATA,BIN_2_DATA,BIN_3_DATA
FROM
SELECT ROW_NUMBER() OVER(ORDER BY TRAFFIC_SAMPLE_ID) AS RN,traffic_sample_id,
end_intv_time,
last_value(end_intv_time) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
AS END_INTV_TIME_1,
LAST_VALUE (bin_data_id) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
AS bin_data_id,
LAST_VALUE (bin_1_data) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
AS bin_1_data,
LAST_VALUE (bin_2_data) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
AS bin_2_data,
LAST_VALUE (bin_3_data) OVER (PARTITION BY traffic_sample_id ORDER BY bin_data_id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
AS bin_3_data
FROM bin_data
WHERE RN=BIN_DATA_ID
and traffic_sample_id=539Now all works fine and appends the single record to the set of records and i get the following data set.
RN_1 CNT_1 TRAFFIC_SAMPLE_ID BIN_DATA_ID TO_NUMBER(END_INTV_TIME) BIN_1_DATA BIN_2_DATA BIN_3_DATA
1 48 539 2 1200 0 65 18
2 48 539 3 1300 0 51 17
3 48 539 4 1400 0 65 27
4 48 539 5 1500 0 99 48
5 48 539 6 1600 0 426 138
6 48 539 7 1700 0 151 62
7 48 539 8 1800 0 80 32
8 48 539 9 1900 0 31 11
9 48 539 10 2000 0 37 11
10 48 539 11 2100 0 24 9
11 48 539 12 2200 0 16 5
12 48 539 13 2300 0 27 12
13 48 539 14 2400 0 55 20
14 48 539 15 100 0 18 9
15 48 539 16 200 0 134 52
16 48 539 17 300 0 230 69
17 48 539 18 400 0 15 7
18 48 539 19 500 0 6 5
19 48 539 20 600 0 47 23
20 48 539 21 700 0 100 41
21 48 539 22 800 0 196 43
22 48 539 23 900 0 81 20
23 48 539 24 1000 0 58 28
24 48 539 25 1100 0 58 24
25 48 539 26 1200 0 60 22
26 48 539 27 1300 0 42 18
27 48 539 28 1400 0 53 15
28 48 539 29 1500 0 107 43
29 48 539 30 1600 0 441 146
30 48 539 31 1700 0 128 34
31 48 539 32 1800 0 67 27
32 48 539 33 1900 0 45 22
33 48 539 34 2000 0 24 13
34 48 539 35 2100 0 16 11
35 48 539 36 2200 0 28 5
36 48 539 37 2300 0 23 8
37 48 539 38 2400 0 73 11
38 48 539 39 100 0 16 3
39 48 539 40 200 0 243 82
40 48 539 41 300 0 121 55
41 48 539 42 400 0 17 4
42 48 539 43 500 0 5 5
43 48 539 44 600 0 41 15
44 48 539 45 700 0 101 34
45 48 539 46 800 0 184 43
46 48 539 47 900 0 69 15
47 48 539 48 1000 0 51 18
48 48 539 49 1100 0 61 25
1 1 539 49 1200 0 61 25But please help me , all the above queries are working fine when i check by traffic_sample_id, for example if i remove the WHERE CLAUSE, WHERE TRAFFIC_SAMPLE_ID=539 from both the queries in the UNION ALL to get all the TRAFFIC_SAMPLE_ID's the single records are not getting appended to the resultant data set. Please need help.
ThanksPlease consider the following sample data
WITH sample_data AS
(SELECT '1' AS bin_data_id, '539' AS traffic_sample_id,
'1100' AS end_intv_time, '0' AS bin_1_data, '34' AS bin_2_data,
'19' AS bin_3_data
FROM DUAL
UNION ALL
SELECT '2', '539', '1200', '0', '65', '18'
FROM DUAL
UNION ALL
SELECT '3', '539', '1300', '0', '51', '17'
FROM DUAL
UNION ALL
SELECT '4', '539', '1400', '0', '65', '27'
FROM DUAL
UNION ALL
SELECT '5', '539', '1500', '0', '99', '48'
FROM DUAL
UNION ALL
SELECT '6', '539', '1600', '0', '426', '138'
FROM DUAL
UNION ALL
SELECT '7', '539', '1700', '0', '151', '62'
FROM DUAL
UNION ALL
SELECT '8', '539', '1800', '0', '80', '32'
FROM DUAL
UNION ALL
SELECT '9', '539', '1900', '0', '31', '11'
FROM DUAL
UNION ALL
SELECT '10', '539', '2000', '0', '37', '11'
FROM DUAL
UNION ALL
SELECT '11', '539', '2100', '0', '24', '9'
FROM DUAL
UNION ALL
SELECT '12', '539', '2200', '0', '16', '5'
FROM DUAL
UNION ALL
SELECT '13', '539', '2300', '0', '27', '12'
FROM DUAL
UNION ALL
SELECT '14', '539', '2400', '0', '55', '20'
FROM DUAL
UNION ALL
SELECT '15', '539', '0100', '0', '18', '9'
FROM DUAL
UNION ALL
SELECT '16', '539', '0200', '0', '134', '52'
FROM DUAL
UNION ALL
SELECT '17', '539', '0300', '0', '230', '69'
FROM DUAL
UNION ALL
SELECT '18', '539', '0400', '0', '15', '7'
FROM DUAL
UNION ALL
SELECT '19', '539', '0500', '0', '6', '5'
FROM DUAL
UNION ALL
SELECT '20', '539', '0600', '0', '47', '23'
FROM DUAL
UNION ALL
SELECT '21', '539', '0700', '0', '100', '41'
FROM DUAL
UNION ALL
SELECT '22', '539', '0800', '0', '196', '43'
FROM DUAL
UNION ALL
SELECT '23', '539', '0900', '0', '81', '20'
FROM DUAL
UNION ALL
SELECT '24', '539', '1000', '0', '58', '28'
FROM DUAL
UNION ALL
SELECT '25', '539', '1100', '0', '58', '24'
FROM DUAL
UNION ALL
SELECT '26', '539', '1200', '0', '60', '22'
FROM DUAL
UNION ALL
SELECT '27', '539', '1300', '0', '42', '18'
FROM DUAL
UNION ALL
SELECT '28', '539', '1400', '0', '53', '15'
FROM DUAL
UNION ALL
SELECT '29', '539', '1500', '0', '107', '43'
FROM DUAL
UNION ALL
SELECT '30', '539', '1600', '0', '441', '146'
FROM DUAL
UNION ALL
SELECT '31', '539', '1700', '0', '128', '34'
FROM DUAL
UNION ALL
SELECT '32', '539', '1800', '0', '67', '27'
FROM DUAL
UNION ALL
SELECT '33', '539', '1900', '0', '45', '22'
FROM DUAL
UNION ALL
SELECT '34', '539', '2000', '0', '24', '13'
FROM DUAL
UNION ALL
SELECT '35', '539', '2100', '0', '16', '11'
FROM DUAL
UNION ALL
SELECT '36', '539', '2200', '0', '28', '5'
FROM DUAL
UNION ALL
SELECT '37', '539', '2300', '0', '23', '8'
FROM DUAL
UNION ALL
SELECT '38', '539', '2400', '0', '73', '11'
FROM DUAL
UNION ALL
SELECT '39', '539', '0100', '0', '16', '3'
FROM DUAL
UNION ALL
SELECT '40', '539', '0200', '0', '243', '82'
FROM DUAL
UNION ALL
SELECT '41', '539', '0300', '0', '121', '55'
FROM DUAL
UNION ALL
SELECT '42', '539', '0400', '0', '17', '4'
FROM DUAL
UNION ALL
SELECT '43', '539', '0500', '0', '5', '5'
FROM DUAL
UNION ALL
SELECT '44', '539', '0600', '0', '41', '15'
FROM DUAL
UNION ALL
SELECT '45', '539', '0700', '0', '101', '34'
FROM DUAL
UNION ALL
SELECT '46', '539', '0800', '0', '184', '43'
FROM DUAL
UNION ALL
SELECT '47', '539', '0900', '0', '69', '15'
FROM DUAL
UNION ALL
SELECT '48', '539', '1000', '0', '51', '18'
FROM DUAL
UNION ALL
SELECT '49', '539', '1100', '0', '61', '25'
FROM DUAL
UNION ALL
SELECT '11033', '613','1300','3','421','124'
FROM DUAL
UNION ALL
SELECT '11034', '613', '1400', '4', '419', '128'
FROM DUAL
UNION ALL
SELECT '11035', '613', '1500', '5', '522', '169'
FROM DUAL
UNION ALL
SELECT '11036', '613', '1600', '5', '596', '185'
FROM DUAL
UNION ALL
SELECT '11037', '613', '1700', '9', '667', '150'
FROM DUAL
UNION ALL
SELECT '11038', '613', '1800', '4', '522', '105'
FROM DUAL
UNION ALL
SELECT '11039', '613', '1900', '2', '428', '80'
FROM DUAL
UNION ALL
SELECT '11040', '613', '2000', '5', '304', '73'
FROM DUAL
UNION ALL
SELECT '11041', '613', '2100', '1', '284', '61'
FROM DUAL
UNION ALL
SELECT '11042', '613', '2200', '3', '245', '45'
FROM DUAL
UNION ALL
SELECT '11043', '613', '2300', '6', '193', '39'
FROM DUAL
UNION ALL
SELECT '11044', '613', '2400', '0', '109', '23'
FROM DUAL
UNION ALL
SELECT '11045', '613', '0100', '0', '81', '25'
FROM DUAL
UNION ALL
SELECT '11046', '613', '0200', '0', '56', '24'
FROM DUAL
UNION ALL
SELECT '11047', '613', '0300', '0', '62', '11'
FROM DUAL
UNION ALL
SELECT '11048', '613', '0400', '0', '59', '27'
FROM DUAL
UNION ALL
SELECT '11049', '613', '0500', '1', '180', '87'
FROM DUAL
UNION ALL
SELECT '11050', '613', '0600', '4', '410', '126'
FROM DUAL
UNION ALL
SELECT '11051', '613', '0700', '6', '454', '138'
FROM DUAL
UNION ALL
SELECT '11052', '613', '0800', '4', '393', '145'
FROM DUAL
UNION ALL
SELECT '11053', '613', '0800', '4', '357', '131'
FROM DUAL
UNION ALL
SELECT '11054', '613', '0900', '5', '347', '126'
FROM DUAL
UNION ALL
SELECT '11055', '613', '1000', '3', '368', '155'
FROM DUAL
UNION ALL
SELECT '11056', '613', '1100', '2', '384', '153'
FROM DUAL
UNION ALL
SELECT '11057', '613', '1200', '7', '423', '166'
FROM DUAL
UNION ALL
SELECT '11058', '613', '1300', '9', '489', '213'
FROM DUAL
UNION ALL
SELECT '11059', '613', '1400', '5', '576', '190'
FROM DUAL
UNION ALL
SELECT '11060', '613', '1500', '11', '712', '189'
FROM DUAL
UNION ALL
SELECT '11061', '613', '1600', '9', '634', '211'
FROM DUAL
UNION ALL
SELECT '11062', '613', '1700', '3', '501', '114'
FROM DUAL
UNION ALL
SELECT '11063', '613', '1800', '2', '411', '117'
FROM DUAL
UNION ALL
SELECT '11064', '613', '1900', '5', '291', '99'
FROM DUAL
UNION ALL
SELECT '11065', '613', '2000', '1', '276', '71'
FROM DUAL
UNION ALL
SELECT '11066', '613', '2100', '2', '214', '56'
FROM DUAL
UNION ALL
SELECT '11067', '613', '2200', '3', '166', '46'
FROM DUAL
UNION ALL
SELECT '11068', '613', '2300', '0', '99', '26'
FROM DUAL
UNION ALL
SELECT '11069', '613', '2400', '0', '65', '19'
FROM DUAL
UNION ALL
SELECT '11070', '613', '0100', '1', '57', '14'
FROM DUAL
UNION ALL
SELECT '11071', '613', '0200', '0', '55', '15'
FROM DUAL
UNION ALL
SELECT '11072', '613', '0300', '0', '49', '22'
FROM DUAL
UNION ALL
SELECT '11073', '613', '0400', '3', '151', '113'
FROM DUAL
UNION ALL
SELECT '11074', '613', '0500', '2', '324', '145'
FROM DUAL
UNION ALL
SELECT '11075', '613', '0600', '5', '342', '161'
FROM DUAL
UNION ALL
SELECT '11076', '613', '0700', '3', '294', '186'
FROM DUAL
UNION ALL
SELECT '11077', '613', '0800', '6', '303', '171'
FROM DUAL
UNION ALL
SELECT '11078', '613', '0900', '4', '278', '158'
FROM DUAL
UNION ALL
SELECT '11079', '613', '1000', '2', '309', '156'
FROM DUAL
UNION ALL
SELECT '11080', '613', '1100', '0', '51', '18'
FROM DUAL
UNION ALL
SELECT '11081', '613', '1200', '0', '61', '25'
FROM DUAL)
SELECT *
FROM sample_data;Here when i say the LAST(BIN_DATA_ID) i meant the last BIN_DATA_ID PER EACH TRAFFIC SAMPLE ID. What i was trying to do is in the bottom query i'm getting the LAST BIN_DATA_ID for each TRAFFIC SAMPLE ID and appending it to the top query.
Thanks -
Need a little help with my d145 allin one changed printer heads and cartiages all i get is blue and red what to do
Most likely you have some very old #78 cartridges. The cartrdiges have a shelf life and can lose colors (usualy yellow and cyan first) if stored for years. If these are original HP cartridges check the cartridge warranty date as shown here.
If the cartridges are within their two year warranty call HP at 1-800-HPINVENt or contact your dealer for replacements. If the cartridges are beyond their warranty period then purchase a fresh cartridge.
When buying new cartridges look for the "install by" date on the package. I would look for a package with at least six months remaining before the "install by" date, which would have a year of remaining warranty.
When storing unused cartridges for an extended period keep them in a cool place and keep them upright as they would hang on a store display. This will provide maximum shelf life.
Regards,
Bob Headrick, MS MVP Printing/imaging
Bob Headrick, HP Expert
I am not an employee of HP, I am a volunteer posting here on my own time.
If your problem is solved please click the "Accept as Solution" button ------------V
If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V -
Date table accross the year with a union all query
Hi
I'm trying to create a table in SQL that will show the Output Values acrross the year.
I'm basically trying to change a date range of BETWEEN '2014-01-01' AND '2014-01-30' as Jan show the Columns look like the below.
Jan
Feb
March
April
May
June
July
121
12
154
78
21
32
21
SELECT count(distinct [Form Number]) as Starts
FROM dbo.WATP
WHERE [Cohort Desc] IN ('BBC APPs', 'ETP', 'Foundation Learning', 'WBL Scheme')
AND [Episode Start] BETWEEN '2014-01-01' AND '2014-01-30'
UNION ALL
SELECT count(distinct [Form Number]) as Starts
FROM dbo.WATP
WHERE [Cohort Desc] IN ('BBC APPs', 'ETP', 'Foundation Learning', 'WBL Scheme')
AND [Episode Start] BETWEEN '2014-02-01' AND '2014-02-28'
UNION ALL
SELECT count(distinct [Form Number]) as Starts
FROM dbo.WATP
WHERE [Cohort Desc] IN ('BBC APPs', 'ETP', 'Foundation Learning', 'WBL Scheme')
AND [Episode Start] BETWEEN '2014-03-01' AND '2014-02-30'
UNION ALL
SELECT count(distinct [Form Number]) as Starts
FROM dbo.WATP
WHERE [Cohort Desc] IN ('BBC APPs', 'ETP', 'Foundation Learning', 'WBL Scheme')
AND [Episode Start] BETWEEN '2014-04-01' AND '2014-04-30'
Hope you can help,
SIIOBIIBYou can simplify that, like this:
DECLARE @WATP TABLE ([Form Number] INT IDENTITY, [Episode Start] DATE)
INSERT INTO @WATP ([Episode Start])
VALUES
('2013-01-01'),('2013-02-01'),('2013-04-01'),('2013-04-01'),('2013-05-01'),('2013-06-01'),
('2013-01-01'),('2013-02-01'),('2013-04-01'),('2013-04-01'),('2013-05-01'),('2013-06-01'),
('2014-01-01'),('2014-02-01'),('2014-03-01'),('2014-04-01'),('2014-05-01'),('2014-06-01'),
('2014-01-01'),('2014-02-01'),('2014-04-01'),('2014-04-01'),('2014-05-01'),('2014-06-01'),
('2014-01-01'),('2014-02-01'),('2014-04-01'),('2014-04-01'),('2014-05-01'),('2014-06-01'),
('2014-07-01'),('2014-08-01'),('2014-09-01'),('2014-10-01'),('2014-11-01'),('2014-12-01'),
('2014-07-01'),('2014-08-01'),('2014-09-01'),('2014-10-01'),('2014-11-01'),('2014-12-01'),
('2014-04-01'),('2014-05-01'),('2014-06-01'),('2014-04-01'),('2014-05-01'),('2014-06-01'),
('2014-04-01'),('2014-05-01'),('2014-06-01'),('2014-10-01'),('2014-11-01'),('2014-12-01'),
('2014-10-01'),('2014-11-01'),('2014-12-01')
SELECT YEAR([Episode Start]) AS year, COUNT(DISTINCT [Form Number]) AS yearTotal,
COUNT(DISTINCT CASE WHEN MONTH([Episode Start]) = 1 THEN [Form Number] END) AS Jan,
COUNT(DISTINCT CASE WHEN MONTH([Episode Start]) = 2 THEN [Form Number] END) AS Feb,
COUNT(DISTINCT CASE WHEN MONTH([Episode Start]) = 3 THEN [Form Number] END) AS Mar,
COUNT(DISTINCT CASE WHEN MONTH([Episode Start]) = 4 THEN [Form Number] END) AS Apr,
COUNT(DISTINCT CASE WHEN MONTH([Episode Start]) = 5 THEN [Form Number] END) AS May,
COUNT(DISTINCT CASE WHEN MONTH([Episode Start]) = 6 THEN [Form Number] END) AS Jun,
COUNT(DISTINCT CASE WHEN MONTH([Episode Start]) = 7 THEN [Form Number] END) AS Jul,
COUNT(DISTINCT CASE WHEN MONTH([Episode Start]) = 8 THEN [Form Number] END) AS Aug,
COUNT(DISTINCT CASE WHEN MONTH([Episode Start]) = 9 THEN [Form Number] END) AS Sep,
COUNT(DISTINCT CASE WHEN MONTH([Episode Start]) = 10 THEN [Form Number] END) AS Oct,
COUNT(DISTINCT CASE WHEN MONTH([Episode Start]) = 11 THEN [Form Number] END) AS Nov,
COUNT(DISTINCT CASE WHEN MONTH([Episode Start]) = 12 THEN [Form Number] END) AS Dec
FROM @WATP
GROUP BY YEAR([Episode Start])
Please include DDL,DML and example data when posing a question, it makes it much easier for us to help you. -
Using order by with the UNION ALL operator
Hi,
I have 2 queries and i'm using UNION ALL to join both of them.
And i want to sort the final result based on a column.
When i try to do that, its not allowing me to use the ORDER BY clause.
Any suggestions??
Example
select * from xxx where job='Manager'
order by ename
union all
select * from yyy where job='Engineer'
order by ename
Thanks in advance
--KumarSQL> select * from test_emp where deptno = 10 order by ename
2 union all
3 select * from test_emp where deptno = 20 order by ename;
union all
ERROR at line 2:
ORA-00933: SQL command not properly ended
SQL> select * from test_emp where deptno = 10 --order by ename
2 union all
3 select * from test_emp where deptno = 20 order by ename;
select * from test_emp where deptno = 20 order by ename
ERROR at line 3:
ORA-00904: "ENAME": invalid identifier
SQL> select * from test_emp where deptno = 10 --order by ename
2 union all
3 select * from test_emp where deptno = 20 --order by ename;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7698 BLAKE MANAGER 7839 01-MAY-81 3141 1 10
7782 CLARK MANAGER 7839 09-JUN-81 2700 10
7839 KING PRESIDENT 17-NOV-81 5512 10
7934 MILLER CLERK 7782 23-JAN-82 1433 10
7369 SMITH CLERK 7902 10-OCT-06 882 123 20
7566 JONES MANAGER 7839 10-OCT-06 3279 123 20
7788 SCOTT ANALYST 7566 11-OCT-06 3307 123 20
7876 ADAMS CLERK 7788 10-OCT-06 1212 123 20
7902 FORD ANALYST 7566 10-OCT-06 3307 123 20
9 rows selected.
SQL> select * from
2 (select * from test_emp where deptno = 10 union all
3 select * from test_emp where deptno = 20)
4 order by ename;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7876 ADAMS CLERK 7788 10-OCT-06 1212 123 20
7698 BLAKE MANAGER 7839 01-MAY-81 3141 1 10
7782 CLARK MANAGER 7839 09-JUN-81 2700 10
7902 FORD ANALYST 7566 10-OCT-06 3307 123 20
7566 JONES MANAGER 7839 10-OCT-06 3279 123 20
7839 KING PRESIDENT 17-NOV-81 5512 10
7934 MILLER CLERK 7782 23-JAN-82 1433 10
7788 SCOTT ANALYST 7566 11-OCT-06 3307 123 20
7369 SMITH CLERK 7902 10-OCT-06 882 123 20
9 rows selected.
SQL> -
Please help with any or all: FTP, HTML, .Mac unpub'ing
Dear Helpers,
I too, build my site with iWeb and published to Mac, only to discover that the site was not "built in HTML" so I could not get help with SEO later on. (Then I read a Varrkgirl entry that seems to say that indeed once published, the site does contain HTML code. I am a novice and I don't "see" the code on my published pages..what do I know?) I was told "rebuild your site in HTML", transfer to new host via FTP.
Sooo, I had someone look at the site, put in the HTML code, and then he gave it to me on a disk which I can load onto my computer. I have been told to publish to a new host, via FTP Cyberduck (I see there's a tutorial for that here too) and unpublish my .Mac one. Don't know what in what order to do this.
I need help prioritzing tasks please. and to know if there is an easier way perhaps or if this should/could be avoided. Ultimately, I want a site in HTML code on my published site so that I can get some SEO help with later on. When I published to a folder, I do see code but if I simply upload this to another host would that take care of the whole issue? (i.e. dump the disk my person worked on, etc.)
re: HTML (could I have done this myself with Text Edit? If so, then is there a way to do so at this point, since my site is published to .Mac presently?) If I want to build/change current pages in the future using iWeb I want to know how, and then how to move changes to a new host.
re: Unpublishing my site at .Mac (when? it would seem like before I use FTP but if for some reason FTP'ing does not work then I am without my site, right?)
re:my laundry (really out of hand since beginnng this process of totally ignoring one's life for the web..)
Sincere thanksHTML:
iWeb pages certainly ARE html code. You just don't edit the code in iWeb. If you need to add some code afterwards, try this:
http://www.varkgirl.com/Varkgirl/Basic%20HTML%20Additions.html
SEO:
http://www.varkgirl.com/Varkgirl/Google%20and%20iWeb.html
Basic iWeb FAQ:
http://www.varkgirl.com/iWebFAQ -
Help with a large compound statement - sort of
Hi all. Hopefully you can help me. I'm trying to develop a little application in htmldb/ application express and having troubles with one little box.
I have a page item that will have a value between 2003 and 2036. I will be referencing the value of this item from the session state, no worries. The next item in the page will be based on this value and the session state will trigger one of 33 possible queries for this 2nd item. I know that sounds complex but it has to be that way unfortunately, the queries that will be triggered by this :ITEM_1 value are very different so there is no pretty way of doing that bit.
So say the value of Item1 = :ITEM1(session state value)
I need to do something like
IF
:ITEM1 = '2004'
THEN
select column.name from table.name where condition
ELSEIF
:ITEM = '2005'
THEN
select column.name from table.name where condition
ELSEIF
:ITEM = '2006'
THEN
''you get the idea
I need to repeat this the 33 times for 33 different SELECT statements. I've tried to figure out the best way to approach it, whether that is an IF statement, a WHERE statement or similar but am really struggling. I have no training in any of this and am not an IT person or programmer, just a cartograpaher who got an extra job to do :)
Which is the best approach for me here? And what is the syntax I need to use? I tried the IF statements but must be making some really fundamental mistakes in syntax. Forums are the only support available to me. Please help.....
Cheers and thanks for your time. Michael:ITEM1 = '2004' ... :ITEM = '2005'
select column.name from table.name where conditionAssuming ITEM1 and ITEM is just a typo and if the select statement is the same, you can use
if :ITEM BETWEEN TO_NUMBER('2004') and TO_NUMBER('2005') THEN
select column.name from table.name where condition
end if;
HTH
Ghulam -
Help with parsing an UPDATE statement
I am stuck and need help! The teacher has not gone over parsing with us
and it is not on his scheduled topics list. But, I am a person that likes to
scope out and learn new things. For our final project, we have to allow
updates, delete and inserts into the 5 main tables of the Premiere Products
database. I have done everything except for the updates. I can achieve
the updates of the entities by pretty much hardcoding them and that is
okay by the teacher, but I want to learn about parsing because Barbara
from this site mentioned this to me.
This is what I was able to write and I am getting errors:
CREATE OR REPLACE PROCEDURE updatecust_proc (
v_cust_num IN customera.cust_num%TYPE,
v_attributetoupdate VARCHAR2 ,
v_updatedvalue VARCHAR2 )
AS
e_invalidcustnum_error EXCEPTION;
BEGIN
v_isvalidcustnum := iscust(v_cust_num);
IF (v_isvalidcustnum = FALSE) THEN
RAISE e_invalidcustnum_error;
END IF;
PARSE(
'UPDATE customer
SET' | | v_attributetoupdate | | '=' | | v_updatedvalue | |
'WHERE cust_num =' | | v_cust_num
END;
EXCEPTION
WHEN e_invalidcustnum_error THEN
DBMS_OUTPUT.PUT_LINE('Cannot be updated. Invalid customer number');
END;
Any help would be useful. I went to the Oracle help site but their examples are a little too complicated for me to understand, plus, I am not using any C code.
Thanks in advance!
BobNow we are getting somewhere. Identifier 'PARSE' must be declared.
I again used the 'Search' link just above the forum posts and entered 'dbms_sql.parse' and got a short list of hits (as I suggested in my previous reply).
There is one with Barbara's name on it. It shows exactly how to do what you are trying to do. In particular note her code:
DBMS_SQL.PARSE
(cursor_name,
'UPDATE client SET '
| | v_column
| | ' = ' | | '''' | | v_new_data | | ''''
| | ' WHERE account_id = '
| | v_account_id,
DBMS_SQL.NATIVE);
Compare her PARSE statement to yours and you will see some major differences. The PARSE procedure is defined in the DBMS_SQL package and must be reference by DBMS_SQL.PARSE as Barbara shows.
In addition to dynamic SQL using the DBMS_SQL package Oracle 8i also supports the EXEC IMMEDIATE statement.
All of Oracle's documentation is available online via the 'Documentation' link on the left side of the OTN home page.
The 'Supplied PL/SQL Packages Reference' has a chapter for each package (including DBMS_SQL) and describes the procedures/functions in the package and how to use them.
The 'Application Developers Guide - Fundamentals' has chapters on 'processing SQL statements' and 'dynamic SQL' that go into some detail on performing dynamic sql.
Yes, Barbara's code uses a CURSOR. The DBMS_SQl package requires it and so does your code. Almost all SQL uses a CURSOR either implicitly or explicitly.
My comments are not, and were not, directed at you personally so I hope you don't take them that way.
Your latest reply has a lot of useful information in it.
1. 19/1 PLS-00201: identifier 'PARSE' must be declared. This is the explicit error message we need to help someone. We don't have to guess which error they are talking about. We can look it up in the MESSAGES manual if necessary. When someone says 'I get an error', or 'I get a PARSE error' we can only guess which error they are talking about.
In your reply you state that you looked at Barbara's code, she uses a cursor and you don't need a cursor. That is very useful information to someone trying to help you because it tells us two things: you are trying to find the answer for yourself (a lot of people just want someone to write the code for them) and it shows that you haven't made the connection between Barbara's example (which shows EXACTLY what you need to do) and your own code.
This is a public forum and I have found it useful to keep repeating certain suggestions.
For whatever reason many people still do not seem to realize that:
1. ALL of Oracle's documentation is available on-line via the 'Documentation' link on the left side of the OTN main page.
2. You can purchase (for about $50) a CD-ROM that has all of the Oracle documentation on it in both PDF and HTML format.
3. The 'search' link just above each discussion forum allows one to search any or all forums for topics, users, etc.
The above resources should be used by everyone.
Good luck!
null -
Help with a update,select statement
Hi all please can you help me with a update statement i am struggling with.
I have 2 tables
Holiday and data
In the Holiday table i have columns for
Machine_ID NUMBER,
date_from DATE,
date_to DATE,
ID NUMBER
Machine column represents a type of machine, the two dates represent the start and end date of a holiday and ID represents the ID of the machines that the holiday effects (as you can have many machines that are the same, so the ID unique field to seperate them.
i.e.
996 25-DEC-08 00:00:00 27-DEC-08 00:00:00 91
996 25-DEC-08 00:00:00 27-DEC-08 00:00:00 92
100 28-DEC-08 00:00:00 29-DEC-08 00:00:00 1
100 28-DEC-08 00:00:00 29-DEC-08 00:00:00 2
In the data table i have the following columns:
DATE DATE
Machine NUMBER
SHIFT1S DATE
SHIFT1F DATE
SHIFT2S DATE
SHIFT2F DATE
CALS DATE
CALF DATE
CAP NUMBER
CALCAP NUMBER
total_hrs_up NUMBER
In here i have data for every date in the calendar. The machines are cross references with the machine in holidays table.
I run two shifts so have shift 1 start, finish. shift 2 start, finish. These are dates with times, so shift1s could be 01-01-08 09:00:00 shift1f could be 01-01-08 17:00:00.
shift2S could be 01-01-08 21:00:00 shift2f could be 01-01-08 23:59:00.
so that machine would be up between them hours of the day.
Other columns include
CALS, ,CALF = calendar start, finish, - This needs to be populated from the holiday table. currently null. So if the date is the 26 DEC and the machine is the same as what is in the holiday table then these two columns should be populated with them data
CAP is the total number of these machines i have available.
CALCAP is the no of machines the holiday affects -currently null
total_hrs_up is the number of hours this machine is up and running -currently null.
So what i need to do is populate the cals, calf calcap, total_hrs_up columns.
total_hrs_up is the important one, this needs to work out based on the two shift patterns the number of hours that the machine is available and then take off the holiday hours to give a final value.
so current data example in data is
date machine shifts shiftf shift2s shift2f cals, calf, cap, calcap, total_hrs
16-JUL-08 100 09:00:00 17:00:00 12:00:00 00:00:00 '','','',1 ,''
16-JUL-08 105 09:00:00 17:00:00 12:00:00 00:00:00 '','','',1 ,''
16-JUL-08 107 09:00:00 17:00:00 12:00:00 00:00:00 '','','',1 ,''
id like to see based on the holiday table if there is a holiday then this data is updated as such and a total_hrs machine is available populated on that date.
Any help is very much appreciated!
ThanksHi,
The following query does what you requested.
It makes the following assumptions:
(a) in data, shift1start <= shift1finish
(b) in holiday, hol_start <= hol_finish
(b) in data, the combination (machine, shift1start) is unique
(c) in holiday, hol_start <= hol_finish
(d) in holiday, rows for the same machine and id never have overlapping dates (including times). For example:
INSERT INTO holiday (machine, id, date_from, date_to)
VALUES (200, 1, '26-DEC-08 07:00:00', '26-DEC-08 09:59:59');
INSERT INTO holiday (machine, id, date_from, date_to)
VALUES (200, 1, '26-DEC-08 09:00:00', '26-DEC-08 09:59:59');will cause a probem. Multiple rows for the same machine and day are okay, however, if the times do not overlap, like the following:
INSERT INTO holiday (machine, id, date_from, date_to)
VALUES (200, 1, '26-DEC-08 07:00:00', '26-DEC-08 08:59:59');
INSERT INTO holiday (machine, id, date_from, date_to)
VALUES (200, 1, '26-DEC-08 09:00:00', '26-DEC-08 09:59:59');Here's the UPDATE statement:
UPDATE data m
SET ( hol_start
, hol_finish
, no_of_available_minutes
) =
( SELECT MIN (date_from)
, MAX (date_to)
, ( MAX (shift1finish - shift1start) -- Total from data
- ( NVL ( SUM ( LEAST (date_to, shift1finish)
- GREATEST (date_from, shift1start)
, 0
) -- Total from holiday
/ MAX (total_no_of_machines) -- Average
) * 24 * 60 -- Convert days to minutes
FROM data d
LEFT OUTER JOIN holiday h ON h.machine = d.machine
AND NOT ( date_from > shift1finish
OR date_to < shift1start
WHERE d.machine = m.machine
AND d.shift1start = m.shift1start
);The subquery has to use its own copy of data (that is, in needs d, not m), since the subquery has to return a non-NULL number of minutes when no rows in h match m. -
Help with TYPE and LIKE statements
HI guys,
I know this is really novice stuff, but I am a little confused.
Can anyone please explain the exact difference between TYPE and like with the help of a program, to understand it.
What situation would demand the use of each of the LIKE statement, since I can do all these things using the TYPE ?Hi Akhil,
I summarized the info in SDN posts and SAP Help, to make it easier for you to understand. I also included some code snippets. Hope these prove to be helpful to you.
The following is from SAP Help:
The Additions TYPE and LIKE
The additions TYPE type and LIKE dobj are used in various ABAP statements. The additions can have various meanings, depending on the syntax and context.
· Definition of local types in a program
· Declaration of data objects
· Dynamic creation of data objects
· Specification of the type of formal parameters in subroutines
· Specification of the type of formal parameters in methods
· Specification of the type of field symbols
A known data type can be any of the following:
· A predefined ABAP type to which you refer using the TYPE addition
· An existing local data type in the program to which you refer using the TYPE addition
· The data type of a local data object in the program to which you refer using the LIKE addition
· A data type in the ABAP Dictionary to which you refer using the TYPE addition. To ensure compatibility with earlier releases, it is still possible to use the LIKE addition to refer to database tables and flat structures in the ABAP Dictionary. However, you should use the TYPE addition in new programs.
The LIKE addition takes its technical attributes from a visible data object. As a rule, you can use LIKE to refer to any object that has been declared using DATA or a similar statement, and is visible in the current context. The data object only has to have been declared. It is irrelevant whether the data object already exists in memory when you make the LIKE reference.
· In principle, the local data objects in the same program are visible. As with local data types, there is a difference between local data objects in procedures and global data objects. Data objects defined in a procedure obscure other objects with the same name that are declared in the global declarations of the program.
· You can also refer to the data objects of other visible ABAP programs. These might be, for example, the visible attributes of global classes in class pools. If a global class cl_lobal has a public instance attribute or static attribute attr, you can refer to it as follows in any ABAP program:
DATA dref TYPE REF TO cl_global.
DATA: f1 LIKE cl_global=>attr,
f2 LIKE dref->attr.
You can access the technical properties of an instance attribute using the class name and a reference variable without first having to create an object. The properties of the attributes of a class are not instance-specific and belong to the static properties of the class.
Example
TYPES: BEGIN OF struct,
number_1 TYPE i,
number_2 TYPE p DECIMALS 2,
END OF struct.
DATA: wa_struct TYPE struct,
number LIKE wa_struct-number_2,
date LIKE sy-datum,
time TYPE t,
text TYPE string,
company TYPE s_carr_id.
This example declares variables with reference to the internal type STRUCT in the program, a component of an existing data object wa_struct, the predefined data object SY-DATUM, the predefined ABAP type t and STRING, and the data element S_CARR_ID from the ABAP Dictionary.
The following info is from various posts:
--> Type: It is used when userdefined object link with SAP system data type.
Local types mask global types that have the same names. When typing the interface parameters or field symbols, a reference is also possible to generic types ANY, ANY TABLE,INDEX TABLE, TABLE or STANDARD TABLE, SORTED TABLE and HASHED TABLE.
--> Like: It is when data object link with the other data object.
--> TYPE, you assign datatype directly to the data object while declaring.
--> LIKE,you assign the datatype of another object to the declaring data object. The datatype is referenced indirectly.
you can refer to all visible data objects at the ABAP program's positon in question. Only the declaration of the data object must be known. In this case it is totally irrelevant whether the data object already exists physically in
memory during the LIKE reference. Local data objects mask global data objects that have the same name.
--> Type is a keyword used to refer to a data type whereas Like is a keyword used to copy the existing properties of already existing data object.
Types: var1(20) type c.
data: var2 type var1. ( type is used bcoz var1 is defined with TYPES and it
does not occupy any memory spce.
data: var3 like var2. ( like is used here bcoz var2 is defined with DATA
so it does occupy space in memory ).
data: material like mara-matnr. ( like is used here bcoz mara-matnr is stored in memory)
--> Type refers the existing data type
--> Like refers the existing data object
Please Reward Points if any of the above points are helpful to you.
Regards,
Kalyan Chakravarthy -
Help with filling a if statement
hello everyone i hope someone can help me
if you look at my code below the arraylist contains the number 8. but i want to know how i can use that number 8 inside the if statement (if (i%10 == 1)) where the number 1 is, so that number 1 will change to the number 8.
could someone please help me.
thanks for your time
loftty
hash.put(new Integer(8), st1);
if(hash.containsValue(st1)) {
Enumeration e = hash.keys();
while (e.hasMoreElements()) {
Object it = e.nextElemenet();
Object it1 = hash.get(it);
if (it1.equals(st1){
arraylist.add(it);
Enumeration e = v.elements();
Object o;
for(int i = 1;e.hasMoreElements();i++) {
o = e.nextElement();
if (i%10 == 1){
System.out.println(o);By ArrayList do you mean the hashtable in your code?
Because a hastable is not the same as an arraylist....
For one thing your hashtable is wrong...
The first parameter you pass in a put method is a key, the second is an object...
When you want to get the object from the hashtable you pass it the key.... like so:
hash.put("Str1", new Double(8));
Double l_Double = (Double)hash.get("Str1");With an ArrayList you don't use keys by the way...
Vermelh0 -
Help with a "AT NEW" statement
I am debugging at some code and I am trying to understand the following statement
<i>LOOP AT it_data_item_final INTO st_data_item_final.
MOVE st_data_item_final-waers TO w_waers.
<b>AT NEW xblnr."xblnr." budat xblnr waers.</b>
MOVE-CORRESPONDING st_data_item_final TO s_bbkpf.
s_bbkpf-waers = w_waers.
t_upload_file = s_bbkpf.
APPEND t_upload_file.
ENDAT.</i>
I know this code is to only execute when there is a change in the fields but I am not sure how to read the statement. I am assuming there if there is a change in the budat xblnr waers fields of the st_data_item_final table, this code will execute. I am not sure what the xblnr."xblnr." code is trying to do.
thanks for the help in advancehi,
LOOP AT it_data_item_final INTO st_data_item_final.
v_tabix = sy-tabix.
MOVE st_data_item_final-waers TO w_waers.
AT NEW xblnr.
read table it_data_item_final into st_data_item_final index v_tabix.
MOVE-CORRESPONDING st_data_item_final TO s_bbkpf.
s_bbkpf-waers = w_waers.
t_upload_file = s_bbkpf.
APPEND t_upload_file.
ENDAT.
endloop.
After the at new XBLNR, the structure gets empty and only contains the fields that are left to the field (in the internal table) at which we are performing at end/at new.
XBLNR F1 F2
1 2 4 <-
1 3 6
2 2 4 <-
3 3 3 <-
then it gets triggered at these three positions. To fill the structure again with the values we need to read the table again with sy-tabix.
Hope this helps.
Regards,
Richa
Maybe you are looking for
-
What steps do I take to maybe repair my HD hard drive! A warning pops up when I am trying to install OS X on my Macintosh HD Disk?? S.M.A.R.T. errors, backup hard drive and replace, cannot repair!!!! Please Help!!! mfreeman
-
developing a ui in flash for photo gallery which I am loading into dreamweaver. using as3 in flash to load external photo files so not all having to download on opening. have had no problem in dreamweaver with swfs with embedded jpgs. ui comes up in
-
Different Types of Aggregates For a Keyfigure
Hi, When we go to aggregaion tab of a keyfigure.(i.e in tcode:rsd1). There are i) Aggregation ii) Exception Aggregat iii) Agg.referen.char Can You please tell me what each option is meant for.? Where and when we should use them ? What are its purpose
-
PLS-00905: object XDB.DBMS_XDBUTIL_INT is invalid
While exporting a user using exp i am receiving this error . exporting triggers EXP-00056: ORACLE error 6550 encountered ORA-06550: line 1, column 30: PLS-00905: object XDB.DBMS_XDBUTIL_INT is invalid ORA-06550: line 1, column 14: PL/SQL: Statement i
-
SQL Loader fails loading XML data enclosed by tag not found
The problem I'm having is my XML tree doesn't contain all possible elements. In this example the second entry doesn't contain <age> - only the first entry will be added to the database Any idea of how I could solve this? The fields are saved as varch