Please help!!! Tuning the query
Hi,
I am using Oracle BDBXML 2.4.16. In the following, policyContainer.dbxml has around 1000 documents and productsContainer.dbxml around 10 documents. The following query is taking around 6 - 8 seconds to fetch the data of around 300 records. I have created node-element-equality-string indexes on PolicyEvent, PolicyStatus, Archived, IsLatest, ProductID and CompanyID.
I am novice on Query tuning. Can someone please help me to tune the following query. I have posted the query plan as well.
Thanks in Advance!!
Balakrishna.
Query:
query ' for $policy in collection("policyContainer.dbxml")/Policy[PolicyState/PolicyEvent=("APPLICATION","QUOTE","BINDER","POLICY","ENDORSEMENT QUOTE")]
[PolicyHeader/ProductID = (for $product in collection("productsContainer.dbxml")/Product/ProductsHeader[CompanyID=(1)] return $product/ProductID)]
[PolicyState/PolicyStatus !=("RATE","DECLINED ENDORSEMENT QUOTE","DECLINED NON-PRE ENDORSEMENT QUOTE","DECLINED EXTENSION QUOTE")]
[PolicyState/Archived !="true"]
[(PolicyState/IsLatest !="false"
and (PolicyState/PolicyStatus != ("ENDORSEMENT QUOTE","NON-PRE ENDORSEMENT QUOTE","EXTENSION QUOTE")))
or (PolicyState/IsLatest !="true"
and (PolicyState/PolicyStatus =("ENDORSEMENT QUOTE","NON-PRE ENDORSEMENT QUOTE","EXTENSION QUOTE")))]
let $state := $policy/PolicyState
let $header := $policy/PolicyHeader
let $datatable := $policy/DataTable/DataTableInfo
return
<policyDetail>
{$policy/SubmissionNumber},
{$policy/DocumentNumber},
{$policy/QuoteVersionNumber},
{$state/*,$header/*,$datatable/*}
</policyDetail>'
Query plan:
<XQuery>
<Return>
<LetTuple uri="" name="datatable">
<LetTuple uri="" name="header">
<LetTuple uri="" name="state">
<ForTuple uri="" name="policy">
<ContextTuple/>
<QueryPlanToAST>
<BufferQP id="2">
<NegativeNodePredicateFilterQP uri="" name="#tmp67">
<NegativeNodePredicateFilterQP uri="" name="#tmp73">
<NodePredicateFilterQP uri="" name="#tmp404">
<ParentOfChildJoinQP>
<StepQP axis="parent-of-child" name="PolicyState" nodeType="element">
<UnionQP>
<ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="PolicyEvent" value="ENDORSEMENT QUOTE"/>
<ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="PolicyEvent" value="APPLICATION"/>
<ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="PolicyEvent" value="POLICY"/>
<ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="PolicyEvent" value="BINDER"/>
<ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="PolicyEvent" value="QUOTE"/>
</UnionQP>
</StepQP>
<StepQP axis="child" name="Policy" nodeType="element">
<SequentialScanQP container="policyContainer.dbxml" nodeType="document"/>
</StepQP>
</ParentOfChildJoinQP>
<ValueFilterQP comparison="eq" general="true">
<StepQP axis="child" name="ProductID" nodeType="element">
<StepQP axis="child" name="PolicyHeader" nodeType="element">
<VariableQP name="#tmp404"/>
</StepQP>
</StepQP>
<Atomize>
<Return>
<ForTuple uri="" name="product">
<ContextTuple/>
<QueryPlanToAST>
<ParentOfChildJoinQP>
<ValueFilterQP comparison="eq" general="true">
<PresenceQP container="productsContainer.dbxml" index="node-element-equality-string" operation="prefix" child="CompanyID"/>
<Sequence>
<NumericTypeConstructor value="1.0E0" typeuri="http://www.w3.org/2001/XMLSchema" typename="integer"/>
</Sequence>
</ValueFilterQP>
<StepQP axis="child" name="ProductsHeader" nodeType="element">
<StepQP axis="child" name="Product" nodeType="element">
<SequentialScanQP container="productsContainer.dbxml" nodeType="document"/>
</StepQP>
</StepQP>
</ParentOfChildJoinQP>
</QueryPlanToAST>
</ForTuple>
<QueryPlanToAST>
<StepQP axis="child" name="ProductID" nodeType="element">
<VariableQP name="product"/>
</StepQP>
</QueryPlanToAST>
</Return>
</Atomize>
</ValueFilterQP>
</NodePredicateFilterQP>
<ValueFilterQP comparison="ne" general="true">
<ValueFilterQP comparison="ne" general="true">
<ValueFilterQP comparison="ne" general="true">
<ValueFilterQP comparison="ne" general="true">
<StepQP axis="child" name="PolicyStatus" nodeType="element">
<StepQP axis="child" name="PolicyState" nodeType="element">
<VariableQP name="#tmp73"/>
</StepQP>
</StepQP>
<Sequence>
<AnyAtomicTypeConstructor value="RATE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
<AnyAtomicTypeConstructor value="DECLINED ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
<AnyAtomicTypeConstructor value="DECLINED NON-PRE ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
<AnyAtomicTypeConstructor value="DECLINED EXTENSION QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
</Sequence>
</ValueFilterQP>
<Sequence>
<AnyAtomicTypeConstructor value="RATE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
<AnyAtomicTypeConstructor value="DECLINED ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
<AnyAtomicTypeConstructor value="DECLINED NON-PRE ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
<AnyAtomicTypeConstructor value="DECLINED EXTENSION QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
</Sequence>
</ValueFilterQP>
<Sequence>
<AnyAtomicTypeConstructor value="RATE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
<AnyAtomicTypeConstructor value="DECLINED ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
<AnyAtomicTypeConstructor value="DECLINED NON-PRE ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
<AnyAtomicTypeConstructor value="DECLINED EXTENSION QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
</Sequence>
</ValueFilterQP>
<Sequence>
<AnyAtomicTypeConstructor value="RATE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
<AnyAtomicTypeConstructor value="DECLINED ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
<AnyAtomicTypeConstructor value="DECLINED NON-PRE ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
<AnyAtomicTypeConstructor value="DECLINED EXTENSION QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
</Sequence>
</ValueFilterQP>
</NegativeNodePredicateFilterQP>
<ChildJoinQP>
<StepQP axis="child" name="PolicyState" nodeType="element">
<VariableQP name="#tmp67"/>
</StepQP>
<ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="Archived" value="true"/>
</ChildJoinQP>
</NegativeNodePredicateFilterQP>
<UnionQP>
<NegativeNodePredicateFilterQP uri="" name="#tmp18">
<NegativeNodePredicateFilterQP uri="" name="#tmp46">
<BufferReferenceQP id="2"/>
<ChildJoinQP>
<StepQP axis="child" name="PolicyState" nodeType="element">
<VariableQP name="#tmp46"/>
</StepQP>
<ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="IsLatest" value="false"/>
</ChildJoinQP>
</NegativeNodePredicateFilterQP>
<ValueFilterQP comparison="ne" general="true">
<ValueFilterQP comparison="ne" general="true">
<ValueFilterQP comparison="ne" general="true">
<StepQP axis="child" name="PolicyStatus" nodeType="element">
<StepQP axis="child" name="PolicyState" nodeType="element">
<VariableQP name="#tmp18"/>
</StepQP>
</StepQP>
<Sequence>
<AnyAtomicTypeConstructor value="ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
<AnyAtomicTypeConstructor value="NON-PRE ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
<AnyAtomicTypeConstructor value="EXTENSION QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
</Sequence>
</ValueFilterQP>
<Sequence>
<AnyAtomicTypeConstructor value="ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
<AnyAtomicTypeConstructor value="NON-PRE ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
<AnyAtomicTypeConstructor value="EXTENSION QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
</Sequence>
</ValueFilterQP>
<Sequence>
<AnyAtomicTypeConstructor value="ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
<AnyAtomicTypeConstructor value="NON-PRE ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
<AnyAtomicTypeConstructor value="EXTENSION QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
</Sequence>
</ValueFilterQP>
</NegativeNodePredicateFilterQP>
<NegativeNodePredicateFilterQP uri="" name="#tmp56">
<ParentOfChildJoinQP>
<StepQP axis="parent-of-child" name="PolicyState" nodeType="element">
<UnionQP>
<ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="PolicyStatus" value="NON-PRE ENDORSEMENT QUOTE"/>
<ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="PolicyStatus" value="EXTENSION QUOTE"/>
<ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="PolicyStatus" value="ENDORSEMENT QUOTE"/>
</UnionQP>
</StepQP>
<BufferReferenceQP id="2"/>
</ParentOfChildJoinQP>
<ChildJoinQP>
<StepQP axis="child" name="PolicyState" nodeType="element">
<VariableQP name="#tmp56"/>
</StepQP>
<ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="IsLatest" value="true"/>
</ChildJoinQP>
</NegativeNodePredicateFilterQP>
</UnionQP>
</BufferQP>
</QueryPlanToAST>
</ForTuple>
<QueryPlanToAST>
<StepQP axis="child" name="PolicyState" nodeType="element">
<VariableQP name="policy"/>
</StepQP>
</QueryPlanToAST>
</LetTuple>
<QueryPlanToAST>
<StepQP axis="child" name="PolicyHeader" nodeType="element">
<VariableQP name="policy"/>
</StepQP>
</QueryPlanToAST>
</LetTuple>
<QueryPlanToAST>
<StepQP axis="child" name="DataTableInfo" nodeType="element">
<StepQP axis="child" name="DataTable" nodeType="element">
<VariableQP name="policy"/>
</StepQP>
</StepQP>
</QueryPlanToAST>
</LetTuple>
<DOMConstructor type="element">
<Name>
<Sequence>
<ATQNameConstructor uri="" prefix="" localname="policyDetail" typeuri="http://www.w3.org/2001/XMLSchema" typename="QName"/>
</Sequence>
</Name>
<Children>
<ContentSequence>
<QueryPlanToAST>
<StepQP axis="child" name="SubmissionNumber" nodeType="element">
<VariableQP name="policy"/>
</StepQP>
</QueryPlanToAST>
</ContentSequence>
<ContentSequence>
<Sequence>
<AnyAtomicTypeConstructor value="," typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
</Sequence>
</ContentSequence>
<ContentSequence>
<QueryPlanToAST>
<StepQP axis="child" name="DocumentNumber" nodeType="element">
<VariableQP name="policy"/>
</StepQP>
</QueryPlanToAST>
</ContentSequence>
<ContentSequence>
<Sequence>
<AnyAtomicTypeConstructor value="," typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
</Sequence>
</ContentSequence>
<ContentSequence>
<QueryPlanToAST>
<StepQP axis="child" name="QuoteVersionNumber" nodeType="element">
<VariableQP name="policy"/>
</StepQP>
</QueryPlanToAST>
</ContentSequence>
<ContentSequence>
<Sequence>
<AnyAtomicTypeConstructor value="," typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
</Sequence>
</ContentSequence>
<ContentSequence>
<Parenthesized>
<QueryPlanToAST>
<ChildJoinQP>
<VariableQP name="state"/>
<SequentialScanQP container="policyContainer.dbxml" nodeType="element"/>
</ChildJoinQP>
</QueryPlanToAST>
<QueryPlanToAST>
<StepQP axis="child" uri="*" name="*" nodeType="element">
<VariableQP name="header"/>
</StepQP>
</QueryPlanToAST>
<QueryPlanToAST>
<ChildJoinQP>
<VariableQP name="datatable"/>
<SequentialScanQP container="policyContainer.dbxml" nodeType="element"/>
</ChildJoinQP>
</QueryPlanToAST>
</Parenthesized>
</ContentSequence>
</Children>
</DOMConstructor>
</Return>
</XQuery>
The good news is that your indexes are being used (anywhere in the query plan where you see index="node-element-equality-string"), the bad news is that the entire policyContainer is being scanned several times (<SequentialScanQP container="policyContainer.dbxml" nodeType="element"/>). Your best bet is to upgrade to dbxml-2.5.16, since that has several improvements to the optimizer that should optimize away those scans. Failing that, use the shell command (dbxml) to add and remove indexes and see how that changes the query plan and speed. The following line is what is causing the scans:
{$state/*,$header/*,$datatable/*}So add indexes that will help to locate those nodes, or change that line so that the query is faster.
Lauren Foutz
Similar Messages
-
Please Help for the Query
Hi frds please help me for the below query.What I want to do is to pull out the data from below table :-
date ticker indicator
03/13/2008 3IINFOTECH -8
03/18/2008 3IINFOTECH -4
03/25/2008 3IINFOTECH -5
03/27/2008 3IINFOTECH -3
as such :-
date ticker indicator
03/13/2008 3IINFOTECH -8
03/25/2008 3IINFOTECH -5
03/27/2008 3IINFOTECH -3
Here I want to find the Trend i.e either asc or desc order from the lowest indicator.
In the above sample data -8, -4, -5, -3 out of which I want the asc order data -8, -5, -3 and exclude -4 data.Because the asc order -8, -5, -3 will not follow.
So I want the data
date ticker indicator
03/13/2008 3IINFOTECH -8
03/25/2008 3IINFOTECH -5
03/27/2008 3IINFOTECH -3SQL> CREATE TABLE BORRAME(FECHA DATE, INDICA VARCHAR2(100));
Tabla creada.
SQL> INSERT INTO BORRAME VALUES(TO_DATE('03/13/2008','MM/DD/YYYY'), '3IINFOTECH -8');
1 fila creada.
SQL> INSERT INTO BORRAME VALUES(TO_DATE('03/18/2008','MM/DD/YYYY'), '3IINFOTECH -4');
1 fila creada.
SQL> INSERT INTO BORRAME VALUES(TO_DATE('03/25/2008','MM/DD/YYYY'), '3IINFOTECH -5');
1 fila creada.
SQL> INSERT INTO BORRAME VALUES(TO_DATE('03/27/2008','MM/DD/YYYY'), '3IINFOTECH -3');
1 fila creada.
SQL> COMMIT;
Validación terminada.
SQL>
SQL> SELECT FECHA, INDICA
2 FROM BORRAME
3 WHERE SUBSTR(INDICA,INSTR(INDICA,'-',1)+1,LENGTH(INDICA)) <> '4'
4 ORDER BY SUBSTR(INDICA,INSTR(INDICA,'-',1)+1,LENGTH(INDICA)) DESC;
FECHA
INDICA
13/03/08
3IINFOTECH -8
25/03/08
3IINFOTECH -5
27/03/08
3IINFOTECH -3
-
Hi ,
Below query is taking more time (4mins) for 41 rows returning and there is no full table scan .Can some one help to rewrite the query.
SELECT
esma.candidate AS candidate_additional_sample,
ccr.raw_mark,
ccr.split_session_year AS year,
ccr.split_session_month AS month,
ccr.paper_code,
ccr.assessment_school AS school_code,
get_cand_session_number(ccr.split_session_year,ccr.split_session_month,ccr.candidate) AS candidate_session_number,
ccr.candidate AS candidate_code,
c.firstname AS candidate_firstname,
c.lastname AS candidate_lastname,
ema.moderator_code,
ema.examiner_code,
csr.self_taught
FROM
ibis.candidate_component_reg ccr
INNER JOIN ibis.candidate_examiner_allocation cea
ON ccr.split_session_year= cea.year
AND ccr.split_session_month=cea.month
AND ccr.assessment_school=cea.assessment_school
AND ccr.paper_code= cea.paper_code
AND ccr.candidate = cea.candidate
INNER JOIN ibis.examination_paper ep
ON ccr.split_session_year= ep.year
AND ccr.split_session_month=ep.month
AND ccr.paper_code=ep.paper_code
INNER JOIN ibis.examiner_moderator_allocation ema
ON ema.year =cea.year
AND ema.month =cea.month
AND ema.no_lang_code=ep.no_lang_code
AND ema.examiner_code=cea.examiner_code
AND ema.year =ccr.split_session_year
AND ema.month =ccr.split_session_month
INNER JOIN ibis.candidate_subject_registration csr
ON ccr.split_session_year=csr.year
AND ccr.split_session_month=csr.month
AND ccr.main_school=csr.main_school
AND ccr.candidate=csr.candidate
AND ccr.subject=csr.subject
AND ccr.subject_option=csr.subject_option
AND ccr.lvl=csr.lvl
AND ccr.language=csr.language
INNER JOIN ibis.candidate c
ON ccr.candidate=c.candidate
LEFT OUTER JOIN ibis.exam_sample_mark_additional esma
ON ccr.split_session_year = esma.year
AND ccr.split_session_month = esma.month
AND ep.no_lang_code = esma.nolang_code
AND ccr.candidate = esma.candidate
WHERE
ccr.split_session_year=:v_year
AND ccr.split_session_month=:v_month
AND ccr.subject=:v_subject
AND ccr.subject_option=nvl(:v_subject_option,ccr.subject_option)
AND ccr.language=nvl(:v_language, ccr.language)
AND ccr.component=:v_component
AND ccr.lvl=:v_lvl
AND ccr.raw_mark IS NOT NULL
AND cea.examiner_code = :v_examiner_code
AND ((ccr.sampled='Y'
AND csr.self_taught='N'
AND EXISTS (SELECT 1 FROM ibis.subject_component sc
WHERE sc.assessment_method_id = 11
AND sc.assessment_type='INTERNAL'
AND ccr.split_session_year=sc.year
AND ccr.split_session_month=sc.month
AND ccr.paper_code=sc.paper_code
AND ccr.subject=sc.subject
AND ccr.subject_option=sc.subject_option
AND ccr.lvl=sc.lvl
AND ccr.language=sc.language
AND ccr.component=sc.component)
AND NOT EXISTS (SELECT 1 FROM ibis.cw_portfolio_template cpt
WHERE ccr.split_session_year = cpt.year
AND ccr.split_session_month = cpt.month
AND ccr.subject = cpt.subject
AND ccr.subject_option = cpt.subject_option
AND ccr.component = cpt.component
AND cpt.combined = 'Y')
AND NOT EXISTS (SELECT 1 FROM ibis.school_sample_mark ssm
WHERE ssm.year= ccr.split_session_year
AND ssm.month = ccr.split_session_month
AND ssm.paper_code = ccr.paper_code
AND ssm.candidate =ccr.candidate
AND ssm.examiner_sample = 'Y'))
OR (ccr.sampled='N'
AND csr.self_taught='Y'
AND EXISTS (SELECT 1 FROM ibis.subject_component sc
WHERE sc.assessment_method_id = 11
AND ccr.split_session_year=sc.year
AND ccr.split_session_month=sc.month
AND ccr.paper_code=sc.paper_code
AND ccr.subject=sc.subject
AND ccr.subject_option=sc.subject_option
AND ccr.lvl=sc.lvl
AND ccr.language=sc.language
AND ccr.component=sc.component)
AND NOT EXISTS (SELECT 1 FROM ibis.cw_portfolio_template cpt
WHERE ccr.split_session_year = cpt.year
AND ccr.split_session_month = cpt.month
AND ccr.subject = cpt.subject
AND ccr.subject_option = cpt.subject_option
AND ccr.component = cpt.component
AND cpt.combined = 'Y'))
OR (ccr.sampled='N'
AND EXISTS (SELECT 1 FROM ibis.subject_component sc
WHERE sc.assessment_method_id = 11
AND ccr.split_session_year=sc.year
AND ccr.split_session_month=sc.month
AND ccr.paper_code=sc.paper_code
AND ccr.subject=sc.subject
AND ccr.subject_option=sc.subject_option
AND ccr.lvl=sc.lvl
AND ccr.language=sc.language
AND ccr.component=sc.component)
AND EXISTS (SELECT 1 FROM ibis.cw_portfolio_template cpt
WHERE ccr.split_session_year = cpt.year
AND ccr.split_session_month = cpt.month
AND ccr.subject = cpt.subject
AND ccr.subject_option = cpt.subject_option
AND ccr.component = cpt.component
AND cpt.combined = 'Y')));
explain plan
line 1: SQLPLUS Command Skipped: set linesize 130
line 2: SQLPLUS Command Skipped: set pagesize 0
PLAN_TABLE_OUTPUT
Plan hash value: 2594643366
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 2 | 1036 | 34 (3)| 00:00:01 |
|* 1 | FILTER | | | | | |
|* 2 | HASH JOIN OUTER | | 2 | 1036 | 34 (3)| 00:00:01 |
| 3 | VIEW | | 2 | 974 | 32 (0)| 00:00:01 |
| 4 | CONCATENATION | | | | | |
|* 5 | FILTER | | | | | |
|* 6 | TABLE ACCESS BY INDEX ROWID | CANDIDATE_SUBJECT_REGISTRATION | 1 | 58 | 3 (0)| 00:00:01 |
| 7 | NESTED LOOPS | | 1 | 485 | 16 (0)| 00:00:01 |
| 8 | NESTED LOOPS | | 1 | 427 | 13 (0)| 00:00:01 |
| 9 | NESTED LOOPS | | 1 | 357 | 11 (0)| 00:00:01 |
| 10 | NESTED LOOPS | | 1 | 129 | 8 (0)| 00:00:01 |
| 11 | NESTED LOOPS | | 1 | 80 | 5 (0)| 00:00:01 |
|* 12 | INDEX RANGE SCAN | PK_EXAMINER_MODERATOR_ALLOC | 1 | 39 | 3 (0)| 00:00:01 |
|* 13 | INDEX RANGE SCAN | RFL_EP1 | 1 | 41 | 2 (0)| 00:00:01 |
| 14 | TABLE ACCESS BY INDEX ROWID| CANDIDATE_EXAMINER_ALLOCATION | 1 | 49 | 3 (0)| 00:00:01 |
|* 15 | INDEX RANGE SCAN | CANDIDATE_ALLOCATION_EXAMINER | 1 | | 2 (0)| 00:00:01 |
|* 16 | TABLE ACCESS BY INDEX ROWID | CANDIDATE_COMPONENT_REG | 1 | 228 | 3 (0)| 00:00:01 |
|* 17 | INDEX RANGE SCAN | SPLIT_SESSION_CANDIDATE | 1 | | 2 (0)| 00:00:01 |
| 18 | TABLE ACCESS BY INDEX ROWID | CANDIDATE | 1 | 70 | 2 (0)| 00:00:01 |
|* 19 | INDEX UNIQUE SCAN | CANDIDATE_PK | 1 | | 1 (0)| 00:00:01 |
|* 20 | INDEX RANGE SCAN | Y_M_CAND_SUBJ_LVL_OPTION | 1 | | 2 (0)| 00:00:01 |
|* 21 | FILTER | | | | | |
|* 22 | TABLE ACCESS BY INDEX ROWID | CANDIDATE_SUBJECT_REGISTRATION | 1 | 58 | 3 (0)| 00:00:01 |
| 23 | NESTED LOOPS | | 1 | 485 | 16 (0)| 00:00:01 |
| 24 | NESTED LOOPS | | 1 | 427 | 13 (0)| 00:00:01 |
| 25 | NESTED LOOPS | | 1 | 357 | 11 (0)| 00:00:01 |
| 26 | NESTED LOOPS | | 1 | 129 | 8 (0)| 00:00:01 |
| 27 | NESTED LOOPS | | 1 | 80 | 5 (0)| 00:00:01 |
|* 28 | INDEX RANGE SCAN | PK_EXAMINER_MODERATOR_ALLOC | 1 | 39 | 3 (0)| 00:00:01 |
|* 29 | INDEX RANGE SCAN | RFL_EP1 | 1 | 41 | 2 (0)| 00:00:01 |
| 30 | TABLE ACCESS BY INDEX ROWID| CANDIDATE_EXAMINER_ALLOCATION | 1 | 49 | 3 (0)| 00:00:01 |
|* 31 | INDEX RANGE SCAN | CANDIDATE_ALLOCATION_EXAMINER | 1 | | 2 (0)| 00:00:01 |
|* 32 | TABLE ACCESS BY INDEX ROWID | CANDIDATE_COMPONENT_REG | 1 | 228 | 3 (0)| 00:00:01 |
|* 33 | INDEX RANGE SCAN | SPLIT_SESSION_CANDIDATE | 1 | | 2 (0)| 00:00:01 |
| 34 | TABLE ACCESS BY INDEX ROWID | CANDIDATE | 1 | 70 | 2 (0)| 00:00:01 |
|* 35 | INDEX UNIQUE SCAN | CANDIDATE_PK | 1 | | 1 (0)| 00:00:01 |
|* 36 | INDEX RANGE SCAN | Y_M_CAND_SUBJ_LVL_OPTION | 1 | | 2 (0)| 00:00:01 |
|* 37 | INDEX RANGE SCAN | EXAM_SAMP_MARK_ADD_IOT_PK | 36 | 1116 | 1 (0)| 00:00:01 |
|* 38 | TABLE ACCESS BY INDEX ROWID | CW_PORTFOLIO_TEMPLATE | 1 | 46 | 4 (0)| 00:00:01 |
|* 39 | INDEX RANGE SCAN | YEAR_MON_PORTFOLIO_TEMPLATE | 1 | | 3 (0)| 00:00:01 |
|* 40 | TABLE ACCESS BY INDEX ROWID | SCHOOL_SAMPLE_MARK | 1 | 34 | 4 (0)| 00:00:01 |
|* 41 | INDEX RANGE SCAN | CAND_PAPER_YEAR_MONTH | 1 | | 3 (0)| 00:00:01 |
|* 42 | TABLE ACCESS BY INDEX ROWID | SUBJECT_COMPONENT | 1 | 96 | 4 (0)| 00:00:01 |
|* 43 | INDEX RANGE SCAN | SUBJECT_COMPONENT_PK | 1 | | 3 (0)| 00:00:01 |
|* 44 | TABLE ACCESS BY INDEX ROWID | CW_PORTFOLIO_TEMPLATE | 1 | 46 | 4 (0)| 00:00:01 |
|* 45 | INDEX RANGE SCAN | YEAR_MON_PORTFOLIO_TEMPLATE | 1 | | 3 (0)| 00:00:01 |
|* 46 | TABLE ACCESS BY INDEX ROWID | SUBJECT_COMPONENT | 1 | 87 | 4 (0)| 00:00:01 |
|* 47 | INDEX RANGE SCAN | SUBJECT_COMPONENT_PK | 1 | | 3 (0)| 00:00:01 |
|* 48 | TABLE ACCESS BY INDEX ROWID | SUBJECT_COMPONENT | 1 | 87 | 4 (0)| 00:00:01 |
|* 49 | INDEX RANGE SCAN | SUBJECT_COMPONENT_PK | 1 | | 3 (0)| 00:00:01 |
|* 50 | TABLE ACCESS BY INDEX ROWID | CW_PORTFOLIO_TEMPLATE | 1 | 46 | 4 (0)| 00:00:01 |
|* 51 | INDEX RANGE SCAN | YEAR_MON_PORTFOLIO_TEMPLATE | 1 | | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("from$_subquery$_011"."SAMPLED"='Y' AND "from$_subquery$_011"."SELF_TAUGHT"='N' AND NOT EXISTS
(SELECT /*+ */ 0 FROM "IBIS"."CW_PORTFOLIO_TEMPLATE" "CPT" WHERE "CPT"."COMPONENT"=:B1 AND
"CPT"."SUBJECT_OPTION"=:B2 AND "CPT"."SUBJECT"=:B3 AND "CPT"."MONTH"=:B4 AND "CPT"."YEAR"=:B5 AND
"CPT"."COMBINED"='Y') AND NOT EXISTS (SELECT /*+ */ 0 FROM "IBIS"."SCHOOL_SAMPLE_MARK" "SSM" WHERE
"SSM"."MONTH"=:B6 AND "SSM"."YEAR"=:B7 AND "SSM"."PAPER_CODE"=:B8 AND "SSM"."CANDIDATE"=:B9 AND
"SSM"."EXAMINER_SAMPLE"='Y') AND EXISTS (SELECT /*+ */ 0 FROM "IBIS"."SUBJECT_COMPONENT" "SC" WHERE
"SC"."COMPONENT"=:B10 AND "SC"."SUBJECT_OPTION"=:B11 AND "SC"."LANGUAGE"=:B12 AND "SC"."LVL"=:B13 AND
"SC"."SUBJECT"=:B14 AND "SC"."MONTH"=:B15 AND "SC"."YEAR"=:B16 AND "SC"."PAPER_CODE"=:B17 AND
"SC"."ASSESSMENT_METHOD_ID"=11 AND "SC"."ASSESSMENT_TYPE"='INTERNAL') OR "from$_subquery$_011"."SAMPLED"='N'
AND "from$_subquery$_011"."SELF_TAUGHT"='Y' AND NOT EXISTS (SELECT /*+ */ 0 FROM
"IBIS"."CW_PORTFOLIO_TEMPLATE" "CPT" WHERE "CPT"."COMPONENT"=:B18 AND "CPT"."SUBJECT_OPTION"=:B19 AND
"CPT"."SUBJECT"=:B20 AND "CPT"."MONTH"=:B21 AND "CPT"."YEAR"=:B22 AND "CPT"."COMBINED"='Y') AND EXISTS (SELECT
/*+ */ 0 FROM "IBIS"."SUBJECT_COMPONENT" "SC" WHERE "SC"."COMPONENT"=:B23 AND "SC"."SUBJECT_OPTION"=:B24 ANDEdited byCan you please post the following scripts:
1. Tables structure (with all indexes & constraints)
2. Tables data
3. SQL trace file
possibly everything that one can need to regenerate the scenario on his own DB...
OR
spend some time with Oracle Docs on Performance Tuning and then resolve it yourself.
Regards,
Ankit Rathi
http://theoraclelog.blogspot.in -
Please help with the query (INSERT RETURNING BULK COLLECT INTO)
I am trying to write a query inside the C# code where I would insert values into a table in bulk using bind variables. But I also I would like to receive a bulk collection of generated sequence number IDs for the REQUEST_ID. I am trying to use RETURNING REQUEST_ID BULK COLLECT INTO :REQUEST_IDs clause where :REQUEST_IDs is another bind variable
Here is a full query that use in the C# code
INSERT INTO REQUESTS_TBL(REQUEST_ID, CID, PROVIDER_ID, PROVIDER_NAME, REQUEST_TYPE_ID, REQUEST_METHOD_ID, SERVICE_START_DT, SERVICE_END_DT, SERVICE_LOCATION_CITY, SERVICE_LOCATION_STATE, BENEFICIARY_FIRST_NAME,
BENEFICIARY_LAST_NAME, BENEFICIARY_DOB, HICNUM, CCN, CLAIM_RECEIPT_DT, ADMISSION_DT, BILL_TYPE,
LANGUAGE_ID, CONTRACTOR_ID, PRIORITY_ID, UNIVERSE_DT, REQUEST_DT, BENEFICIARY_M_INITIAL,
ATTENDING_PROVIDER_NUMBER, BILLING_NPI, BENE_ZIP_CODE, DRG, FINAL_ALLOWED_AMT, STUDY_ID, REFERRING_NPI)
VALUES
(SQ_CDCDATA.NEXTVAL, :CIDs, :PROVIDER_IDs, :PROVIDER_NAMEs, :REQUEST_TYPE_IDs,
:REQUEST_METHOD_IDs, :SERVICE_START_DTs, :SERVICE_END_DTs, :SERVICE_LOCATION_CITYs,
:SERVICE_LOCATION_STATEs, :BENEFICIARY_FIRST_NAMEs, :BENEFICIARY_LAST_NAMEs, :BENEFICIARY_DOBs,
:HICNUMs, :CCNs, :CLAIM_RECEIPT_DTs, :ADMISSION_DTs, :BILL_TYPEs, :LANGUAGE_IDs,
:CONTRACTOR_IDs, :PRIORITY_IDs, :UNIVERSE_DTs, :REQUEST_DTs, :BENEFICIARY_M_INITIALs,
:ATTENDING_PROVIDER_NUMBERs, :BILLING_NPIs, :BENE_ZIP_CODEs, :DRGs, :FINAL_ALLOWED_AMTs,
:STUDY_IDs, :REFERRING_NPIs) RETURNING REQUEST_ID BULK COLLECT INTO :REQUEST_IDs
However, when I run this query, it gives me a strange error ORA-00925: missing INTO keyword. I am not sure what that error means since I am not missing any INTOs
Please help me resolve this error or I would appreciate a different solution
Thank youYou cannot use (and do not want to in this case) the BULK COLLECT.
create table for_testing
the_id number not null primary key,
some_data number
declare
l_return_value for_testing.the_id%type;
begin
4
insert into for_testing
the_id,
some_data
values
1,
5
returning the_id into l_return_value;
dbms_output.put_line('the return values is ' || l_return_value);
end;
20 /
the return values is 1
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.02
TUBBY_TUBBZ?Is a simple example. In the future, please use the tags to preserve formatting on your code like i have so it remains readable . -
Please help with the query creating Materialized View
Hi,
We are using the below query to create a Materialized View but it has been running since 3 hours. It is an Oracle 9i database running in HP-UX.The quey is as follows,
(SELECT
/*+ use_nl(A) parallel (A,4)*/
A.ICD_CODE AS ICD_CODE,
A.ICD_DESC AS ICD_DESC,
A.PROC_GROUP as PROC_GROUP,
B.COMPL_ICD_CODE AS COMPL_ICD_CODE,
B.COMPL_GRP_TXT AS COMPL_GRP_TXT,
C.PROC_TYPE AS PROC_TYPE ,
C.I_O_IND AS I_O_IND,
C.DISC_MON AS QUARTER ,
B.PAT_KEY AS PAT_KEY ,
D.COMPL_TYPE_TXT AS COMPL_TYPE_TXT ,
C.PROV_ID AS PROV_ID ,
A.SPECIALTY AS SPECIALTY
FROM
EES_ICD_9_CODE A ,
EES_CLINICAL_COMPL_DATA B,
EES_CLINICAL_DATA C,
EES_CLINCL_COMPL_ICD D
WHERE A.ICD_CODE= B.ICD_CODE
AND B.ICD_CODE= C.ICD_CODE
AND B.COMPL_ICD_CODE=D.ICD_9_CD
AND B.PAT_KEY=C.PAT_KEY
AND B.COMPL_ICD_CODEB.ICD_CODE
AND C.PROC_TYPE 'L'
AND B.COMPL_GRP_TXT'Reoperations'
AND D.COMPL_TYPE_TXT'Intra-operative Misadventure'
AND C.DISC_MON>='2003101'
AND A.SPECIALTY='Colo-Rectal')
union
(SELECT
/*+ use_nl(A) parallel (A,4)*/
A.ICD_CODE AS ICD_CODE,
A.ICD_DESC AS ICD_DESC,
A.PROC_GROUP as PROC_GROUP,
B.COMPL_ICD_CODE AS COMPL_ICD_CODE,
B.COMPL_GRP_TXT AS COMPL_GRP_TXT,
C.PROC_TYPE AS PROC_TYPE ,
C.I_O_IND AS I_O_IND,
C.DISC_MON AS QUARTER ,
B.PAT_KEY AS PAT_KEY ,
D.COMPL_TYPE_TXT AS COMPL_TYPE_TXT ,
C.PROV_ID AS PROV_ID ,
A.SPECIALTY AS SPECIALTY
FROM
EES_ICD_9_CODE A ,
EES_CLINICAL_COMPL_DATA B,
EES_CLINICAL_DATA C,
EES_CLINCL_COMPL_ICD D
WHERE A.ICD_CODE= B.ICD_CODE
AND B.ICD_CODE= C.ICD_CODE
AND B.COMPL_ICD_CODE=D.ICD_9_CD
AND B.PAT_KEY=C.PAT_KEY
AND B.COMPL_ICD_CODEB.ICD_CODE
AND C.PROC_TYPE 'L'
--AND B.COMPL_GRP_TXT'Reoperations'
AND D.COMPL_TYPE_TXT='Intra-operative Misadventure'
AND B.PROC_DAY=C.PROC_DAY
AND C.DISC_MON>='2003101'
AND A.SPECIALTY='Colo-Rectal')
union
(SELECT
/*+ use_nl(A) parallel (A,4)*/
A.ICD_CODE AS ICD_CODE,
A.ICD_DESC AS ICD_DESC,
A.PROC_GROUP as PROC_GROUP,
B.COMPL_ICD_CODE AS COMPL_ICD_CODE,
B.COMPL_GRP_TXT AS COMPL_GRP_TXT,
C.PROC_TYPE AS PROC_TYPE ,
C.I_O_IND AS I_O_IND,
C.DISC_MON AS QUARTER ,
B.PAT_KEY AS PAT_KEY ,
D.COMPL_TYPE_TXT AS COMPL_TYPE_TXT ,
C.PROV_ID AS PROV_ID ,
A.SPECIALTY AS SPECIALTY
FROM
EES_ICD_9_CODE A ,
EES_CLINICAL_COMPL_DATA B,
EES_CLINICAL_DATA C,
EES_CLINCL_COMPL_ICD D
WHERE A.ICD_CODE= B.ICD_CODE
AND B.ICD_CODE= C.ICD_CODE
AND B.COMPL_ICD_CODE=D.ICD_9_CD
AND B.PAT_KEY=C.PAT_KEY
AND B.COMPL_ICD_CODEB.ICD_CODE
AND C.PROC_TYPE 'L'
AND B.COMPL_GRP_TXT='Reoperations'
--AND D.COMPL_TYPE_TXT='Intra-operative Misadventure'
AND B.PROC_DAY>C.PROC_DAY
AND C.DISC_MON>='2003101'
AND A.SPECIALTY='Colo-Rectal')
The explain plan is as follows,
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost | TQ |IN-OUT| PQ Distrib |
| 0 | SELECT STATEMENT | | 46935 | 6716K| | 10648 | | | |
| 1 | SORT UNIQUE | | 46935 | 6716K| 14M| 10648 | 45,14 | P->S | QC (RAND) |
| 2 | UNION-ALL | | | | | | 45,13 | P->P | HASH |
|* 3 | HASH JOIN | | 42801 | 6102K| | 4640 | 45,13 | PCWP | |
|* 4 | TABLE ACCESS FULL | EES_CLINCL_COMPL_ICD | 875 | 18375 | | 2 | 45,02
|* 5 | HASH JOIN | | 41552 | 5072K| 14M| 4638 | 45,13 | PCWP | |
|* 6 | TABLE ACCESS FULL | EES_CLINICAL_DATA | 1430K| 40M| | 2855 | 45,03
|* 7 | HASH JOIN | | 628K| 56M| | 494 | 45,10 | P->P | HASH |
|* 8 | TABLE ACCESS FULL | EES_ICD_9_CODE | 37 | 2183 | | 1 | 45,08
|* 9 | TABLE ACCESS BY INDEX ROWID | EES_CLINICAL_COMPL_DATA | 2090K| 71M| | 49
| 10 | BITMAP CONVERSION TO ROWIDS | | | | | | |
|* 11 | BITMAP INDEX FULL SCAN | INX_COMPL_GRP | | | | | |
|* 12 | TABLE ACCESS BY INDEX ROWID | EES_CLINICAL_DATA | 1 | 33 | | 1
| 13 | NESTED LOOPS | | 1327 | 196K| | 947 | 45,13 | PCWP | |
|* 14 | HASH JOIN | | 60205 | 6996K| | 495 | 45,13 | PCWP | |
| 15 | TABLE ACCESS BY INDEX ROWID | EES_CLINCL_COMPL_ICD | 36 | 756 | |
|* 16 | INDEX RANGE SCAN | COMPL_TYPE_TXT_3 | 1 | | | 1 |
|* 17 | HASH JOIN | | 1420K| 132M| | 494 | 45,13 | PCWP | |
|* 18 | TABLE ACCESS FULL | EES_ICD_9_CODE | 37 | 2183 | | 1 | 45,11
|* 19 | TABLE ACCESS BY INDEX ROWID | EES_CLINICAL_COMPL_DATA | 4722K| 175M| | 49
| 20 | BITMAP CONVERSION TO ROWIDS| | | | | | | |
| 21 | BITMAP INDEX FULL SCAN | INX_COMPL_GRP | | | | | |
|* 22 | INDEX RANGE SCAN | EES_CLINICAL_DATA_IND1 | 1 | | | 2 | 45,13
|* 23 | HASH JOIN | | 2807 | 416K| | 4695 | 45,13 | PCWP | |
| 24 | TABLE ACCESS FULL | EES_CLINCL_COMPL_ICD | 911 | 19131 | | 2 | 45,06
|* 25 | HASH JOIN | | 2617 | 334K| 15M| 4693 | 45,13 | PCWP | |
|* 26 | TABLE ACCESS FULL | EES_CLINICAL_DATA | 1430K| 45M| | 2855 | 45,07
|* 27 | HASH JOIN | | 791K| 74M| | 305 | 45,12 | P->P | HASH |
|* 28 | TABLE ACCESS FULL | EES_ICD_9_CODE | 37 | 2183 | | 1 | 45,09
|* 29 | TABLE ACCESS BY INDEX ROWID | EES_CLINICAL_COMPL_DATA | 2632K| 97M| | 30
| 30 | BITMAP CONVERSION TO ROWIDS | | | | | | |
|* 31 | BITMAP INDEX SINGLE VALUE | INX_COMPL_GRP | | | | | |
Predicate Information (identified by operation id):
3 - access("B"."COMPL_ICD_CODE"="D"."ICD_9_CD")
4 - filter("D"."COMPL_TYPE_TXT"'Intra-operative Misadventure')
5 - access("B"."ICD_CODE"="C"."ICD_CODE" AND "B"."PAT_KEY"="C"."PAT_KEY")
6 - filter("C"."PROC_TYPE"'L' AND "C"."DISC_MON">=2003101)
7 - access("A"."ICD_CODE"="B"."ICD_CODE")
8 - filter("A"."SPECIALTY"='Colo-Rectal')
9 - filter("B"."COMPL_ICD_CODE""B"."ICD_CODE")
11 - filter("B"."COMPL_GRP_TXT"'Reoperations')
12 - filter("B"."ICD_CODE"="C"."ICD_CODE" AND "C"."PROC_TYPE"'L' AND "B"."PROC_DAY"="C"."PROC_DA
14 - access("B"."COMPL_ICD_CODE"="D"."ICD_9_CD")
16 - access("D"."COMPL_TYPE_TXT"='Intra-operative Misadventure')
17 - access("A"."ICD_CODE"="B"."ICD_CODE")
18 - filter("A"."SPECIALTY"='Colo-Rectal')
19 - filter("B"."COMPL_ICD_CODE""B"."ICD_CODE")
22 - access("B"."PAT_KEY"="C"."PAT_KEY")
23 - access("B"."COMPL_ICD_CODE"="D"."ICD_9_CD")
25 - access("B"."ICD_CODE"="C"."ICD_CODE" AND "B"."PAT_KEY"="C"."PAT_KEY")
filter("B"."PROC_DAY">"C"."PROC_DAY")
26 - filter("C"."PROC_TYPE"'L' AND "C"."DISC_MON">=2003101)
27 - access("A"."ICD_CODE"="B"."ICD_CODE")
28 - filter("A"."SPECIALTY"='Colo-Rectal')
29 - filter("B"."COMPL_ICD_CODE""B"."ICD_CODE")
31 - access("B"."COMPL_GRP_TXT"='Reoperations')
Note: cpu costing is offPlease help.Try removing the hints.
Is 47,000 a reasonable estimate of how many rows you expect in the results?
See these posts for other information that you should supply.
HOW TO: Post a SQL statement tuning request
HOW TO: Post a SQL statement tuning request - template posting
When your query takes too long
When your query takes too long ... -
Help tuning the query on NAST table .
I have the below query on NAST table which is performin very badly:
SELECT objky INTO TABLE i_objky
FROM nast
WHERE kappl = c_kappl
AND ( ( kschl = c_kschl_zbax )
OR ( kschl = c_kschl_zoem ) )
AND vstat = c_vstat_comp
AND objtype = c_likp
AND ( ( datvr EQ w_start_date AND
uhrvr GE w_start_time ) OR
( datvr EQ w_end_date AND
uhrvr LE w_end_time ) OR
( datvr GT w_start_date AND
datvr LT w_end_date ) ).
Further there is already an index on KAPPL and KSCHL.
Message was edited by:
Ashish kumarIf I understood your logic correctly - you are trying to select objects which have outputs processed within your date/time interval.
You can try to rewrite your select to force index 'A' usage as suggested by Christian, but it is not very helpful if you have too many records in NAST as in this case this index is not very selective and optimizer usually ignores it. Of course, you can ask your BASIS folks to tell you if you can use 'hint' addition in your select to force index usage as it depends on DB and some DBs require some work to be done on DB level to enable hints.
Other options could be
- try to provide a range (even if it is wide enough) for object key... it may really help as NAST contains too many records for different objects and this range may help with primary key usage.
- OR if you are interested in these 2 output types only - you can increase the speed of your select significally if you define a separate database table which you will update with these outputs (when they are just created in NAST) and your program (if it usually runs just once per your date.time range) will check the status of these outputs and then delete records from your table or just update them with "processed" status.
You can actually just create a copy of NAST table which is going to be updated when these outputs are processed (from corresponding processing program), so you will have records there with at least date, and then based on these records you can select actual date/time from NAST. It will be much faster... but it requires more design/coding. -
I have table which has 4 columns (A,B,C,D)
Table t1
A B C D
1 - - -
- 2 - -
- - 3 -
- - - 4
5 - - -
- 6 - -
- - 7 -
- - - 8
the required output is
Table T2
A B C D
1 2 3 4
5 6 7 8
How can i come up with this outputlike this
with t
as
select 1 c1, null c2, null c3, null c4 from dual union all
select null, 2, null, null from dual union all
select null, null, 3, null from dual union all
select null, null, null, 4 from dual union all
select 5, null, null, null from dual union all
select null, 6, null, null from dual union all
select null, null, 7, null from dual union all
select null, null, null, 8 from dual
select max(c1), max(c2), max(c3), max(c4)
from (
select t.*,
last_value(c1 ignore nulls) over(order by nvl(c1,0)+nvl(c2,0)+nvl(c3,0)+nvl(c4,0)) gval
from t
group by gval -
Hi to all,
I have flat files in different location through FTP i need to fetch those files and load in the relavant table of the database.
Please share me the query to do it ..You would need a ForEach Loop to iterate though the files. Initially the FTP task will pull the files from locations to a landing folder. Once thats done the ForEachLoop will iterate through files in the folder and will have a data flow task inside to transfer
file data to tables.
If you want a more secure option you can also use SFTP (Secured FTP) and can implement it using free WinSCP clinet. I've explained a method of doing it fo dynamic files here
http://visakhm.blogspot.in/2012/12/implementing-dynamic-secure-ftp-process.html
for iterating through files see this example
http://visakhm.blogspot.in/2012/05/package-to-implement-daily-processing.html
you may not need the validation step inside the loop in your case
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Please tell me the query,If i want to fetch before 5 days data from sqlite database in ios ?
kumar190 wrote:
Please Can you send me the link of Sq-lite(Making own Schema). Which will be help full for me...
Here is the general concept for a database schema: http://en.wikipedia.org/wiki/Database_schema
This is how you would create a table in SQLite: https://sqlite.org/lang_createtable.html -
Hi, please help with the installation of Lightroom 4, I bought a new Mac (Apple) and I want to install a software that I have on the album cd. My new computer does not have the drives. Can I download software from Adobe? Is my license number just to be able to download the srtony adobe.
Adobe - Lightroom : For Macintosh
Hal -
I'm trying to setup a printer go wireless through my airport extreme, but every time I try to print the printing file gets paused. I'm in loop. PLEASE HELP! (The printer is a Brother 7020 monochrome)
I had the exact same problem
It turns out I was using a 20 foot USB cable between the printer and the Airport Extreme and the signal had become to weak to work. Try using nothing more than a 6 foot cable or try a new cable -
I need help with the query
Here is what I need
For a particular comm record if there is no Salary record where comm:Date = Salary:Date, then
• Find maximum dated Salary record as of comm:Date.
• Clone this record and set Salary:Date = comm:Date
• Set Salary:rate = comm:rate
Like wise for a particular Salary record If there is no comm record where Salary:Date = comm:Date then
• Find maximum effective dated comm record as of Salary:Date
• Apply Rate 2 amount from this maximum effective dated record to Salary record i.e. Set Salary:rate = comm:rate
Example
Salary Table :
ID Sal_Date Rate Hours
1 07/01/2011 400.00 40
2 02/15/2011 200.00 40
3 01/01/2011 160.00 40
Sal_comm Table:
Sal_Date comm_Rate
1 07/01/2011 10.00
4 03/01/2011 7.50
3 01/01/2011 4.00
I need to merge comm_Rate column in Salary table, since there is no salary record as off 03/01/2011, I need to find the maximum dated salary record as of 03/01/2011
i.e. the record dated 02/15/2011. Now I need to clone that salary record, set the SAL_date as 03/01/2011 and update Rate2 amount. So the record set will be like:
Sal_Date:
id sal_Date Rate Hours comm_Rate
1 07/01/2011 400.00 40 10.00
4 03/01/2011 200.00 40 7.50
2 02/15/2011 200.00 40 4.00
3 01/01/2011 160.00 40 4.00So you need all used dates as the "driving" dataset. And you need the according data for each of these.
WITH salary_table as
(select 1 id,to_date('07/01/2011','MM/DD/YYYY')sal_date,400 rate,40 hours from dual union all
select 2 id,to_date('02/15/2011','MM/DD/YYYY')sal_date,200 rate,40 hours from dual union all
select 3 id,to_date('01/01/2011','MM/DD/YYYY')sal_date,160 rate,40 hours from dual),
sal_comm as
(select 1 id,to_date('07/01/2011','MM/DD/YYYY')sal_date,10 comm_Rate from dual union all
select 4 id,to_date('03/01/2011','MM/DD/YYYY')sal_date,7.5 comm_Rate from dual union all
select 3 id,to_date('01/01/2011','MM/DD/YYYY')sal_date,4 comm_Rate from dual)
select to_char(all_dates.sal_date,'MM/DD/YYYY') sal_date,sal.rate,sal.hours,com.comm_rate
from (select sal_date from salary_table
union
select sal_date from sal_comm) all_dates
inner join (select s1.*,lead(sal_date-1,1,to_date('31/12/9999','DD/MM/YYYY')) over (order by sal_date) next_sal_date
from salary_table s1) sal
on (all_dates.sal_date between sal.sal_date and sal.next_sal_date)
inner join (select s1.*,lead(sal_date-1,1,to_date('31/12/9999','DD/MM/YYYY')) over (order by sal_date) next_sal_date
from sal_comm s1) com
on (all_dates.sal_date between com.sal_date and com.next_sal_date)
order by all_dates.sal_date desc;
SAL_DATE RATE HOURS COMM_RATE
07/01/2011 400 40 10
03/01/2011 200 40 7.5
02/15/2011 200 40 4
01/01/2011 160 40 4
-
Urgent, please help. why the ListSelectionListener() called twice?
I had two JList, and every time, I click value in list1, it will call the ListSelectionListener() twice, and when I click on value in List2, it called the list2 actionListener twice also, I don't know why?
Please help.
The part of the code list below:
jList1 = new JList(words1);
JScrollPane scrollPane1 = new JScrollPane(jList1); jList1.setBackground(Color.lightGray);
jList1.setBorder(BorderFactory.createLoweredBevelBorder());
jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
jList1_valueChanged(e){
/* add Column_Name to the jList2*/
JScrollPane scrollPane2 = new JScrollPane(jList2);
jList2.setBackground(Color.lightGray);
jList2.setBorder(BorderFactory.createLoweredBevelBorder());
jList2.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
jList2_valueChanged(e);
void jList1_valueChanged(ListSelectionEvent evt)
void jList2_valueChanged(ListSelectionEvent evt)
{ }You can call ListSelectionEvent.getValueIsChanging() to find out if the selection is in progress or if has been finished. You will get an event both when the user starts the selection (presses the button) and when he/she finishes it (lets go of the betton).
/Michael -
I cannot restore my Iphone 4, I keep getting the error code 1611, please help and the Iphone keeps displaying the "Plug-In Itunes Symbol!??
http://tinyurl.com/nyj36v
-
My IPOD menus suddenly appear in Japanese or Chinese and are impossible to understand for me who is european. Has somebody else had this problem? Please help? The song titles are still in the language they were entered though. /Jane
Fingers crossed, the following document might be of some assistance:
iPod: Changing the display language -
i have proubleam with string to date conversion, i out put date fromat is 2012-04-30T23:48:55.727-07:00 . so please help me the format conversion.
i wrote the method but it not workig
My method is
-(NSDate *)dateformstr:(NSString *)str
NSString *date = [str stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSDateFormatter *dateFormate = [[NSDateFormatter alloc] init];
[dateFormate setDateFormat:@"yyyy-MM-dd'T'HH:mm:sssZZZZ"]
// NSDate *formatterDate = [dateFormate dateFromString:str];
return formatterDate;
but i did not the value and if i try othere formate i is working but my requiremet format is 2012-04-30T23:48:55.727-07:00.
can any help it out in this senario.Sorry Butterbean, but I'm interested in the answer to your question myself.
I've spent a few hours transfering my library from one computer to another and then find out that my ratings didn't transfer. Like you, I've spent many hours rating my 2000+ songs. I'm sure you have more, nevertheless, I want to find out how to get those ratings. They still show in my iTunes on my laptop but, when I go to the iTunes folder and display the details of at song, no rating is there. If you find out how to get them to display there in the iTunes folder, it seems that would be the key.
Hope you get your answer soon.
Maybe you are looking for
-
How to convert .doc file into .rtf file in Java?
Hello All, I want to convert doc file into rtf format in java and for the same i am not getting any help so pls suggest some solution for that. Thanks and Regards only1Vinay
-
Random lines around screen and then cannot restart computer
I'm having an issue with my iMac. recently i i will turn it on and after a while there will be random lines across my screen in certain windows. when I move the windows around the line moves with the window. as i open other apps i start getting other
-
Change Batch Management Flag in Material Master
TCode : MM17 Select General Material Data MARA Execute(F8) Enter Material Number Execute(F8) Click on Select Fields Icon above New Values under General Material Data tab Choose "Batch Management" Check/Uncheck Flag for Batch Management & Save
-
I need to develop a online PDF viewer in Flash that should have the options of Page navigation, Zoom, Search, print How is is possible . I need suggesstions
-
I'm trying to Download mbam Malwarebytes-Anti-Malware, because of a lot of trouble getting my Browser to get things on the Internet. I want to clean up this stuff, but I need the Program. I go on Site and Hit the Download and then See Nothing. I don'