Scalar Correlated Subquery Problem
SELECT a.unit_id
, NVL((
SELECT COUNT(*)
FROM (
SELECT b.unit_id
, b.rfq_id
, b.vendor_id
FROM RFQ_DISPATCHED b
WHERE b.unit_id a.unit_id
AND b.vendor_id = a.vendor_id
AND b.rfq_id = a.rfq_id
GROUP BY a.business_unit, a.rfq_id, a.vendor_id)),0) AS bid_qty
FROM rfq_disp_hdr a
WHERE a.unit_id = '00021'
Oracle won't let me do this. Is it because it's correlated to a Query View? I know I can just create a view as a work around and then do a select on the view but any other suggestions on how to handle it?
Thanks all!!
Hi,
Damorgan is right; whenever you have a question, you should post:
(1) The version of Oracle (and any other relevant software) you're using
(2) A little sample data (just enough to show what the problem is) from all the relevant tables
(3) The results you want from that data, and an explanation of how you get from the data to the results
(4) Your best attempt so far (formatted) (You posted this, but since it's unformated, it's very hard to read.)
(5) The full error message (if any), including line number
Executable SQL statements (like "CREATE TABLE AS ..." or "INSERT ..." statements) are best for (2).
If you can present your problem using commonly available tables (for example, tables in scott schema, or views in the data dictionary), then you can omit (2).
Formatted tabular output is okay for (3). Type these 6 characters:
{code}
(small letters only, inside curly brackets) before and after formatted text, to preserve spacing.
You've been using this forum longer than I have; you should know this by now.
It looks like the immediate problem is that you're trying to correlate a sub-query to its grandparent, not its parent. That is, the scalar sub-query could be correlated to the main query (its parent), and the in-line view could be corellated to the scalar sub-query (its parent), but the in-line view can not be correlated to the main query.
Why are you using an in-line view? It looks like what you're trying to do is:
SELECT a.unit_id
, NVL ( (
SELECT COUNT(*)
FROM RFQ_DISPATCHED b
WHERE b.unit_id a.unit_id
AND b.vendor_id = a.vendor_id
AND b.rfq_id = a.rfq_id
GROUP BY a.business_unit
, a.rfq_id
, a.vendor_id
, 0
) AS bid_qty
FROM rfq_disp_hdr a
WHERE a.unit_id = '00021'but I think if correct this error, you'll just get another one. GROUPing by correlated values is very suspicious. So is doing a GROUP BY in a scalar sub-query like you're doing.
If you really want to solve this problem, you'll have to post the information requested.
Similar Messages
-
JDOQL Correlated Subquery - Bad SQL
Hi,
When I execute a JDOQL correlated subquery, the generated SQL is either
invalid or incorrect. Exactly what happens depends on the exact query, and
on the target database type, but I believe it all stems from the same
problem, which has to do with table aliasing.
If you need further details to reproduce this, please let me know. I'll be
glad to help in any way I can to get this situation remedied quickly, as I
am depending on this functionality. I have a test application to
demonstrate the problem.
I'm using Kodo 3.3.3 and application identity.
Paul Mogren
CommerceHubFor the record, this is in part due to a bug in Kodo's SQL92 joining.
See http://bugzilla.solarmetric.com/show_bug.cgi?id=1156
-Patrick
Paul Mogren wrote:
Certainly... Here's a simple example using Microsoft's JDBC Driver for SQL
Server 2000, and kodo.jdbc.sql.SQLServerDictionary, which produces invalid
SQL.
The query:
pm.newQuery(Container.class,
"(select from Entry entry where entries.contains(entry) &&
entry.containedId != 1).isEmpty()");
The classes:
class Contained {
private int id; //pk
class Container {
private int id; //pk
private Set entries = new HashSet(); //<Entry>
class Entry {
private int containerId; //pk
private int containedId; //pk
private Container container; //persistent-redundant
private Contained contained; //persistent-redundant
The result:
Incorrect syntax near the keyword 'WHERE'. {prepstmnt 31598780 SELECT
t0.container_id, t0.lock FROM WHERE (NOT EXISTS (SELECT DISTINCT
t2.contained_id, t2.container_id FROM dbo.entry t2 WHERE (t1.contained_id
= t2.contained_id AND t1.container_id = t2.container_id AND
t2.contained_id <> ?) AND t0.container_id = t1.container_id))
[params=(int) 1]} [code=156, state=HY000]
Patrick Linskey wrote:
Hi Paul,
Kodo's correlated subquery support does have some known limitations. Can
you post a sample JDOQL statement + corresponding SQL statement?
-Patrick
Paul Mogren wrote:
Hi,
When I execute a JDOQL correlated subquery, the generated SQL is either
invalid or incorrect. Exactly what happens depends on the exact query, and
on the target database type, but I believe it all stems from the same
problem, which has to do with table aliasing.
If you need further details to reproduce this, please let me know. I'll be
glad to help in any way I can to get this situation remedied quickly, as I
am depending on this functionality. I have a test application to
demonstrate the problem.
I'm using Kodo 3.3.3 and application identity.
Paul Mogren
CommerceHub -
How does oracle execute a correlated subquery .... some confusion
How does oracle 10g execute a correlated subquery?
I read some articles online & i am a little confused.
example:
select * from emp e
where e.deptno in (select d.deptno from dept d
where e.deptno = d.deptno);
My questions .......
1.In the above example, does oracle read the entire outer table first and then run the inner query using the rows returned by the outer query?
I read in some articles that they execute simultaneously.
How does this work?
2.Should the inner query have lesser amount of rows compared to the outer query for a good performance?
3.Can every correlated subquery be converted to a join and if so which one to use?
Truly appreciate any inputs on how oracle executes it at the backend.
Thanks in advance.user10541890 wrote:
How does oracle 10g execute a correlated subquery?
I read some articles online & i am a little confused.
example:
select * from emp e
where e.deptno in (select d.deptno from dept d
where e.deptno = d.deptno);
My questions .......
1.In the above example, does oracle read the entire outer table first and then run the inner query using the rows returned by the outer query?
I read in some articles that they execute simultaneously.
How does this work?SQL is not a procedural language. SQL code specifies what the system sill do, not how the system wlll do it; that's entirely up to the system.
What does it matter to you whether the two are done together, or if one is completed before the other begins?
The system will probably choose to run ucorellated subqueiris only once, and correlated queries multiple times as needed.
2.Should the inner query have lesser amount of rows compared to the outer query for a good performance?That usually doesn't matter.
It some cases, you may want to consider whether the subquery is correlated or not. If the subquery is very costly, and produces, say, 1 million rows, but you know the main query will only produce about 5 rows, then you may want to do a correlated subquery rather than an uncorrelated one.
3.Can every correlated subquery be converted to a join and if so which one to use?I believe so.
Use whichever is easier to code and debug. That will change depnding on the data and the requirements.
If performance is an issue, try different ways. Usually, where I've noticed a big difference, join was fastest.
By the way, it's unusual to have a correlated IN-subquery.
Usually IN-subqueris are uncorrelated, like this:
select *
from emp e
where e.deptno in ( select d.deptno
from dept d
);(This and the queries below produce the same resutls as your original query.)
Correlated subqueries are usually used for scalar subqueries or EXISTS subqueries, like this:
select *
from emp e
where EXISTS ( select d.deptno
from dept d
where e.deptno = d.deptno
);To do the same thing with a join:
select e.*
from emp e
join dept d on e.deptno = d.deptno
;assuming dept.deptno is unique. -
Top n Analysis using correlated subquery
Please explain this query. It is doing top n analysis using correlated subquery. I need explaination of execution of this query.
Select distinct a.sal
From emp a
where 1=(select count ( distinct b.sal) from emp b
where a.sal <=b.sal)
Thanks in advanceTry breaking the query down and rewriting it in order to follow the logic;
SQL> --
SQL> -- Start by getting each salary from emp along with a count of all salaries in emp
SQL> --
SQL> select a.sal,
(select count (distinct b.sal) from scott.emp b ) count_sal
from scott.emp a
order by 1 desc
SAL COUNT_SAL
5000 12
3000 12
3000 12
2975 12
2850 12
2450 12
1600 12
1500 12
1300 12
1250 12
1250 12
1100 12
950 12
800 12
14 rows selected.
SQL> --
SQL> --Add a condition to the count for only salaries below or equal to the current salarySQL> --
SQL> select a.sal,
(select count (distinct b.sal) from scott.emp b where a.sal <=b.sal) rank_sal
from scott.emp a
order by 1 desc
SAL RANK_SAL
5000 1
3000 2
3000 2
2975 3
2850 4
2450 5
1600 6
1500 7
1300 8
1250 9
1250 9
1100 10
950 11
800 12
14 rows selected.
SQL> --
SQL> -- Add a condition to only pick the nth highest salary
SQL> --
SQL> select a.sal,
(select count (distinct b.sal) from scott.emp b where a.sal <=b.sal) rank_sal
from scott.emp a
where (select count (distinct b.sal) from scott.emp b where a.sal <=b.sal) = 4
SAL RANK_SAL
2850 4
1 row selected.Hope this helps. -
SQL Bug in "Minus" in correlated subquery presence of index
(Oracle Database 11g Release 11.2.0.1.0)
Below, there is a small example that shows the bug. Further below,
there are some more comments.
drop table Country;
create table Country
(code VARCHAR2(4) constraint countrykey PRIMARY KEY,
name VARCHAR2(35));
-- if the key constraint is not given, the bug does not occur
drop table City;
create table City
(name VARCHAR2(35),
country VARCHAR2(4),
population number);
drop table Locatedon;
create table Locatedon
(city VARCHAR2(35),
country VARCHAR2(4),
island VARCHAR2(35));
insert into country values('E','Spain');
insert into country values('F','France');
insert into country values('S','Sweden');
insert into country values('GB','Sweden');
insert into city values('Ajaccio','F',53500);
insert into city values('Paris','F',2152423);
insert into city values('Palma','E',322008);
insert into city values('Madrid','E',3041101);
insert into city values('Stockholm','S',711119);
insert into city values('London','GB',6967500);
insert into locatedon values('Ajaccio','F','Corse');
insert into locatedon values('Palma','E','Mallorca');
insert into locatedon values('London','GB','Great Britain');
-- all countries that have a city that is not located on
-- some island: should be E, F, S.
Select c.name
From country c
Where exists
((Select name
From city
Where city.country=c.code)
minus
(Select city
From locatedon
Where locatedon.country=c.code)
-- wrong answer: only Sweden; Spain and France not in the answer!
select distinct country from
((Select name, country
From city)
minus
(Select city, country
From locatedon)
-- correct answer: E, F, S
Comments:
The bug has been found by students in our SQL course.
Using a larger database from that course, the bug can be reproduced
(same queries as above) at
http://www.semwebtech.org/sqlfrontend/
(wrong: 142 answers, correct: 154 answers)
During reducing it to a simple sample, there were some interesting
observations: trying with smaller and simpler tables (without the keys)
and synthetic data, the bug did not occur immediately. When
restating the query after about one day, the bug occurred. Obviously,
Oracle creates some index on its own in course of its internal
optimization that (or more exactly, its usage) exhibits the bug. The
query plan (showed in SQL Developer) was the same before and after.
WolfgangThere's a typo in the test data - GB should presumably not be in Sweden. However....
the bug did not occur immediatelyIt's possible. But what would have almost certainly happened is that the execution plan DID change at some point. There are various reasons why it might not be immediate.
Obviously, Oracle creates some index on its own in course of its internal optimizationFar from obvious, what are you on about?
The query plan was the same before and afterBet you it wasn't.
A clear illustration of the issue and indication that it must be a bug is below.
Simply by hinting a different access method, we can change the result. Therefore, bug.
See [url http://support.oracle.com]Oracle Support and search for "wrong results".
Please raise with Oracle Support to get confirmation of bug.
There have been so many wrong results bugs recently, it's getting ridiculous.
It's a real issue, IMHO.
If you can't trust the DB to get your data right....
Note that the query plan is very much NOT the same and it is the difference in query plan which s that is the root cause of the bug.
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
SQL> SELECT c.name
2 FROM country1 c
3 WHERE exists ((SELECT name
4 FROM city1
5 WHERE city1.country=c.code)
6 MINUS
7 (SELECT city
8 FROM locatedon1
9 WHERE locatedon1.country=c.code));
NAME
Sweden
SQL> SELECT /*+ full(c) */
2 c.name
3 FROM country1 c
4 WHERE exists ((SELECT name
5 FROM city1
6 WHERE city1.country=c.code)
7 MINUS
8 (SELECT city
9 FROM locatedon1
10 WHERE locatedon1.country=c.code));
NAME
Spain
France
Sweden
SQL> explain plan for
2 SELECT c.name
3 FROM country1 c
4 WHERE exists ((SELECT name
5 FROM city1
6 WHERE city1.country=c.code)
7 MINUS
8 (SELECT city
9 FROM locatedon1
10 WHERE locatedon1.country=c.code));
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 156929629
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 27 | 12 (25)| 00:00:01 |
| 1 | NESTED LOOPS | | | | | |
| 2 | NESTED LOOPS | | 1 | 27 | 12 (25)| 00:00:01 |
| 3 | VIEW | VW_SQ_1 | 6 | 24 | 10 (20)| 00:00:01 |
| 4 | MINUS | | | | | |
| 5 | SORT UNIQUE | | 6 | 138 | | |
| 6 | TABLE ACCESS FULL | CITY1 | 6 | 138 | 4 (0)| 00:00:01 |
| 7 | SORT UNIQUE | | 3 | 69 | | |
| 8 | TABLE ACCESS FULL | LOCATEDON1 | 3 | 69 | 4 (0)| 00:00:01 |
|* 9 | INDEX UNIQUE SCAN | COUNTRYKEY | 1 | | 0 (0)| 00:00:01 |
| 10 | TABLE ACCESS BY INDEX ROWID| COUNTRY1 | 1 | 23 | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
9 - access("VW_COL_1"="C"."CODE")
Note
- dynamic sampling used for this statement (level=4)
26 rows selected.
SQL> explain plan for
2 SELECT /*+ full(c) */
3 c.name
4 FROM country1 c
5 WHERE exists ((SELECT name
6 FROM city1
7 WHERE city1.country=c.code)
8 MINUS
9 (SELECT city
10 FROM locatedon1
11 WHERE locatedon1.country=c.code));
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 1378726376
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 23 | 14 (15)| 00:00:01 |
|* 1 | FILTER | | | | | |
| 2 | TABLE ACCESS FULL | COUNTRY1 | 4 | 92 | 4 (0)| 00:00:01 |
| 3 | MINUS | | | | | |
| 4 | SORT UNIQUE | | 1 | 23 | 5 (20)| 00:00:01 |
|* 5 | TABLE ACCESS FULL| CITY1 | 1 | 23 | 4 (0)| 00:00:01 |
| 6 | SORT UNIQUE | | 1 | 23 | 5 (20)| 00:00:01 |
|* 7 | TABLE ACCESS FULL| LOCATEDON1 | 1 | 23 | 4 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter( EXISTS ( (SELECT "NAME" FROM "CITY1" "CITY1" WHERE
"CITY1"."COUNTRY"=:B1)MINUS (SELECT "CITY" FROM "LOCATEDON1" "LOCATEDON1"
WHERE "LOCATEDON1"."COUNTRY"=:B2)))
5 - filter("CITY1"."COUNTRY"=:B1)
7 - filter("LOCATEDON1"."COUNTRY"=:B1)
Note
- dynamic sampling used for this statement (level=4)
27 rows selected.Just to show that it's related to query transformation:
SQL> SELECT /*+
2 no_query_transformation
3 */
4 c.name
5 FROM country1 c
6 WHERE exists ((SELECT name
7 FROM city1
8 WHERE city1.country=c.code)
9 MINUS
10 (SELECT city
11 FROM locatedon1
12 WHERE locatedon1.country=c.code));
NAME
Spain
France
Sweden
SQL> Edited by: Dom Brooks on Jun 30, 2011 2:50 PM -
Performance of using a Select For Update vs a correlated subquery
I was wondering wether or not it is more effecient to use the
Select ... For Update (with a cursor etc.) versus a correlated
subquery.
I can accomplish the same thing with either however performance
at our site is an issue.Use select for update cursor as that is faster as it updates
based on the rowid. One thing to keep in mind is that rowid is
session specific and the rows to be updated get locked so that
nobody else can update them till the lock is released. I have
had very good performance results with these cursors.
Good luck !
Sudha -
Difference between a regular subquery and a correlated subquery
Can someone explain EXACTLY what is a correlated subquery and could you give me an example? I'm taking an Oracle DBA class and I would appreciate your feedback. Thanks. :)
"Normal" subquery (the subquery is executed only once for the statement):
select name
from emp
where salary > (select avg(emp2.salary) from emp emp2);
Correlated subquery (it is executed for each row of the main query):
select name
from emp
where salary > (select avg(salary) from emp emp2
where emp2.deptno = emp.deptno);
Can someone explain EXACTLY what is a correlated subquery and could you give me an example? I'm taking an Oracle DBA class and I would appreciate your feedback. Thanks. :) -
Correlated subquery execution problem
Hi
In correlated subqueries which query executed first whether the inner query or outer query i.e while oracle processing the query
give me example
thanx
aspI would say the outer query would be executed first as the inner query is dependant upon that but I guess in some circumstances the CBO will turn this rule on its head
SQL> select ename from emp
2 where exists ( select null from dept where dept.deptno = emp.deptno )
3 /
ENAME
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
ENAME
JAMES
FORD
MILLER
14 rows selected.
Execution Plan
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=4 Card=14 Bytes=16
8)
1 0 NESTED LOOPS (SEMI) (Cost=4 Card=14 Bytes=168)
2 1 TABLE ACCESS (FULL) OF 'EMP' (TABLE) (Cost=3 Card=14 Byt
es=126)
3 1 INDEX (UNIQUE SCAN) OF 'PK_DEPT' (INDEX (UNIQUE)) (Cost=
1 Card=7 Bytes=21)
1 select ename from emp
2* where not exists ( select null from dept where dept.deptno = emp.deptno )
SQL> /
no rows selected
Execution Plan
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=4 Card=1 Bytes=12)
1 0 NESTED LOOPS (ANTI) (Cost=4 Card=1 Bytes=12)
2 1 TABLE ACCESS (FULL) OF 'EMP' (TABLE) (Cost=3 Card=14 Byt
es=126)
3 1 INDEX (UNIQUE SCAN) OF 'PK_DEPT' (INDEX (UNIQUE)) (Cost=
1 Card=7 Bytes=21) -
Correlated Subquery in ORDER BY
The following is a valid sql. But, what is meant by a correlated scalar subquery in the ORDER BY clause?
SELECT employee_id, last_name
FROM employees e
ORDER BY (SELECT department_name
FROM departments d
WHERE e.department_id=d.department_id);It is exactly the same in the ORDER BY clause as in any other part of a query. As biswabijay says, the correlated query is run once for each row in the result set.
In essence, the fileds selected from the correlated query are added to the result for each row, then evaluated in the appropriate context (e.g. compared in a WHERE clause, used for sorting in an ORDER BY).
A small addition to your original query makes this more apparent.
SQL> SELECT employee_id, last_name, department_name
2 FROM employees e, departments d
3 WHERE e.department_id=d.department_id
4 ORDER BY (SELECT department_name
5 FROM departments d
6 WHERE e.department_id=d.department_id);
EMPLOYEE_ID LAST_NAME DEPARTMENT_NAME
205 Higgins Accounting
206 Gietz Accounting
200 Whalen Administration
100 King Executive
101 Kochhar Executive
102 De Haan Executive
185 Bull Shipping
144 Vargas Shipping
143 Matos Shipping
184 Sarchand ShippingHTH
John -
MQ Adapter Correlation Set Problem
Hi,
I was using BPEL 10g to run a application, but our company is changing to version 11g, so I created the same app, with basically the same configuration, Correlation Sets and another things, but now I dont receive a response from the MQ Series, and when I go to the panel control of my application i see this error message in the rejected messages tab:
Cannot complete callback since unable to retrieve SourceURI/Wire from Correlation store. Either Instance Tracking is diabled or no corresponding Request succeeded prior to this callback (When i open this message, I can see the payload, and when I open it, it shows my message)
Someone have a clue what the problem is? I verified, and created a hundred times the correlation sets, but it doesn't work, I don't know if I have to do something more, but I don't think the queue is finding the right instance to return the message, and this is why I'm getting a time out, but the reason I don't know, because it's the same process as 10g, sou it should work fine without problems.Solution is:
JDeveloper using Create property alias wizard doesn't add namespace for query.
I had to add it manually
<bpws:propertyAlias propertyName="pns1:orderId_property" messageType="client:activationPushRequestMessage"
part="payload" query="/ns5:activationPushRequest/processid" xmlns:ns5="http://xmlns.oracle.com/activation/bpel/"/>
now it works -
Flattening, correlated subquery
Hi,
The following fields are key values on a table, with example data :
EMPNO DATE ACTION
1234 6/6/05 HIR
1234 6/6/05 XFR
1234 6/10/05 DTA
1234 6/22/05 XFR
1234 7/30/05 TER
3456 6/6/05 HIR
etc.
I need to create a view to show the previous 5 rows of history per employee but flattened to be one line per Employee Number (EMPNO).
So the view would be something like :
EMPNO ACTION1 DATE1 ACTION2 DATE2 ACTION3 DATE3 (etc.)
1234 HIR 6/6/05 XFR 6/6/05 DTA 6/10/05
I have thought of aliasing the table and then using correlated subqueries, but this got complicated joining to >2 tables. Since joining to table 2 required that DATE1 <> DATE2 or ACTION1 <> ACTION2. But then alias 3 becomes more convoluted and then 4 and 5 OTT.
I also looked at some rownum trickery to get the <=5 rows, but I could not get this working.
What is the best solution for this problem ? Note that it does have to be a pure view, not PL/SQL etc.
Thanks,
T0rrentI think you are after this. You must know the number of actions per output row. In this case five:
drop table t;
create table t( empno number, x_date date, action varchar2(3));
insert into t values (1234, to_date('6/6/05 01:00','mm/dd/yy hh:mi'),'HIR'); --need to have unique date values per empno
insert into t values (1234, to_date('6/6/05 02:00','mm/dd/yy hh:mi'),'XFR'); --need to have unique date values per empno
insert into t values (1234, to_date('6/10/05','mm/dd/yy'),'DTA');
insert into t values (1234, to_date('6/22/05','mm/dd/yy'),'XFR');
insert into t values (1234, to_date('7/30/05','mm/dd/yy'),'TER');
insert into t values (3456, to_date('6/6/05','mm/dd/yy'),'HIR');
commit;
create or replace view tv as
select empno, x_date, action, dense_rank() over( partition by empno order by x_date ) e_rank
from t
order by empno;
SELECT empno,
max( decode( e_rank, 1, x_date||' '||action)) e_act1,
max( decode( e_rank, 2, x_date||' '||action)) e_act2,
max( decode( e_rank, 3, x_date||' '||action)) e_act3,
max( decode( e_rank, 4, x_date||' '||action)) e_act4,
max( decode( e_rank, 5, x_date||' '||action)) e_act5
FROM tv
group by empno;
EMPNO E_ACT1 E_ACT2 E_ACT3 E_ACT4 E_ACT5
1234 06-JUN-05 HIR 06-JUN-05 XFR 10-JUN-05 DTA 22-JUN-05 XFR 30-JUL-05 TER
3456 06-JUN-05 HIR -
Build up correlation set problem
Hi everyone,
I follow "Using Correlation Sets Example" in Developer's Guide as a model to build my own simple process.
But got a compiling error said:"Error:null", that's all.
Does anyone know what's going on here??? Do I miss something??
Any document else?
I would be happy on any reply..
Thanks,
Elvis.Check your wsdl!
When I have this problem - I see 2 problems with wsdl (BPEL Desinger damage it, I don't touch it!):
1) missed xml header string (1-st string):
<?xml version="1.0" encoding="UTF-8"?>
2) added import of itself:
<import namespace="http://xmlns.oracle.com/<BPEL_ProcessName>" location="<BPEL_ProcessName>.wsdl"/>
If it is you case, remove this import and add xml header string.
Error must gone now.
Sometimes it happens with BPEL Designer - this may be a bug...
ORACLE - do you here??!!
Check it please ;-)
P.S. By the way. In my case this happens in 10.1.2.0.2
Message was edited by:
occ2000 -
Hi All,
I have a SQL query that I am looking to amend. The query currently shows routes from an A end location and a Z end location. On those routes, orders are placed. I have been asked to show only the routes that have more than one order on them. For this I have written the following subquery in the WHERE clause...
AND (
SELECT COUNT(*) qty
FROM (
SELECT *
FROM SCHEMA.ROUTE R
WHERE r.a_order_id = 457044
UNION
SELECT *
FROM SCHEMA.ROUTE R
WHERE r.z_order_id = 457044)
) > 1Due to the nature of the data, the UNION is needed to ensure orders that are built on either the A or the Z ends are counted.
The problem here is that I would like to use the a_order_id and z_order_id from the parent query to feed the '457044' values in the subquery. As I'm sure you're all aware, Oracle will only let you use the parent query values one level deep.
Can anyone see a way of doing this? I can't seem to see the wood through the trees on this one. Any help greatly appreciated.
Thanks,
Kev
Edited by: kevino17 on 21-Nov-2012 03:23Hi, Kev,
Welcome to the forum!
kevino17 wrote:
Hi All,
I have a SQL query that I am looking to amend. The query currently shows routes from an A end location and a Z end location. On those routes, orders are placed. I have been asked to show only the routes that have more than one order on them. For this I have written the following subquery in the WHERE clause...
AND (
SELECT COUNT(*) qty
FROM (
SELECT *
FROM SCHEMA.ROUTE R
WHERE r.a_order_id = 457044
UNION
SELECT *
FROM SCHEMA.ROUTE R
WHERE r.z_order_id = 457044)
) > 1Due to the nature of the data, the UNION is needed to ensure orders that are built on either the A or the Z ends are counted.It's unclear why you need a UNION. Why not
SELECT COUNT (*)
FROM schema.route r
WHERE s.order_id IN (r.a_order_id, r.z_order_id)
)where s.order_id is a value (such as 457044) from the super-query?
Whenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data, so that the people who want to help you can re-create the problem and test their ideas.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ {message:id=9360002} -
the following sample is from ORACLE DATABASE 10g SQL
i don't understand how it works, the bellow is the table and the query
SELECT Product_id pid, product_type_id ptid, name, price
FROM products
PID PTID NAME PRICE
1 1 Modern Science 19.95
2 1 Chemistry 30
3 2 Supernova 25.99
4 2 Tank War 13.95
5 2 Z Files 49.99
6 2 2412: The Return 14.95
7 3 Space Force 9 13.49
8 3 From Another Planet 12.99
9 4 Classical Music 10.99
10 4 Pop 3 15.99
11 4 Creative Yell 14.99
PID PTID NAME PRICE
12 My Front Line 13.49
the query
SELECT product_id pid, product_type_id ptid, name, price
FROM products outer
WHERE price >
(SELECT AVG(price)
FROM products inner
WHERE inner.product_type_id = outer.product_type_id)
PID PTID NAME PRICE
2 1 Chemistry 30
5 2 Z Files 49.99
7 3 Space Force 9 13.49
10 4 Pop 3 15.99
11 4 Creative Yell 14.99
what i don't understand is HOW and WHEN the AVG function works and HOW AVG() function knows to calculate the average by grouping the PTID not the average of ALL PRICE column.
tks for helping in advanceThe subquery
(SELECT AVG(price)
FROM products inner
WHERE inner.product_type_id = outer.product_type_id)knows to create an average of all the products with the same product type because of the WHERE clause, which limits the rows returned to those with the product_type_id in the outer.
Conceptually, what happens is
- the outer query gets the first row of the table (PID=1)
- it grabs the price (19.95)
- now, it runs the subquery to determine whether this is above average
- the subquery sees that outer.product_type_id is 1, so the WHERE clause eliminates all but the first two rows (PID 1&2). The average of 19.95 and 30 is 24.975.
- Since the price of the first row is not greater than 24.975, Oracle knows that it does not meet the conditions of the WHERE clause in the outer query.
- Repeat for each row in the outer query
Obviously, since Oracle is doing set-based processing, it may not work exactly this way internally. Conceptually, though, this is how correlated subqueries work.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Help with a correlated subquery. flawed results..
Hi,
Can anyone tell me what I am doing wrong here? I am trying to get the employees whos have above average salarys for there departments.
SELECT first_name||' '||last_name NAME,
department_id,
salary
FROM employee
WHERE salary > (SELECT AVG (salary)
FROM employee
GROUP BY department_id);I run this and get this:
ORA-01427: single-row subquery returns more than one rowHow can I amend this subquery to work for my needs? if i leave off:
GROUP BY department_idthen it gives the average for all employees.
Thanks!
Message was edited by:
user526807Your sub-query is not really correlated.
You should join it by deptno with exetrnal query
SELECT ename||' '||job,
deptno,
sal
FROM scott.emp e
WHERE sal > (SELECT AVG (sal)
FROM scott.emp
where deptno = e.deptno
GROUP BY deptno);ENAME||''||JOB DEPTNO SAL
ALLEN SALESMAN 30 1600
JONES MANAGER 20 2975
BLAKE MANAGER 30 2850
SCOTT ANALYST 20 3000
KING PRESIDENT 10 5000
FORD ANALYST 20 3000
Maybe you are looking for
-
Illustrator and Windows 8.1
I use Adobe Illustrator CS4. I just updated to Windows 8.1 and the colours in Illustrator are now very pale and dull. If I move the design to another program, the colours are bright so the problem must be something with Illustrator...
-
Problems with my library after installing itunes 7
I have just installed itunes 7 and when i set it up i have obviously clicked on something wrong as it has rearranged my entire collection and renamed everything, it has put every file from my computer in my library. Is there any way of taking it back
-
Being charged when no services provided
I have moved from my old flat in March and applied for a home-moving service online. During the moving and 3 weeks after I moved to my new flat, I couldn't use any services, especially broadband, because of the delay of the engineering work. I think
-
My big library gets Itunes 7 and my whole pc very slow
Hello, Since i installed Itunes 7.0.0, i notice that when i launch it, my whole pc is getting very slow. My mouse doesn't move properly. Il still have the problem with 7.0.1 and 7.0.2... Then, i thought that i had a big library (nearly 20.000 songs).
-
Mesh Tool distorting artwork.
After I finished doing my design using the "Mesh Tool" and reduced the size of the hole piece, the Mesh is converted from organic shapes into straight lines. Which makes all my work useless. Does any one knows how to fixe that?