Avoid Distinct operation
Hi..
How to avoid distinct operation in table view reports
In my database data are
id__Name__Salary
01_aaaaa__1000
01_aaaaa__1000
01_aaaaa__1000
02_aaaaa__1000
02_aaaaa__1000
My output
01_aaaaa__1000
02_aaaaa__1000
but I need
id__Name__Salary
01_aaaaa__1000
01_aaaaa__1000
01_aaaaa__1000
02_aaaaa__1000
02_aaaaa__1000
This may help, see the answer:
Re: OBIEE using distinct
Have you got ID in the table that is unique?
Regards
Goran
http://108obiee.blogspot.com
Similar Messages
-
Question on using Distinct operator and avoiding ORA-00936 error
I may have answered my own question, by searching the OTN forums, but I just want to confirm what I've learned.
I'm trying to use a distinct on one of my columns, where I am pulling multiple columns, and trying to avoid duplicate entries. From most of my textbook example, when an example is using a distinct, they were only pulling one column.
From my example below, when I try to use a distinct, I get the following error: ORA-00936: missing expression:
select p.list_id, distinct(p.associate_id), d.first, d.last, c.street1, c.street2, c.city, c.state, c.country, c.postal_code, c.email
from sf.profiles p, demographics d, contact_info c
where p.entity_id = d.entity_id
and p.entity_id = c.entity_id
and p.list_id = 111
and associate_id in (insert associate_id in here
);Once I searched OTN, I saw some examples, where they had the distinct operator as the first column. So I switched it with p.list_id, and the query ran find.
select distinct p.associate_id, p.list_id, d.first, d.last, c.street1, c.street2, c.city, c.state, c.country, c.postal_code, c.email
from sf.profiles p, demographics d, contact_info c
where p.entity_id = d.entity_id
and p.entity_id = c.entity_id
and p.list_id = 111
and associate_id in (insert associate_id in here);So, does the distinct operator have to go first, if using multiple columns?
thanks
Message was edited by:
cmmillerWith or without parenthesis, it's a distinct clause for all columns in select statement:
SQL> select * from tt1;
ID T
10203 1
10203 2
SQL> select distinct(id), text from tt1;
ID T
10203 1
10203 2
SQL> select id, text from tt1;
ID T
10203 1
10203 2
SQL> Nicolas. -
DISTINCT operator performance issue
Hi Guyz,
I am facing a performance issue in a query which contains DISTINCT function. Following is my query:
SELECT /*+ ORDERED USE_NL_WITH_INDEX(c DIMENSION_KEY_PK) */
DISTINCT f.*,c.client_ids
FROM FACT_TAB f, DIM_TAB c
WHERE f.client = c.dimension_key
FACT_TAB = Fact table with a bitmap index on client column (10,000,000 records).
DIM_TAB = Dimension table with dimension_key as primary key (100,000 records).
when i select only fact table columns in the above query, the query executes within a second. But when i execute the above query it takes more than 15 minutes to execute.
How can i improve the above query. Any suggestions or tips would be helpful.
Thanks in advance.Hi myers,
you are absolutely right, there is no purpose of using DISTINCT, because i have found there are no duplicates in fact table, neither in dimension.
BUT there is another problem after this, i am joining these two tables with another table (INLINE VIEW), which gives me duplicate data, so i need DISTINCT operator for that purpose. Time dimension is also used in this query now. Here is my new Query:
SELECT /*+ ORDERED USE_NL_WITH_INDEX(c DIMENSION_KEY_PK) */
DISTINCT f.*,c.client_ids
FROM FACT_TAB f, DIM_TAB c, DIM_TIME_TAB t, (select id,start_date,end_date from tab3) tab
WHERE f.client = c.dimension_key
AND f.time = t.dimension_key
AND f.tabid = tab.id
AND t.day_start_date >= tab.start_date
AND (t.day_start_date <= tab.end_date OR tab.end_date IS NULL)
Thanks -
How to avoid DISTINCT in OBIEE SQL
Hi...
For question i posted previously...
Problem with LONG datatype in Answers
I run the query in TOAD, and i was identified the error because of what this error is coming... because of DISTINCT...
I have taken care of avoiding that column in ORDER BY by putting the order by on another column..
Now my question is how to avoid the DISTINCT clause in SQL generated by OBIEE...
If the first column in criteria is measure then it avoids the DISTINCT... but if i use measure... group by will come.. and group by should not be used here...
If this is done... my problem will be resolved...
Ofcourse... i would be getting duplicate rows...
Still i want the answer how to avoid DISTINCT?
Expecting answer from you...
Thanks & Regards
Kishore GuggillaHi...
Thanks for reply...
Now another question.. if i want to do this for one report... how?/
If i do that change in Catalog properties.. that will be effected for all reports i think...
Instead of that if i want to do that for only one report.. which is effecting... then how to proceed??
I tried by writing case when 1=0 ... for first column in criteria.. but no luck...
Thanks & Regards
Kishore Guggilla -
Rewrite sql to avoid filter operation
Hi All,
I found below sql and some more sql's causing high CPU usage.
SELECT :B1 AS ID ,
DECODE((SELECT 1
FROM DUAL
WHERE EXISTS (SELECT NULL
FROM ONS
WHERE PARENT_ID = :B1 )), 1, 1, 0) AS IP_RELATION ,
DECODE((SELECT 1
FROM DUAL
WHERE EXISTS (SELECT NULL
FROM ONS
WHERE ULTIMATE_PARENT_GID = :B1 )), 1, 1, 0) AS UP_RELATION ,
DECODE((SELECT 1
FROM DUAL
WHERE EXISTS (SELECT NULL FROM AFFILIATIONS WHERE AFFILIATED_ID= :B1 )), 1, 1, 0) AS AFF_RELATION ,
DECODE((SELECT 1
FROM DUAL
WHERE EXISTS (SELECT NULL FROM JOINT_VENTURES WHERE JOINT_VENTURE_ID= :B1 )), 1, 1, 0) AS JV_RELATION ,
DECODE((SELECT 1
FROM DUAL
WHERE EXISTS (SELECT NULL FROM SUCCESSORS WHERE SUCCESSOR_ID= :B1 )), 1, 1, 0) AS SUC_RELATION ,
DECODE((SELECT 1
FROM DUAL
WHERE EXISTS (SELECT NULL FROM COUNTERPARTY WHERE CP_TAX_AUTHORITY_ID = :B1 )), 1, 1, 0) AS TAX_AUTH_RELATION ,
DECODE((SELECT 1
FROM DUAL
WHERE EXISTS (SELECT NULL FROM COUNTERPARTY WHERE CP_PRIM_REGULATOR_ID = :B1 )), 1, 1, 0) AS PRIM_REG_RELATION ,
DECODE((SELECT 1
FROM DUAL
WHERE EXISTS (SELECT NULL FROM ONS WHERE DUPLICATE_OF_ID = :B1 )), 1, 1, 0) AS DUP_RELATION ,
DECODE((SELECT 1
FROM DUAL
WHERE EXISTS (SELECT NULL FROM ONS WHERE REG_AUTHORITY_ID = :B1 )), 1, 1, 0) AS REG_AUTH_RELATION
FROM DUAL
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | | | 2 (100)| |
|* 1 | FILTER | | | | | |
| 2 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | IDX_IMMEDIATE_PARENT_ID | 1 | 3 | 2 (0)| 00:00:01 |
|* 4 | FILTER | | | | | |
| 5 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
|* 6 | INDEX RANGE SCAN | IDX_ULTIMATE_PARENT_ID | 2 | 4 | 2 (0)| 00:00:01 |
|* 7 | FILTER | | | | | |
| 8 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
|* 9 | INDEX FAST FULL SCAN| PK_ORG_AFFILIATED_WITH | 1 | 7 | 294 (7)| 00:00:04 |
|* 10 | FILTER | | | | | |
| 11 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
|* 12 | INDEX FULL SCAN | PK_ORG_JOINT_VENTURE_OF | 1 | 7 | 3 (0)| 00:00:01 |
|* 13 | FILTER | | | | | |
| 14 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
|* 15 | INDEX FAST FULL SCAN| PK_ONS_SUCCEEDED_BY | 1 | 7 | 79 (7)| 00:00:01 |
|* 16 | FILTER | | | | | |
| 17 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
|* 18 | INDEX RANGE SCAN | IDX_ORG_CP_TAX_AUTHORITY_ID | 2 | 14 | 2 (0)| 00:00:01 |
|* 19 | FILTER | | | | | |
| 20 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
|* 21 | INDEX RANGE SCAN | IDX_ORGCP_PRIM_REGULATOR_ID | 1 | 4 | 2 (0)| 00:00:01 |
|* 22 | FILTER | | | | | |
| 23 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
|* 24 | TABLE ACCESS FULL | ONS | 1 | 2 | 27013 (4)| 00:05:25 |
|* 25 | FILTER | | | | | |
| 26 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
|* 27 | TABLE ACCESS FULL | ONS | 1 | 2 | 475 (3)| 00:00:06 |
| 28 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
Peeked Binds (identified by position):
2 - :B1 (NUMBER, Primary=1)
3 - :B1 (NUMBER, Primary=1)
4 - :B1 (NUMBER, Primary=1)
5 - :B1 (NUMBER, Primary=1)
6 - :B1 (NUMBER, Primary=1)
7 - :B1 (NUMBER, Primary=1)
8 - :B1 (NUMBER, Primary=1)
9 - :B1 (NUMBER, Primary=1)
10 - :B1 (NUMBER, Primary=1)
Predicate Information (identified by operation id):
1 - filter( IS NOT NULL)
3 - access("IMMEDIATE_PARENT_ID"=:B1)
4 - filter( IS NOT NULL)
6 - access("ULTIMATE_PARENT_ID"=:B1)
7 - filter( IS NOT NULL)
9 - filter("AFFILIATED_ID"=:B1)
10 - filter( IS NOT NULL)
12 - access("JOINT_VENTURE_ID"=:B1)
filter("JOINT_VENTURE_ID"=:B1)
13 - filter( IS NOT NULL)
15 - filter("SUCCESSOR_ID"=:B1)
16 - filter( IS NOT NULL)
18 - access("CP_TAX_AUTHORITY_ID"=:B1)
19 - filter( IS NOT NULL)
21 - access("CP_PRIM_REGULATOR_ID"=:B1)
22 - filter( IS NOT NULL)
24 - filter("DUPLICATE_OF_ID"=:B1)
25 - filter( IS NOT NULL)
27 - filter("REG_AUTHORITY_ID"=:B1)Oracle Version : 10.2.0.4 RAC 2 nodes
Is there any possibility to rewrite this sql to avoid filter operation.
Please let me know if you need any more details....My bad..i overlooked the execution plan.
Below execution plan has been extracted from devlopment database which is exact replica of production database.
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads |
|* 1 | FILTER | | 1 | | 1 |00:00:00.72 | 8028 | 5986 |
| 2 | FAST DUAL | | 1 | 1 | 1 |00:00:00.01 | 0 | 0 |
| 3 | PARTITION RANGE ALL | | 1 | 1 | 1 |00:00:00.72 | 8028 | 5986 |
|* 4 | TABLE ACCESS FULL | ONS | 1 | 1 | 1 |00:00:00.72 | 8028 | 5986 |
|* 5 | FILTER | | 1 | | 1 |00:00:00.19 | 7 | 0 |
| 6 | FAST DUAL | | 1 | 1 | 1 |00:00:00.01 | 0 | 0 |
| 7 | PX COORDINATOR | | 1 | | 1 |00:00:00.19 | 7 | 0 |
| 8 | PX SEND QC (RANDOM) | :TQ10000 | 0 | 1 | 0 |00:00:00.01 | 0 | 0 |
| 9 | PX PARTITION RANGE ALL| | 0 | 1 | 0 |00:00:00.01 | 0 | 0 |
|* 10 | INDEX RANGE SCAN | IDX_ULTIMATE_PARENT_ID | 0 | 1 | 0 |00:00:00.01 | 0 | 0 |
|* 11 | FILTER | | 1 | | 0 |00:00:00.11 | 1231 | 0 |
| 12 | FAST DUAL | | 0 | 1 | 0 |00:00:00.01 | 0 | 0 |
|* 13 | INDEX FAST FULL SCAN | PK_ORG_AFFILIATED_WITH | 1 | 1 | 0 |00:00:00.11 | 1231 | 0 |
|* 14 | FILTER | | 1 | | 0 |00:00:00.01 | 7 | 0 |
| 15 | FAST DUAL | | 0 | 1 | 0 |00:00:00.01 | 0 | 0 |
|* 16 | INDEX FAST FULL SCAN | PK_ORG_JOINT_VENTURE_OF | 1 | 1 | 0 |00:00:00.01 | 7 | 0 |
|* 17 | FILTER | | 1 | | 0 |00:00:00.02 | 229 | 0 |
| 18 | FAST DUAL | | 0 | 1 | 0 |00:00:00.01 | 0 | 0 |
|* 19 | INDEX FAST FULL SCAN | PK_ONS_SUCCEEDED_BY | 1 | 1 | 0 |00:00:00.02 | 229 | 0 |
|* 20 | FILTER | | 1 | | 1 |00:00:00.01 | 3 | 0 |
| 21 | FAST DUAL | | 1 | 1 | 1 |00:00:00.01 | 0 | 0 |
|* 22 | INDEX RANGE SCAN | IDX_CP_TAX_AUTHORITY_ID | 1 | 2 | 1 |00:00:00.01 | 3 | 0 |
|* 23 | FILTER | | 1 | | 1 |00:00:00.01 | 3 | 0 |
| 24 | FAST DUAL | | 1 | 1 | 1 |00:00:00.01 | 0 | 0 |
|* 25 | INDEX RANGE SCAN | IDX_CP_PRIM_REGULATOR_ID | 1 | 1 | 1 |00:00:00.01 | 3 | 0 |
|* 26 | FILTER | | 1 | | 1 |00:00:02.20 | 28923 | 21562 |
| 27 | FAST DUAL | | 1 | 1 | 1 |00:00:00.01 | 0 | 0 |
| 28 | PARTITION RANGE ALL | | 1 | 1 | 1 |00:00:02.20 | 28923 | 21562 |
|* 29 | TABLE ACCESS FULL | ONS | 1 | 1 | 1 |00:00:02.20 | 28923 | 21562 |
|* 30 | FILTER | | 1 | | 1 |00:00:00.01 | 4 | 5 |
| 31 | FAST DUAL | | 1 | 1 | 1 |00:00:00.01 | 0 | 0 |
| 32 | PARTITION RANGE ALL | | 1 | 1 | 1 |00:00:00.01 | 4 | 5 |
|* 33 | TABLE ACCESS FULL | ONS | 1 | 1 | 1 |00:00:00.01 | 4 | 5 |
| 34 | FAST DUAL | | 1 | 1 | 1 |00:00:00.01 | 0 | 0 |
Predicate Information (identified by operation id):
1 - filter( IS NOT NULL)
4 - filter("IMMEDIATE_PARENT_ID"=:B1)
5 - filter( IS NOT NULL)
10 - access("ULTIMATE_PARENT_ID"=:B1)
11 - filter( IS NOT NULL)
13 - filter("AFFILIATED_ID"=:B1)
14 - filter( IS NOT NULL)
16 - filter("JOINT_VENTURE_ID"=:B1)
17 - filter( IS NOT NULL)
19 - filter("SUCCESSOR_ID"=:B1)
20 - filter( IS NOT NULL)
22 - access("CP_TAX_AUTHORITY_ID"=:B1)
23 - filter( IS NOT NULL)
25 - access("CP_PRIM_REGULATOR_ID"=:B1)
26 - filter( IS NOT NULL)
29 - filter("DUPLICATE_OF_ID"=:B1)
30 - filter( IS NOT NULL)
33 - filter("REG_AUTHORITY_ID"=:B1)It took just 2.20 seconds, but why does it causes more CPU resource ?
We are about to plugin new module in this database, hence ONS table is partitioned, its partitioned on column PROVIDER which seperates existing and new module in to different partitions which makes easier for loading wihout affecting existing module data(We also make about to load partition local indexes to unusable state). Also this table is the parent table for about 6 child tables. So we decided to partition even child tables by adding PROVIDER column to all child tables and partition on this column. Parent-Child relationship is built upon ID column in all the tables.
All the sql's will be altered to use PROVIDER column for filtering old and new module data.
Do you think we are in right approach, I would be thankful if you can help me here for precise designing of this table.
As a side thought - and one I would have to investigate - since you have declared a number of inddexes with "case insensitive sorting" - is is possible that you could work around this idea to drop a few of the existing indexes on "lower(column)" and use case-insensitive indexes for these comparisons ?Will test it in development database, but what is the performance improvement prediction? And please let me know your suspects which claims "lower(column)" should be avoided and use case-insensitive indexes.
Anyway we are implementing Text-Index on this table and drop all the unwanted indexes.
I've written a short note on my blog about the "exists subquery" and the varying cost of the tablescane linesI am regular reader of your blog, after seeing your test case i understood the concept crystal clear. Thanks a lot.... -
Avoid distinct clause in the query
hi i have a query from a single table using distinct clause and has columns (a,b,c,d,e,f,g,h,i)
eg: select distinct a,b ,c,d from table
where a<>0 and b<>0 and c<>0 and d<>0 and e=o and f=0 and g=0 and h=0 and i=0 ;
when i see the execution plan with out distinct... it performs a bit faster.
how do i remove distinct clause and make the query perform better
this particular query is used as inline view in my vieiw . it is used in from clause .
please suggest
second question.... iam getting bitmap index to rowid conversion ...is this good? does it hamper performance . how to avoid this?
regards
raj
Edited by: raj_fresher on Jul 17, 2009 7:48 AMHi Raj
what is e in the query ?It is the column name you provided yourself in your own unformatted example.
After 400+ posts I thought you would understand that it's not that hard to put this exact tag => (yes, 6 characters, 4 letters between 2 curly brackets) before and after your code examples or sample data or explain plans.
That way you maintain formatting and improve readability for us poor readers by magnitudes.
But, I'm sure you'll succeed as well as all the others who can.
I always look on the bright side.
Example:
Earlier this week another Raj also finally got enlightened about it, and his life has since then changed forever!
+He drives a Bentley now, you know+ ;) -
How to avoid BPEL operations corrupting namespaces
Hi
I am new to BPEL and XML but I'm having a problem with the seemingly automatic behaviour of the Oracle BPEL engine.
I invoke a Web service which returns a valid XML document with namespaces declared inside the SOAP wrapper.
When I execute the BPEL outlined below the reply generated has lost the namespace declarations resulting in an invalid response to the BPEL service consumer.
I can achieve the correct namespaces by using a Transform step rather than the Copy, but should a transformation be required?
Is there an alternative approach?
Roy
The BPEL logic
<invoke name="retrievePolicy" partnerLink="AlphaCoreService"
portType="ns1:AlphaCoreService" operation="retrieveFullPolicy"
inputVariable="Invoke_1_retrieveFullPolicy_InputVariable"
outputVariable="Invoke_1_retrieveFullPolicy_OutputVariable"/>
<assign name="Assign_2">
<copy>
<from variable="Invoke_1_retrieveFullPolicy_OutputVariable"
part="parameters"
query="/ns2:retrieveFullPolicyResponseElement/ns2:result/ns2:pom"/>
<to variable="outputVariable" part="payload"
query="/client:getPolicyProcessResponse/client:pom"/>
</copy>
</assign>
<reply name="replyOutput" partnerLink="client" portType="client:getPolicy"
operation="process" variable="outputVariable"/>
The retrievePolicy response supplies this document to BPEL ....
<?xml version="1.0" encoding="windows-1252" ?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns0="http://service.ws.core.alpha.web.aif.cgi.com/types/"
xmlns:ns1="http://xpom.ws.core.alpha.web.aif.cgi.com">
<env:Body>
<ns0:retrieveFullPolicyResponseElement>
<ns0:result>
<ns0:errors xsi:nil="1"/>
<ns0:pom>
<ns1:contractId>7140</ns1:contractId>
<ns1:policyRef>POL7140</ns1:policyRef>
etc.
<ns1:version>
<ns1:systemStartDate>2009-06-10T15:33:48.000+01:00</ns1:systemStartDate>
<ns1:changeDescription xsi:nil="1"/>
etc.
</ns1:version>
<ns1:vehicleArray xsi:type="ns1:Vehicle">
<ns1:userModified>ROYC</ns1:userModified>
<ns1:uniqueReference>abc123A</ns1:uniqueReference>
etc.
<ns1:makeModel>17532001</ns1:makeModel>
<ns1:regNo>abc123A</ns1:regNo>
</ns1:vehicleArray>
</ns0:pom>
</ns0:result>
</ns0:retrieveFullPolicyResponseElement>
</env:Body>
</env:Envelope>
======================
The Copy activity results in an ="outputVariable" of this shape (note the namespace ns1 re-creation at the incorrect levels) ....
<outputVariable>
<part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="payload">
<getPolicyProcessResponse xmlns="http://xmlns.oracle.com/getPolicy">
<pom>
<ns1:contractId xmlns:ns1="http://xpom.ws.core.alpha.web.aif.cgi.com">7140</ns1:contractId>
<ns1:policyRef xmlns:ns1="http://xpom.ws.core.alpha.web.aif.cgi.com">POL7140</ns1:policyRef>
<ns1:version xmlns:ns1="http://xpom.ws.core.alpha.web.aif.cgi.com">
<ns1:systemStartDate>2009-06-10T15:33:48.000+01:00</ns1:systemStartDate>
<ns1:changeDescription xsi:nil="1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</ns1:version>
<ns1:vehicleArray xsi:type="ns1:Vehicle"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns1="http://xpom.ws.core.alpha.web.aif.cgi.com">
<ns1:makeModel>17532001</ns1:makeModel>
<ns1:regNo>abc123A</ns1:regNo>
</ns1:vehicleArray>
</pom>
</getPolicyProcessResponse>
</part>
</outputVariable>
=================================
Finally the Reply activity generates this XML to send back as a response - note the ns1:vehicle invalid reference
<?xml version="1.0" encoding="windows-1252" ?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<getPolicyProcessResponse xmlns="http://xmlns.oracle.com/getPolicy">
<result>success message</result>
<extra>extra tag</extra>
<pom>
<ns1:contractId xmlns:ns1="http://xpom.ws.core.alpha.web.aif.cgi.com">7140</ns1:contractId>
<ns1:policyRef xmlns:ns1="http://xpom.ws.core.alpha.web.aif.cgi.com">POL7140</ns1:policyRef>
<version>
<systemStartDate>2009-06-10T15:33:48.000+01:00</systemStartDate>
<changeDescription nil="1"/>
</version>
<vehicleArray type="ns1:Vehicle">
<makeModel>17532001</makeModel>
<regNo>abc123A</regNo>
</vehicleArray>
</pom>
</getPolicyProcessResponse>
</env:Body>
</env:Envelope>Hi Marc
Having consulted with a few colleagues, you are correct, this is a valid XML message after all.
The Oracle BPEL console however has a problem with it and generates the error
"Could not initiate the BPEL process because the input xml is not well formed, the reason is : Error parsing envelope Please correct the input xml."
The BPEL script has not only been initiated, but succesfully completed, so the message can only be referring to the SOAP message it got back from the BPEL process.
Oracle BPEL has also changed the namespaces, which is surely a corruption of the document that should need correcting by someone.
The Web service message had "pom" defined in the "http://service.ws.core.alpha.web.aif.cgi.com/types/" namespace and "contractID" and "vehicleArray" defined in the "http://xpom.ws.core.alpha.web.aif.cgi.com" namespace.
The BPEL reply message has "pom" and "vehicleArray" defined in the "http://xmlns.oracle.com/getPolicy" namespace, "contractID" correctly in the "http://xpom.ws.core.alpha.web.aif.cgi.com" namespace and the "http://service.ws.core.alpha.web.aif.cgi.com/types/" namespace has completely disappeared.
I can't see what I've done to generate the corruption, so surely this must be an Oracle defect?
Roy -
Distinct operation using GROUP BY
I was doing some research on retrieving Duplicate records in a table.
create table x
(empid number,
empname varchar2(50)
insert into x values (1,'John');
insert into x values (2,'Reynolds');
insert into x values (3,'Harrison');
insert into x values (1,'Kate');
insert into x values (2,'Hans');
SQL> select * from x;
EMPID EMPNAME
1 John
2 Reynolds
3 Harrison
1 Kate
2 Hans
SQL> select empid from x group by empid; ------ Query 1
EMPID
1
2
3
SQL> select min(empid) from x group by empid; ------ Query 2
MIN(EMPID)
1
2
3
SQL> select * from x where empid not in
2 (select min(empid) from x group by empid); -------- Query 3
no rows selectedI understand how Query 1 and Query 2 retrieves distinct values. Query 3 can't fetch duplicate values because it is equivalent to
SQL> select * from x where empid not in
2 (select distinct(empid) from x);
no rows selectedAm i right?
From various OTN threads, i gathered that a query using ROWID should be used for retrieving duplicate rows.
Something like
select * from x where rowid not in
(select min(rowid) from x group by empid); ------------- Query 4How come this query (Query 4) works and Query 3 doesn't?Hi,
Y.Ramlet wrote:
I was doing some research on retrieving Duplicate records in a table.
create table x
(empid number,
empname varchar2(50)
insert into x values (1,'John');
insert into x values (2,'Reynolds');
insert into x values (3,'Harrison');
insert into x values (1,'Kate');
insert into x values (2,'Hans');
SQL> select * from x;
EMPID EMPNAME
1 John
2 Reynolds
3 Harrison
1 Kate
2 Hans
SQL> select empid from x group by empid; ------ Query 1
EMPID
1
2
3
SQL> select min(empid) from x group by empid; ------ Query 2
MIN(EMPID)
1
2
3
SQL> select * from x where empid not in
2 (select min(empid) from x group by empid); -------- Query 3
no rows selectedI understand how Query 1 and Query 2 retrieves distinct values. Query 3 can't fetch duplicate values because it is equivalent to
SQL> select * from x where empid not in
2 (select distinct(empid) from x);
no rows selectedAm i right?Yes, you're right. Query 3 and Query 4 get the same results (or lack of results) by different ways.
From various OTN threads, i gathered that a query using ROWID should be used for retrieving duplicate rows.
Something like
select * from x where rowid not in
(select min(rowid) from x group by empid); ------------- Query 4How come this query (Query 4) works and Query 3 doesn't?They both work; they get different results because they are doing different things.
ROWID is unique; empid is not. When you "GROUP BY empid", any group with more than one member will have ROWIDs that are not equal to MIN (ROWID) for that group. -
How to avoid click/operation on page when an event is already in queue
Hi,
I have an app, in which we have a many fields which have patial submit.
How can we avoid/stop user form taking any action of page untilll the previous request is responded back.
-NageshIn property inspector go to behavior section and set Blocking = true
An Blocking attribute which if set to TRUE the component will start blocking user input when the action is initiated. The blocking will stop when a response is received from the server. -
DML operations on multiple views
Hi all.
I can't understand updateing the data on views which created by multiple table joining. Which columns I can update and why I'm getting
ORA-01779: cannot modify a column which maps to a non key-preserved table error??
Can anybody show me explanation with examples??
Thanks...Modifying a Join View
A modifiable join view is a view that contains more than one table in the top
level FROM clause of the SELECT statement, and that does not contain any of
the following:
- DISTINCT operator
- aggregate functions: AVG, COUNT, GLB, MAX, MIN, STDDEV, SUM, or VARIANCE
- set operations: UNION, UNION ALL, INTERSECT, MINUS
- GROUP BY or HAVING clauses
- START WITH or CONNECT BY clauses
- ROWNUM pseudocolumn
With some restrictions, you can modify views that involve joins. If a view is
a join on other nested views, then the other nested views must be mergeable
into the top level view.
The examples in following sections use the EMP and DEPT tables. These examples
work only if you explicitly define the primary and foreign keys in these
tables, or define unique indexes. Following are the appropriately constrained
table definitions for EMP and DEPT:
CREATE TABLE dept
deptno NUMBER(4) PRIMARY KEY,
dname VARCHAR2(14),
loc VARCHAR2(13)
CREATE TABLE emp
empno NUMBER(4) PRIMARY KEY,
ename VARCHAR2(10),
job varchar2(9),
mgr NUMBER(4),
hiredate DATE,
sal NUMBER(7,2),
comm NUMBER(7,2),
deptno NUMBER(2),
FOREIGN KEY (DEPTNO) REFERENCES DEPT(DEPTNO)
You could also omit the primary and foreign key constraints listed above, and
create a UNIQUE INDEX on DEPT (DEPTNO) to make the following examples work.
CREATE OR REPLACE VIEW emp_dept AS
SELECT empno, ename, sal, e.deptno, dname, loc
FROM EMP e, DEPT d
WHERE e.deptno = d.deptno;
Key-Preserved Tables
The concept of a key-preserved table is fundamental to understanding the
restrictions on modifying join views. A table is key preserved if every key of
the table can also be a key of the result of the join. So, a key-preserved
table has its keys preserved through a join.
Note: It is not necessary that the key or keys of a table be selected for it
to be key preserved. It is sufficient that if the key or keys were selected,
then they would also be key(s) of the result of the join.
Attention: The key-preserving property of a table does not depend on the
actual data in the table. It is, rather, a property of its schema and not of
the data in the table. For example, if in the EMP table there was at most one
employee in each department, then DEPT.DEPTNO would be unique in the result of
a join of EMP and DEPT, but DEPT would still not be a key-preserved table.
If you SELECT all rows from EMP_DEPT view, the results are:
SELECT * FROM EMP_DEPT;
EMPNO ENAME SAL DEPTNO DNAME LOC
7369 SMITH 800 20 RESEARCH DALLAS
7499 ALLEN 1600 30 SALES CHICAGO
7521 WARD 1250 30 SALES CHICAGO
7566 JONES 2975 20 RESEARCH DALLAS
7654 MARTIN 1250 30 SALES CHICAGO
7698 BLAKE 2850 30 SALES CHICAGO
7782 CLARK 2695 10 ACCOUNTING NEW YORK
7788 SCOTT 3000 20 RESEARCH DALLAS
7839 KING 5500 10 ACCOUNTING NEW YORK
7844 TURNER 1500 30 SALES CHICAGO
7876 ADAMS 1100 20 RESEARCH DALLAS
7900 JAMES 950 30 SALES CHICAGO
7902 FORD 3000 20 RESEARCH DALLAS
7934 MILLER 1430 10 ACCOUNTING NEW YORK
14 rows selected.
In this view, EMP is a key-preserved table, because EMPNO is a key of the EMP
table, and also a key of the result of the join. DEPT is not a key-preserved
table, because although DEPTNO is a key of the DEPT table, it is not a key of
the join.
DML Statements and Join Views
=============================
!!!!!! IMPORTANT !!!!!! IMPORTANT !!!!!! IMPORTANT !!!!!! IMPORTANT !!!!!!
Any UPDATE, INSERT, or DELETE statement performed on a join view can modify
only *** one *** underlying base table.
!!!!!! IMPORTANT !!!!!! IMPORTANT !!!!!! IMPORTANT !!!!!! IMPORTANT !!!!!!
UPDATE Statements:
The following example shows an UPDATE statement that successfully modifies the
EMP_DEPT view:
UPDATE emp_dept
SET sal = sal * 1.10
WHERE deptno = 10;
The following UPDATE statement would be disallowed on the EMP_DEPT view:
UPDATE emp_dept
SET loc = 'BOSTON'
WHERE ename = 'SMITH';
This statement fails with an ORA-01779 error (cannot modify a column which
maps to a non key-preserved table), because it attempts to modify the
underlying DEPT table, and the DEPT table is not key preserved in the EMP_DEPT
view.
In general, all modifiable columns of a join view must map to columns of a
key-preserved table. If the view is defined using the WITH CHECK OPTION
clause, then all join columns and all columns of repeated tables are not
modifiable.
So, for example, if the EMP_DEPT view were defined using WITH CHECK OPTION,
the following UPDATE statement would fail:
UPDATE emp_dept
SET deptno = 10
WHERE ename = 'SMITH';
The statement fails because it is trying to update a join column.
DELETE Statements:
You can delete from a join view provided there is one and only one
key-preserved table in the join.
The following DELETE statement works on the EMP_DEPT view:
DELETE FROM emp_dept
WHERE ename = 'SMITH';
This DELETE statement on the EMP_DEPT view is legal because it can be
translated to a DELETE operation on the base EMP table, and because the EMP
table is the only key-preserved table in the join.
In the following view, a DELETE operation cannot be performed on the view
because both E1 and E2 are key-preserved tables:
CREATE VIEW emp_emp AS
SELECT e1.ename, e2.empno, deptno
FROM emp e1, emp e2
WHERE e1.empno = e2.empno;
If a view is defined using the WITH CHECK OPTION clause and the keypreserved
table is repeated, then rows cannot be deleted from such a view:
CREATE VIEW emp_mgr AS
SELECT e1.ename, e2.ename mname
FROM emp e1, emp e2
WHERE e1.mgr = e2.empno
WITH CHECK OPTION;
No deletion can be performed on this view because the view involves a
self-join of the table that is key preserved.
INSERT Statements:
The following INSERT statement on the EMP_DEPT view succeeds:
INSERT INTO emp_dept (ename, empno, deptno)
VALUES ('KURODA', 9010, 40);
This statement works because only one key-preserved base table is being
modified (EMP), and 40 is a valid DEPTNO in the DEPT table (thus satisfying
the FOREIGN KEY integrity constraint on the EMP table).
An INSERT statement like the following would fail for the same reason that
such an UPDATE on the base EMP table would fail: the FOREIGN KEY integrity
constraint on the EMP table is violated.
INSERT INTO emp_dept (ename, empno, deptno)
VALUES ('KURODA', 9010, 77);
The following INSERT statement would fail with an ORA-1776 error (cannot
modify more than one base table through a view).
INSERT INTO emp_dept (empno, ename, loc)
VALUES (9010, 'KURODA', 'BOSTON');
An INSERT cannot, implicitly or explicitly, refer to columns of a
non-key-preserved table. If the join view is defined using the WITH CHECK
OPTION clause, then you cannot perform an INSERT to it.
Using the UPDATABLE_ COLUMNS Views
The following views can assist you when modifying join views:
View Name Description
USER_UPDATABLE_COLUMNS Shows all columns in all tables and views in the
users schema that are modifiable.
DBA_UPDATABLE_COLUMNS Shows all columns in all tables and views in the
DBA schema that are modifiable.
ALL_UPDATABLE_COLUMNS Shows all columns in all tables and views that are
modifiable. -
How to avoid duplicate BOM Item Numbers?
Hello,
is there a way to avoid duplicate BOM Item Numbers (STPO-POSNR) within one BOM?
For Routings I could avoid duplicate Operation/Activity Numbers with transaction OP46 by setting T412-FLG_CHK = 'X' for Task List Check. Is there an aquivalent for BOMs?
Regards,
Helmut GanteHello,
is there a way to avoid duplicate BOM Item Numbers (STPO-POSNR) within one BOM?
For Routings I could avoid duplicate Operation/Activity Numbers with transaction OP46 by setting T412-FLG_CHK = 'X' for Task List Check. Is there an aquivalent for BOMs?
Regards,
Helmut Gante -
When using ‘insert into table2 select distinct field from table1′ and table2 contains a field with a default value sys_guid(), the distinct operator does not seem to work ! This was tested on Oracle 10.2.0.4 on 64 bit linux. See the following SQL code to prove it :
create table table1 (field1 varchar2(100));
insert into table1 (field1) values (‘value1′);
insert into table1 (field1) values (‘value1′);
insert into table1 (field1) values (‘value2′);
– distinct and to_char(sysdate) function gives the correct 2 rows (‘value1′ and ‘value2′)
create table table2 (field1 varchar2(100), field2 raw(16) default to_char(sysdate, ‘hh’));
insert into table2(field1) select distinct field1 from table1;
select * from table2;
rollback;
drop table table2 purge;
– distinct and sys_guid function gives 3 rows (twice ‘value1′ !!) instead of 2
create table table2 (field1 varchar2(100), field2 raw(16) default sys_guid());
insert into table2(field1) select distinct field1 from table1;
select * from table2;
rollback;
drop table table2 purge;
– with group by : no problem
create table table2 (field1 varchar2(100), field2 raw(16) default sys_guid());
insert into table2(field1) select field1 from table1 group by field1;
select * from table2;
rollback;
drop table table2 purge;
drop table table1 purge;It looks like I can reproduce (on XE 10.2.0.1), with or without using a default for sys_guid:
SQL> select banner from v$version where rownum=1;
BANNER
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
1 row selected.
SQL> create table table1 (field1 varchar2(100));
Table created.
SQL> insert into table1 (field1) values ('value1');
1 row created.
SQL> insert into table1 (field1) values ('value1');
1 row created.
SQL> insert into table1 (field1) values ('value2');
1 row created.
SQL> -- distinct and to_char(sysdate) function gives the correct 2 rows (‘value1' and ‘value2')
SQL> create table table2 (field1 varchar2(100), field2 raw(16) default to_char(sysdate, 'hh'));
Table created.
SQL> insert into table2(field1) select distinct field1 from table1;
2 rows created.
SQL> select * from table2;
FIELD1 FIELD2
value1 11
value2 11
2 rows selected.
SQL> drop table table2 purge;
Table dropped.
SQL> -- distinct and sys_guid function gives 3 rows (twice ‘value1' !!) instead of 2
SQL> create table table2 (field1 varchar2(100), field2 raw(16) default sys_guid());
Table created.
SQL> insert into table2(field1) select distinct field1 from table1;
3 rows created.
SQL> select * from table2;
FIELD1 FIELD2
value1 5AF743C0FD484D578E84276C875C5BC1
value1 725ABE6066BF42E2A78406BD549D9E85
value2 CC43E3C688AF428B885A0F4EA24482CB
3 rows selected.
SQL> drop table table2 purge;
Table dropped.
SQL> -- without using DEFAULT, here Max is right (see posts below)
SQL> create table table2 (field1 varchar2(100), field2 raw(16));
Table created.
SQL> insert into table2(field1, field2) select distinct field1, sys_guid() from table1;
3 rows created.
SQL> select * from table2;
FIELD1 FIELD2
value1 7B277A2068AF468EBC06E33F6700B9E3
value1 9644C1C8A909489F98B51531BDD282D9
value2 8707FD2E6AB94EA7810D8D4AB19AB091
3 rows selected.
SQL> drop table table2 purge;
Table dropped.
SQL> -- with group by : no problem
SQL> create table table2 (field1 varchar2(100), field2 raw(16) default sys_guid());
Table created.
SQL> insert into table2(field1) select field1 from table1 group by field1;
2 rows created.
SQL> select * from table2;
FIELD1 FIELD2
value2 202A87C86EF446D8915B3C976385D68F
value1 484625A675524FA09CC393A78411B38A
2 rows selected.
SQL> drop table table2 purge;
Table dropped.
SQL> drop table table1 purge;
Table dropped.Edited by: hoek on Feb 18, 2010 11:29 AM -
Hi
I have problem with Distinct clause in Physical SQL getting generated. It has distinct by defaul.
I searched through this blog and found in BMM-->Content Tab and "Select Disctinct" is not check for any of my tables used in Report/Query. Still it fires distince.
Can anybody help me here pls..to avoid Distinct caluse in Physical SQL
Thanks!Hi
thanks for the quick reply.
I don't have any measures there on report, and it is select few columns in report from fact and dimension values...
Could you please help here
Thanks in advance. -
How to detect SQL type to avoid SQL injection
Hi,
I work in a gsm company and we develop a program to make trend analysis. Users of this program know how to write SQL statements. I want them to write specific sql statements as input statement of my program (SELECT ... from ...). Mostly SELECT statements. I have PL/SQL blocks and dynamic SQL's in my program. I get user defined SQL statements and execute them as Dynamic Sql's.
Here is the problem: I need to understant what type of SQL they give as input parameter of my program to avoid wrong operations (DELETE, TRUNCATE, DROP...)
First i thought about the REGEXP to understant if its a SELECT SQL or DELETE SQL..
Is there any recommend about this problem? Does Oracle have any procedure to detect it?
Thanksacadet wrote:
BluShadow wrote:
a_yavuz wrote:
I work in a gsm company and we develop a program to make trend analysis. Users of this program know how to write SQL statements. I want them to write specific sql statements as input statement of my program (SELECT ... from ...). What is the specification behind these "specific sql statements"?
This should allow you to define a lexicon of permitted terms within the language and, if it's not too complex, you could then write a lexicon/language parser to validate each of the statements submitted, thus ensuring they cannot permit anything that is not expected. It may not be a simple tasks, depending on how complex your sub-language of SQL is, but if you are wanting to truly allow users to use SQL rather than some user interface that restricts input and prevents injection, then it's one of the safer ways of doing it.Hi,
This is exactly what the database does through the technique of grants. Why reinvent the wheel.
AndreAssuming you're only talking about access to database objects etc. and that the database user shouldn't be able to perform those tasks through a controlled interface. What if they should be able to e.g. delete records, but only through a controlled screen, whereas the selection of data is to be flexible and permit SQL.
The original question sounds more like he wants to permit a certain subset of the SQL language as he says he wants them to write "specific sql statements". If there is a definition of what form those statements should take then a restricted lexicon parser could be written to cater for those. -
I have a problem that I'm sure has a simple solution.
I'm trying to insert unique records into one table from another table that has duplicates. However, I cant use the sequence for my primary key with the distinct operator. eg.:
INSERT INTO unique_table (pkey,fkey,name)
SELECT DISTINCT seq.nextval, col1, col2
FROM dup_table;
it is the combination of fields col1 and col2 that must be unique. Please help.correct, the distinct clause returns unique rows. you could
create a trigger for your table then just insert your dup_tab
into the uniq_tab
insert into uniq_tab (select distinct col1,col2 from dup_tab);
with the trigger, your dup_tab will be populated with uniq
rows on col1,col2
Hope this helps
Jay
Maybe you are looking for
-
Error while trying to import external web service in webdynpro java
Hi, I am trying to import external webservice in webdynpro java using adaptive webservice model, but i am getting below error..i tried some other external webservices but those are working fine....I wanted to know if there is any issue with this wsdl
-
Outbound delivery creation in case of stock transfer scheduling agreement.
Dear All, We are creating the Scheduling Agreement for the stock transfer between the 2 plants . and for the stock transfer we are following the outbound delivery route (641 movement type) Issue is as below:- suppose in the scheduling Agreement I hav
-
How to modify a Master Slide on a single page.
I am wondering how to modify the master slide on a particular slide. Like in InDesign when you hold shift + ctrl you can select items from the master page and modify them on that particular page only, without making the changes to every page where th
-
Runtime Crash after Upgrading to CR2008
I've upgraded my .NET application from VS2005 w/CRXIR2 SP4 to VS2008 w/CR2008 SP1. The program runs fine in the debugger. By this I mean the reports come up, etc. and there are no visble errors in the build or running in debug mode. However, when I i
-
i need help i can not change the password it does that shaking boz thingy even thoough i put the correct password in