Error in subquery
I have a table on which i need to generate serial number or batch numbers based on two criterias that by each unique desc, and item qty less than 10 per batch and item weight less than 50, i got the solution yesterday but when i rewrote the query using subquery it giving me an error like 'ora-01436' , how to overcome this problem.is there a way to write procedure and do this more simpler.please find below the sample test case.
CREATE TABLE OW_TEMP_DATA
TMP_NO VARCHAR2(12 BYTE),
TMP_PM_CODE VARCHAR2(12 BYTE),
TMP_PS_CODE VARCHAR2(12 BYTE),
TMP_DESC VARCHAR2(30 BYTE),
TMP_WT NUMBER,
TMP_QTY NUMBER,
TMP_TYPE VARCHAR2(2 BYTE)
insert into ow_temp_data (tmp_no, tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','A' , NULL,'H170',25 ,0,'W' );
insert into ow_temp_data ( tmp_no, tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','A' ,'A01' ,'HEA100' ,0 ,10,'WI' );
insert into ow_temp_data ( tmp_no,tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','B' , NULL,'H170',25 ,0,'W' );
insert into ow_temp_data ( tmp_no,tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','B' ,'B01' ,'HEA100' ,0 ,10,'WI' );
insert into ow_temp_data (tmp_no, tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','C' , NULL,'HB120',30 ,0,'W' );
insert into ow_temp_data ( tmp_no, tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','C' ,'C01' ,'HB100' ,0 ,10,'WI' );
insert into ow_temp_data ( tmp_no,tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','D' , NULL,'HB120',40 ,0,'W' );
insert into ow_temp_data ( tmp_no,tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','D' ,'D01' ,'HB100' ,0 ,10,'WI' );
insert into ow_temp_data (tmp_no, tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','E' , NULL,'PL120',30 ,0,'W' );
insert into ow_temp_data ( tmp_no, tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','E' ,'E01' ,'P100' ,0 ,10,'WI' );
insert into ow_temp_data ( tmp_no,tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','F' , NULL,'PL120',35 ,0,'W' );
insert into ow_temp_data ( tmp_no,tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','F' ,'F01' ,'P100' ,0 ,50,'WI' );
SQL> with agg_data as
2 (
3 select TMP_PM_CODE,TMP_DESC,TMP_WT,TMP_QTY,TMP_TYPE,ATT
4 from
5 (
6 SELECT b.tmp_pm_code tmp_pm_code, b.tmp_desc tmp_desc, b.tmp_wt tmp_wt,
7 b.tmp_qty tmp_qty, b.tmp_type tmp_type,tmp_ps_code,
8 SUM (b.tmp_qty) over(partition by b.tmp_pm_code) att
9 FROM ow_temp_data b
10 )
11 WHERE tmp_ps_code IS NULL
12 ),
13 agg_wt as
14 (
15 select TMP_PM_CODE,TMP_DESC,TMP_WT,TMP_QTY,TMP_TYPE,ATT,
16 sum(tmp_wt) over(partition by tmp_desc order by tmp_pm_code) sm_wt,
17 case when sum(tmp_wt) over(partition by tmp_desc) > 50 then 1
18 when sum(att) over(partition by tmp_desc) > 50 then 1
19 else 0
20 end wt_rnk
21 from agg_data
22 ),
23 agg_wt_rnk as
24 (
25 select TMP_PM_CODE,TMP_DESC,TMP_WT,TMP_QTY,TMP_TYPE,ATT,
26 sm_wt,wt_rnk
27 from agg_wt
28 ),
29 complete_data as
30 (
31 select TMP_PM_CODE,TMP_DESC,
32 tmp_wt,10 TMP_QTY,TMP_TYPE,ATT,level l,
33 sum(wt_rnk) over(order by TMP_PM_CODE,TMP_DESC,level) wt_rnk
34 from agg_wt_rnk
35 connect by prior tmp_pm_code = tmp_pm_code
36 and prior tmp_desc = tmp_desc
37 and (
38 att/level >= 10
39 or (prior tmp_wt/(level-1) > 10 and sm_wt > 50 )
40 )
41 and prior sys_guid() is not null
42 )
43 select to_char(
44 dense_rank() over(order by wt_rnk),
45 '0000') ob_batch,
46 TMP_PM_CODE ob_pm_code,
47 TMP_DESC ob_desc,
48 TMP_WT/count(*) over(partition by tmp_pm_code) ob_wt,
49 TMP_QTY ob_qty,TMP_TYPE ob_type
50 from complete_data;
OB_BA OB_PM_CODE OB_DESC OB_WT OB_QTY OB
0001 A H170 25 10 W
0001 B H170 25 10 W
0002 C HB120 30 10 W
0003 D HB120 10 10 W
0004 D HB120 10 10 W
0005 D HB120 10 10 W
0006 D HB120 10 10 W
0007 E PL120 30 10 W
0008 F PL120 7 10 W
0009 F PL120 7 10 W
0010 F PL120 7 10 W
OB_BA OB_PM_CODE OB_DESC OB_WT OB_QTY OB
0011 F PL120 7 10 W
0012 F PL120 7 10 W
SQL> select to_char(
2 dense_rank() over(order by wt_rnk),
3 '0000') ob_batch,
4 TMP_PM_CODE ob_pm_code,
5 TMP_DESC ob_desc,
6 TMP_WT/count(*) over(partition by tmp_pm_code) ob_wt,
7 TMP_QTY ob_qty,TMP_TYPE ob_type
8 from (
9 select TMP_PM_CODE,TMP_DESC,
10 tmp_wt,10 TMP_QTY,TMP_TYPE,ATT,level l,
11 sum(wt_rnk) over(order by TMP_PM_CODE,TMP_DESC,level) wt_rnk
12 from (
13 select TMP_PM_CODE ,TMP_DESC,TMP_WT,TMP_QTY,TMP_TYPE,ATT,
14 sm_wt,wt_rnk
15 from ( select TMP_PM_CODE,TMP_DESC,TMP_WT,TMP_QTY,TMP_TYPE,ATT,
16 sum(tmp_wt) over(partition by tmp_desc order by tmp_pm_code) sm_wt,
17 case when sum(tmp_wt) over(partition by tmp_desc) > 50 then 1
18 when sum(att) over(partition by tmp_desc) > 50 then 1
19 else 0
20 end wt_rnk
21 from
22 (
23 select TMP_PM_CODE,TMP_DESC,TMP_WT,TMP_QTY,TMP_TYPE,ATT
24 from
25 (
26 SELECT b.tmp_pm_code tmp_pm_code, b.tmp_desc tmp_desc, b.tmp_wt tmp_wt,
27 b.tmp_qty tmp_qty, b.tmp_type tmp_type,tmp_ps_code,
28 SUM (b.tmp_qty) over(partition by b.tmp_pm_code) att
29 FROM ow_temp_data b
30 )
31 WHERE tmp_ps_code IS NULL
32 )))
33 connect by prior sys_guid() is not null
34 and prior tmp_pm_code = tmp_pm_code
35 and prior tmp_desc = tmp_desc
36 and (
37 att/level >= 10
38 or (prior tmp_wt/(level-1) > 10 and sm_wt > 50 )
39 )
40 )
41 /
FROM ow_temp_data b
ERROR at line 29:
ORA-01436: CONNECT BY loop in user dataEdited by: 998476 on Apr 8, 2013 12:20 AM
Yeah i am sorry for posting it wrongly and i will brief it again in a proper way.
Thanks very much for the response alberto, will explain it again, actually i am generating the batch number or you can say serial number based on tmp_desc with two criterias of adding up the tmp_qty and adding up tmp_wt as follows.
Criteria for generating batch number is tmp_qty should not exceed 10 per each batch and tmp_wt should not exceed 50 each batch
Conditions
a) New batch number will be generated with max(batch)+1 from os_batch for every combination of tmp_Desc and till tmp_wt reaches 50 and till tmp_qty reaches 10, in simple each batch must not contain tmp_wt more than 50 and tmp_qty not more than 10 per each tmp_desc.
b) if weight exceed more than 50 for example if its 60 and qty is 10 , two batches will be created with weight as 30 30 each
as the wt criteria is more and it takes the priority.
c) if wight is ok that is less than 50 like 25 and qty is 50 then 50/10 that is 5 batches will be created with weight of batch being 5 and qty being 10.
d) if both the cases come together like wt is 60 and qty is 50 , priority goes to qty and it will 50/10 -- 5 batches with 60/5 wt per each batch.
please let know if you have any more clarification.
CREATE TABLE OW_TEMP_DATA
TMP_NO VARCHAR2(12 BYTE),
TMP_PM_CODE VARCHAR2(12 BYTE),
TMP_PS_CODE VARCHAR2(12 BYTE),
TMP_DESC VARCHAR2(30 BYTE),
TMP_WT NUMBER,
TMP_QTY NUMBER,
TMP_TYPE VARCHAR2(2 BYTE)
insert into ow_temp_data (tmp_no, tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','A' , NULL,'H170',25 ,0,'W' );
insert into ow_temp_data ( tmp_no, tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','A' ,'A01' ,'HEA100' ,0 ,10,'WI' );
insert into ow_temp_data ( tmp_no,tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','B' , NULL,'H170',25 ,0,'W' );
insert into ow_temp_data ( tmp_no,tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','B' ,'B01' ,'HEA100' ,0 ,10,'WI' );
insert into ow_temp_data (tmp_no, tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','C' , NULL,'HB120',30 ,0,'W' );
insert into ow_temp_data ( tmp_no, tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','C' ,'C01' ,'HB100' ,0 ,10,'WI' );
insert into ow_temp_data ( tmp_no,tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','D' , NULL,'HB120',40 ,0,'W' );
insert into ow_temp_data ( tmp_no,tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','D' ,'D01' ,'HB100' ,0 ,10,'WI' );
insert into ow_temp_data (tmp_no, tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','E' , NULL,'PL120',30 ,0,'W' );
insert into ow_temp_data ( tmp_no, tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','E' ,'E01' ,'P100' ,0 ,10,'WI' );
insert into ow_temp_data ( tmp_no,tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','F' , NULL,'PL120',35 ,0,'W' );
insert into ow_temp_data ( tmp_no,tmp_pm_code ,tmp_ps_code ,tmp_desc ,tmp_wt ,tmp_qty ,tmp_type ) values ('0','F' ,'F01' ,'P100' ,0 ,50,'WI' );
commit;
--query on which criterias to be applied and serial numbers to be generated.
select TMP_PM_CODE,TMP_DESC,TMP_WT, att TMP_QTY,TMP_TYPE
from
SELECT b.tmp_pm_code tmp_pm_code, b.tmp_desc tmp_desc, b.tmp_wt tmp_wt,
b.tmp_qty tmp_qty, b.tmp_type tmp_type,tmp_ps_code,
SUM (b.tmp_qty) over(partition by b.tmp_pm_code) att
FROM ow_temp_data b
WHERE tmp_ps_code IS NULL;
TMP_PM_CODE TMP_DESC TMP_WT TMP_QTY TMP_TYPE
A H170 25 10 W --this line and second line will go to batch 0001 as tmp_wt reaches 50
B H170 25 10 W --0001
C HB120 30 10 W --this will go into two batches as tmp_wt reaches 70 and divided by 2 and two batches for C AND D --0003
D HB120 40 10 W --0004
E PL120 30 10 W --In this case Both qty and wt are crossing their limits and this case will
have total of 6 batch numbers since tmp_qty becomes 60 here and it has to be splitted into each batch with qty as 10.
F PL120 35 50 W
--the output i want in os_batch table is as follows.
CREATE TABLE OS_BATCH
OB_BATCH VARCHAR2(12 BYTE),
OB_PM_CODE VARCHAR2(12 BYTE),
OB_DESC VARCHAR2(30 BYTE),
OB_WT NUMBER,
OB_QTY NUMBER,
OB_TYPE VARCHAR2(2 BYTE)
--the following is the result data i want in os_batch table.
ob_batch ob_pm_code ob_desc ob_wt ob_qty ob_type
0001 A H170 25 10 W
0001 B H170 25 10 W
0002 C HB120 35 10 W
0003 D HB120 35 10 W
0004 E PL120 10.83 10 W
0005 F PL120 10.83 10 W
0006 F PL120 10.83 10 W
0007 F PL120 10.83 10 W
0008 F PL120 10.83 10 W
0009 F PL120 10.83 10 WEdited by: 998476 on Apr 8, 2013 2:07 AM
Edited by: 998476 on Apr 8, 2013 2:09 AM
Similar Messages
-
[SQL Question] ORA-00936: missing expression --- Possible Error on subquery
I have one query that is basically three subqueries together.
If I separate them, they run correctly, but once I put them together I get the Oracle error:
ORA-00936: missing expression
select associate_id, application_id, entity_id, profile_id, language, neutrals,
created_date, sf_completed_date, completed_time, parent_respondent, parent_aid, attempt, parent_attempt,
reported_top1, reported_top2, reported_top3, reported_top4, reported_top5, top1, top2, top3, top4, top5
from profiles p1
where sf_completed_date < to_date('15-aug-2006 00:00:00','DD-MM-YYYY HH24:MI:SS')
and parent_respondent is null
and parent_aid is null
and neutrals < 155
and p1.attempt in
(select nvl(max(attempt),0)
from profiles p2
where p2.associate_id = p1.associate_id
and p1.associate_id in)
(select p1.associate_id, count(*) as count
from
(select top1 as theme
from p1.profiles
union all
select top2 as theme
from p1.profiles
union all
select top3 as theme
from p1.profiles
union all
select top4 as theme
from p1.profiles
union all
select top5 as theme
from p1.profiles)
group by theme);
I'm using Golden, and this is the SQL where the error is happening:
and p1.associate_id in)
(select p1.associate_id, count(*) as countWhat is the best way to get this to run? Is it something with the way the subquery is written?
thanksTry this:
and p1.attempt in (select nvl(max(attempt),0)
from profiles p2
where p2.associate_id = p1.associate_id
and p1.associate_id in
(select p1.associate_id
, count(*) as count
from (select top1 as theme
from p1.profiles
union all
select top2 as theme
from p1.profiles
union all
select top3 as theme
from p1.profiles
union all
select top4 as theme
from p1.profiles
union all
select top5 as theme
from p1.profiles
group by theme
; -
We have a Query in BIP11g and it fails on this:
WHERE S.STUDENTNUMMER = SE.STUDENTNUMMER
AND SE.OPLEIDING = O.OPLEIDING
AND SI.OPLEIDING = O.OPLEIDING
AND NVL(:P_COLLEGEJAAR,12)
IN ( SELECT NVL( :P_COLLEGEJAAR,12) JAAR
FROM OST_STUDENT_INSCHRIJFHIST SI
WHERE SI.STUDENTNUMMER = S.STUDENTNUMMER
AND SI.OPLEIDING = SO.OPLEIDING )
It fails on the NVL-function in the subquery.
The query works fine in SQL*Developer and BIP 10g.
How can I fix this?Found it: NVL cannot be used in a subquery.
Why? No clue. Is just a bug.
Workaround: case or exist. Both work well. -
Hi guys,
I have used sql extension to invoke my DB function (Sybase) dateDiff.
The filter i have sprcified is like
ext:sql ('dateDiff(dd, <b>payDate</b>, '<i>(select sysDate.systemDate from SYSTEMDATE sysDate)</i>')') == calculatedAge )
Here payDate is the field of my entity on which i am invoking the query(Candidate class).
calculatedAge is query param
but the second param to this dateDiff function is not some field but sql subquery.
on invoking this, I get the error :
Error message: Subquery "select sysDate.systemDate from SYSTEMDATE sysDate" has an unrecognized candidate class. Make sure the class name is valid. You may need to fully-qualify the class name if it is not in the package of the query's candidate class or in any of the imports
I think this subquery is being taken as JDOQL but i want this to be assumed as a sql query because SYSTEMDATE is not persistace capable class.
Any help is appreciated.
Thanks,
Mahesh
Message was edited by:
mvatwaniEnable security descriptors = Allow virtual applications full write permission to the virtual file system.
Here is how it looks like:
https://twitter.com/packageologist/status/462180503995813888/photo/1 -
I am trying to do the oracle version, thats where I kind of got stuck, what I have to do in the external where clause. Any help is appreciated.
Thanks
/* sybase version
update sale_upgrades_temp
set a.exchangeRate = b.conversionRate
from sale_upgrades_temp a, CurrencyConversion b
where a.chargeCurrency = b.name
and (convert(datetime,convert(varchar(11),a.workCompleted,101))
>= b.effectivePeriodStartDate)
and (convert(datetime,convert(varchar(11),a.workCompleted,101))
<= b.effectivePeriodEndDate
OR b.effectivePeriodEndDate is null)
--trifleet_hyperion_user.
update sale_upgrades_temp
set exchangeRate =(select b.conversionRate
from CurrencyConversion b
where sale_upgrades_temp.chargeCurrency = b.name
and ( to_date(sale_upgrades_temp.workCompleted)
>= b.effectivePeriodStartDate)
and (to_date(sale_upgrades_temp.workCompleted))
<= b.effectivePeriodEndDate
OR b.effectivePeriodEndDate is null))
where (sale_upgrades_temp.chargeCurrency, sale_upgrades_temp.workCompleted)
in (selectI tried this and obviously I got the error, as subquery retursn morethan one row as my external where clause does not have any filter condition. Could some shed some light on this ?
update sale_upgrades_temp
set exchangeRate =(select b.conversionRate
from CurrencyConversion b
where sale_upgrades_temp.chargeCurrency = b.name
and ( to_date(sale_upgrades_temp.workCompleted)
>= b.effectivePeriodStartDate)
and (to_date(sale_upgrades_temp.workCompleted))
<= b.effectivePeriodEndDate
OR b.effectivePeriodEndDate is null))
where sale_upgrades_temp.chargeCurrency
in (select name from CurrencyConversion); -
How to use group function in insert or update
Hai All
How can we use group function in insert or update statement
I am generating an attendance so i have different set of timing for example
0800,1200,1230, 1700 and i need to insert into these data into table with min value to intime and max value to
outtime and othere to inertval time in or out
Pls tell me with some example
For example
For INSERT
insert into T2 (barcode,empcode,intime,attend_date)
values(r2.cardn,r2.enpno,MIN(r2.ptime),r2.pdate);
For UPDATE
update dail_att set outtime= MAX(r2.ptime) where empcode=r2.enpno and barcode=r2.cardn and
attend_date=r2.pdate;
Here instead of where i need to use having so pls tell how to use
Thanks & Regards
Srikkanth.MHai Man
R2 is not a table name its a record
Let me explain clearly
I have to generate daily attendance for lot of employees So i have two table t1 and t2
T1 consist of three column empno,date,time
T2 consist of empno,name,date,intime,outtime,intrin,introut
So now i need to give the T1 Min value Of time to T2 Intime and T1 Max value of Time to T2 Outtime fields so there so many records while i am using
max(time) it gives the max value of all so i seperated by group function so now i have an error in subquery ie it is an single row subquery so i need to use multiple row subquery how i can use multiple row subquery in update statement
Thanks In Advance
Srikkanth.M -
SQL Developer Script Output too limited for student - how to increase?
I'm just a student trying to migrate from notepad and SQL Plus to using the SQL Developer for the comprehensive course project. Unfortunately, the script output is way too limited... it only reports a fourth of my last assignment's results - not enough to use in the project. How specifically can this be increased. I have version 1.1.0.21 running on Windows XP on a laptop with 512k memory.
Thanks much for any/all assist. I don't want to go back to notepad!!Thank you for the advice, but I had tried that. My script is 305 lines counting blank lines and the SQL developer displays only about 35 lines of results corresponding to 58 lines of input. When I run the same script in SQL Plus in a console window using the @filename command, I get the entire output.
My input and output follow:
Input:
spool project-test-out.txt
prompt 'name'
prompt 'Assignment X, parts 2b - 2h and 3a - 3b '
create table Customer (
CustID Integer,
Name Char(10),
State Char(2),
primary key (CustID) );
create view CustID_List (ID_Cust) as (select custID from Customer);
create table Inventory (
PartID Integer,
Item Char(10),
Cost Float,
OnHand Integer,
primary key (PartID) );
create table Invoice (
InvNum Integer,
InvDate DATE,
CustID Integer,
primary key (InvNum),
foreign key (CustID) references Customer);
create table Invoice_Item (
InvNum Integer,
PartID Integer,
Quantity Integer,
foreign key (InvNum) references Invoice,
foreign key (PartID) references Inventory);
insert into customer values ( 101, 'Kerry', 'MA' );
insert into customer values ( 102, 'Edwards', 'NC' );
insert into customer values ( 103, 'Cheney', 'TX' );
insert into customer values ( 104, 'Bush', 'TX' );
insert into Inventory values ( 1, 'Boots ', 149.95, 6 );
insert into Inventory values ( 2, 'Spurs ', 12.95, 24 );
insert into Inventory values ( 3, 'Buckle ', 19.95, 4 );
insert into Inventory values ( 4, 'Hat ', 60.00, 12 );
insert into Inventory values ( 5, 'Holster', 75.00, 8 );
insert into Inventory values ( 6, 'Saddle ', 350.00, 2 );
prompt 'Part grad 3b - unsatisfying solution, limitations of Oracle 10g Express'
prompt 'After many trials, found oracle discussion on web stating that'
prompt 'Oracle 9 does not allow subqueries in the trigger WHEN clause.'
prompt 'What a pain. Thus the solution here has become rather inelegant.'
prompt 'The trigger and following select statement are byproducts of various'
prompt 'simplification attempts, none of which worked.'
select ID_Cust from custID_List;
create trigger Invoice_CustID_CK before insert on Invoice
REFERENCING NEW AS newCustID
FOR EACH ROW
BEGIN
if (:newCustID.CustID = 205 )
-- {{want line below but it generates error of: subquery not allowed in }}
-- {{this context }}
-- if (:newCustID.CustID NOT IN
-- (Select ID_Cust from CustID_List))
then :newCustID.CustID := NULL;
end if;
END;
run;
show errors trigger Invoice_CustID_CK;
insert into invoice values ( 201, '01-Aug-2006', 101 );
insert into invoice values ( 202, '02-Sep-2006', 101 );
insert into invoice values ( 203, '05-Oct-2006', 103 );
insert into invoice values ( 204, '07-Oct-2006', 102 );
insert into invoice values ( 205, '09-Oct-2006', 205 );
insert into Invoice_Item values ( 201, 1, 1 );
insert into Invoice_Item values ( 201, 2, 1 );
insert into Invoice_Item values ( 202, 5, 2 );
insert into Invoice_Item values ( 203, 1, 2 );
insert into Invoice_Item values ( 203, 2, 2 );
insert into Invoice_Item values ( 203, 3, 2 );
insert into Invoice_Item values ( 203, 4, 2 );
insert into Invoice_Item values ( 204, 4, 2 );
insert into Invoice_Item values ( 204, 1, 1 );
select * from invoice;
select * from customer;
select * from invoice_item;
select * from inventory;
prompt 'Preparation for part 2b - create view showing onhand and starting inventory'
alter table inventory add (start_inventory integer);
update inventory
set start_inventory = onhand;
create view inv_changes as
select partid, sum(quantity) as sales_by_id
from invoice_item
group by partid;
create table inventory_invoiced as
select inventory.partid, item, cost, onhand, start_inventory, COALESCE (sales_by_id, 0) as sales_by_id_NZ
from inventory left outer join inv_changes
on inventory.partid = inv_changes.partid;
select * from inventory_invoiced;
update inventory_invoiced
Set
onhand = onhand - sales_by_id_NZ;
select * from inventory_invoiced;
prompt 'Part 2b - What item has the least on hand inventory after processing the invoices?'
select item
from inventory_invoiced
where onhand = (select min(onhand) from inventory_invoiced);
prompt 'Part 2c - How much does customer 101 owe?'
create view cust101_orders as
select distinct partID, quantity
from invoice_item, invoice
where invoice_item.invnum IN
(select I.invnum from invoice I where I.custid = 101);
select * from cust101_orders;
select sum(quantity * cost) as cust101_bill
from cust101_orders, inventory
where cust101_orders.partID = inventory.partID;
prompt 'Part 2d - Which customer has the biggest bill?'
prompt ' desirable solution is to do part 2c as a general case '
prompt ' using a stored function such that the custID is passed '
prompt ' to the function. Unfortunately, neither function below '
prompt ' compiles. First case trips on creating the view. Second'
prompt ' case being arewrite without a view - ifit even works - '
prompt ' trips on the complicated select'
create or replace function ind_customer_bill
(ind_customer_ID in integer)
return Float
IS ind_total_bill Float;
begin
create view cust_orders as
select distinct partID, quantity
from invoice_item.invnum IN
(select I.invnum from invoice I where I.custid = ind_customer_ID);
select sum(quantity * cost) into ind_total_bill
from cust_orders, inventory
where cust_orders.partid = inventory.partid;
drop view cust_orders;
return (ind_total_bill);
end;
show errors function ind_customer_bill;
create or replace function ind_customer_bill
(ind_customer_ID in integer)
return Float
IS ind_total_bill Float;
begin
select sum(quantity * cost) into ind_total_bill
from inventory, (select distinct partID as interim_partID, quantity
from invoice_item.invnum IN
(select I.invnum from invoice I where I.custid = ind_customer_ID))
where interim_partID = inventory.partid;
return (ind_total_bill);
end;
show errors function ind_customer_bill;
Prompt 'part 2d continued using shameful brute force technique'
select * from cust101_orders;
create view cust101_due as
select sum(quantity * cost) as cust101_bill
from cust101_orders, inventory
where cust101_orders.partID = inventory.partID;
create view cust102_orders as
select distinct partID, quantity
from invoice_item, invoice
where invoice_item.invnum IN
(select I.invnum from invoice I where I.custid = 102);
select * from cust102_orders;
create view cust102_due as
select sum(quantity * cost) as cust102_bill
from cust102_orders, inventory
where cust102_orders.partID = inventory.partID;
create view cust103_orders as
select distinct partID, quantity
from invoice_item, invoice
where invoice_item.invnum IN
(select I.invnum from invoice I where I.custid = 103);
select * from cust103_orders;
create view cust103_due as
select sum(quantity * cost) as cust103_bill
from cust103_orders, inventory
where cust103_orders.partID = inventory.partID;
create view cust104_orders as
select distinct partID, quantity
from invoice_item, invoice
where invoice_item.invnum IN
(select I.invnum from invoice I where I.custid = 104);
select * from cust104_orders;
create view cust104_due as
select sum(quantity * cost) as cust104_bill
from cust104_orders, inventory
where cust104_orders.partID = inventory.partID;
prompt 'and the answer to part 2d - biggest bill is'
select *
from cust101_due, cust102_due, cust103_due, cust104_due;
prompt 'Part 2e - What items were the most popular (most sold)'
select item
from inventory_invoiced
where sales_by_id_NZ >= ANY (
select max(sales_by_id_NZ) from inventory_invoiced);
prompt 'Part 2f - What was the value of the original inventory'
select sum (start_inventory * cost) as total_start_inventory
from inventory_invoiced;
prompt 'Part 2g - What was the value of the ending inventory'
select sum (onhand * cost) as total_ending_inventory
from inventory_invoiced;
prompt 'Part 2h - What customers did not place an order'
-- after some testing of the inner nest parts wherein the left outer join
-- results in a CustID_List entry 104 having a null entry in
-- invoice's CustID list.
select Name
from customer
where custID IN (select ID_Cust
from (select ID_Cust, CustID
from CustID_List left outer join invoice on
ID_Cust = CustID)
where CUSTID IS NULL);
prompt 'Part 3a - What items were not purchased by anyone'
select item as unpurchased
from inventory_invoiced
where sales_by_id_nz = 0;
prompt 'Part 3b - table modifications for invoices to have valid CustID'
prompt ' -- see 3b section at top of file, notes and trigger '
drop view cust101_due;
drop view cust102_due;
drop view cust103_due;
drop view cust104_due;
drop function ind_customer_bill;
drop view cust101_orders;
drop view cust102_orders;
drop view cust103_orders;
drop view cust104_orders;
drop table inventory_invoiced;
drop view inv_changes;
drop view custID_List;
drop table invoice_item;
drop table invoice;
drop table inventory;
drop table customer;
Output:
'name'
'Assignment X, parts 2b - 2h and 3a - 3b '
create table succeeded.
create view succeeded.
create table succeeded.
create table succeeded.
create table succeeded.
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
1 rows inserted
'Part grad 3b - unsatisfying solution, limitations of Oracle 10g Express'
'After many trials, found oracle discussion on web stating that'
'Oracle 9 does not allow subqueries in the trigger WHEN clause.'
'What a pain. Thus the solution here has become rather inelegant.'
'The trigger and following select statement are byproducts of various'
'simplification attempts, none of which worked.'
ID_CUST
101
102
103
104
4 rows selected
trigger Invoice_CustID_CK Compiled. -
Unable to access application set in admin console after upgrade to 7.0 M
Hi Experts
I am unable to access the Application Set through BPC Administration after upgrading our development server to version 7.0 SP3. I followed the instructions as per the Upgrade guide, and there was no issues during the installation. But when trying to access the application set i receive the following error message on step 9 ( 9/10) of during the connection.
Error message: Subquery returned more than 1 value. This is not
permitted when the subquery follows =, !=, <, <= , >, >= or when the
subquery is used as an expression.
I have done all of the steps outlined as per SAP Note 1242962, but i still receive the error message. I tried to do a SQL Profiler trace, but i have been unable to find the query which returns more than one record.
Any help is appreciated
Kind Regards
DanielInteresting that you ask about upgrade vs uninstall/reinstall.
We were running BPC 5.1
We have also re-installed the Admin client to be the new version.
We have been working with an outside consulting firm to manage our system upgrade/install.
Our dev and qa environments were uninstalled then reinstalled.
When we went to production, our system was intially upgraded. I do not know why this route was chosen when that was not what was completed on dev/qa. On our production 'upgrade', we are still working through issues. We then uninstalled iis, sqlserver reporting services, both .net 1.1 and 2.0, and the BPC application. Then reinstall everything and we were getting the same errors.
Our error was at Progress 10/10 Create Database Schema and check Application server collation.
Error Message: Object Reference not set to an instance of an object.
We are able to access the appShell and test copies of the appShell, we were not able to access any custom appSets which were created prior to the upgrade, nor are we able to access any appSets that were created as a copy of the custom appSet after the upgrade.
When logged with SAP, we were directed toward note Note 1331040 - Cannot log into 7M Admin console after restore from version5 noting that we needed to do the following changes:
Note that you will need to change the following:
INSERT INTO tblDefaults VALUES ('_GLOBAL','Prev_AppSet_Version','','','7.0.112')
INSERT INTO tblDefaults VALUES ('_GLOBAL','Curr_AppSet_Version','','','7.0.112')
to
INSERT INTO tblDefaults VALUES ('_GLOBAL','Prev_AppSet_Version','','','7.0.113')
INSERT INTO tblDefaults VALUES ('_GLOBAL','Curr_AppSet_Version','','','7.0.113')
The reason is because '7.0.113' means 7 MS SP04 while '7.0.112' means SP03.
There are 8 steps in this note, for us, only the first 2 were needed. I have asked SAP to create new note/update existing accordingly.
With the table entry, we were able to successfully access our app set.
Hope our experiences can help you out.
Thanks,
Becky Zick -
UCCX %MIVR-HR_MGR-3-HISTORICAL_DB_WRITE_FAILED
Hi,
I've a client with UCCX HA setup (System version: 8.0.2.10000-41).
I saw this alert generated yesterday in the RTMT under Alert Central. It came from Secondary UCCX server (It is running as Master). The client has some weird issues since yesterday, the agents started getting Licensing Error, CSD is not updating Agents statistics, Real time data in RT tables (for wallboard) is not getting updated etc. I bounced the LRM service and agents were able to login fine.
I looked at Bug: CSCtq91894 but not very helpful. Does anyone know what could have caused this alert and any possible fixes? I am attaching the MIVR logs covering this event.
Module Name : HISTORICAL_REPORTING_MANAGER
Module Failure Name : HISTORICAL_DATABASE
UNKNOWN_PARAMTYPE:Module Run-time Failure Cause : 3
Module Failure Message : Historical database queue is full. Historical data saved in files. Queue size= 0 Total number of lost records= 1 Please check dat
AppID : Cisco Unified CCX Engine
ClusterID :
NodeID : CELCC6802
TimeStamp : Thu Jan 05 09:50:11 AST 2012.
The alarm is generated on Thu Jan 05 08:50:11 EST 2012.Module Name : HISTORICAL_REPORTING_MANAGER
Module Failure Name : HISTORICAL_DATABASE
UNKNOWN_PARAMTYPE:Module Run-time Failure Cause : 3
Module Failure Message : Historical database queue is full. Historical data saved in files. Queue size= 0 Total number of lost records= 1 Please check dat
AppID : Cisco Unified CCX Engine
ClusterID :
NodeID : CELCC6802
TimeStamp : Thu Jan 05 09:50:11 AST 2012.
The alarm is generated on Thu Jan 05 08:50:11 EST 2012.
Thanks,
KapilHi,
After searching for the error logs cam across a TAC case reference:617010385
Which is pointing to below 2 defects which have a fix for this issue.
CSCtj88620: run time error while generating agent related historical reports
Description: HRC throws run time error while generating some agent related reports. HRC log shows the error "A subquery has returned not exactly one row".
Following is seen in the RTMT for the same time frame.
Module Name : HISTORICAL_REPORTING_MANAGER
Module Failure Name : HISTORICAL_DATABASE
UNKNOWN_PARAMTYPE:Module Run-time Failure Cause : 3
Module Failure Message : Historical database queue is full. Historical data saved in files. Queue size= 0 Total number of lost records= 300 Please check d AppID : Cisco Unified CCX Engine
ClusterID : NodeID : uccx1a
TimeStamp : Wed Nov 03 08:02:16 EDT 2010.
The alarm is generated on Wed Nov 03 08:02:16 EDT 2010.
To Be fixed: 8.0(2)SU2 8.5(1)SU3
CSCtl93897: UCCX Engine tries to update missing table, which causes RTMT alerts
Description:
When running a historical report, the customer's system generates RTMT alerts such as:
Subject: [RTMT-ALERT-StandAloneCluster] HistoricalDataWrittenToFiles
Module Name : HISTORICAL_REPORTING_MANAGER Module Failure Name : HISTORICAL_DATABASE UNKNOWN_PARAMTYPE:Module Run-time Failure Cause : 3
Module Failure Message : Historical database queue is full. Historical data saved in files. Queue size= 0 Total number of lost records= 1 Please check dat AppID : Cisco Unified CCX Engine ClusterID :
After further investigations, the cause of this issue was found to be the UCCX engine, which tries to write data to a table from a previous version, called the WorkflowTask table. Given that there is no longer a table within the database by this name, this causes the system to generate RTMT alerts.
While there is no direct impact on the system in a critical way, such as core functionality or critical data loss, this still needs to be addressed, as it causes concerns for the customer who may see these errors.
To Be fixed: 8.5(1)SU3 8.0(2)SU4
As I see you are currently running on UCCX 8.5(1)SU2 with COP file on HA, need to come to 8.5(1)SU3.
As of now I can only see 8.5 SU2 posted in CCO.
http://www.cisco.com/cisco/software/release.html?mdfid=270569179&flowid=5217&softwareid=280840578&release=8.0%282%29_SU4&relind=AVAILABLE&rellifecycle=&reltype=latest
Please contact Cisco TAC for the ES or any other available COP file for this issue.
Hope it helps.
Anand
Please rate helpful posts by clicking on the stars below the right answers !! -
Subquery in pivot_in_clause gives an error in 11g
Hi,
according to the 11g sql documentation a subquery is allowed in pivot_in_clause
http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_10002.htm here's is the pivot_in_clause syntax.
When I use a subquery I get an error. What am I doing wrong?
Without a subquery, everything works fine.
DB version is 11.1.0.6
SQL> with t as (select 1 id from dual
2 union all
3 select 2 from dual)
4 select * from t pivot(sum(id) for id in (1,2));
1 2
1 2
SQL>
SQL> with t as (select 1 id from dual
2 union all
3 select 2 from dual)
4 select * from t pivot(sum(id) for id in (select level from dual connect by level<3));
select * from t pivot(sum(id) for id in (select level from dual connect by level<3))
ERROR at line 4:
ORA-00936: missing expression Thanks,
AntsSo .. is there a way to convert the SQL below so that it CAN work?
with t as (select 1 id from dual
2 union all
3 select 2 from dual)
4 select * from t pivot(sum(id) for id in (select level from dual connect by level<3));
Thanks in advance for any assistance. -
Sql Error in Select statement when doing subquery
Hi,
I am trying to see what the error is in the subquery part of the select statement.
Subquery should be fetching the safety_stock_quantity based on the MAX(effectivity_date).
Any suggestions?
SELECT kbn.last_update_date,itm.segment1,itm.description,kbn.kanban_card_number,kbn.kanban_size,
(SELECT msc.safety_stock_quantity
FROM mtl_safety_stocks msc
WHERE msc.effectivity_date = (select MAX(msc2.effectivity_date)
from mtl_safety_stocks msc2
where msc2.inventory_item_id = itm.inventory_item_id
and msc2.organization_id = itm.organization_id)
AND msc.inventory_item_id = itm.inventory_item_id
AND msc.organization_id = itm.organization_id
FROM mtl_system_items_b itm
,mtl_onhand_quantities_detail moqd
,mtl_safety_stocks msc
,mtl_kanban_card_activity kbn
WHERE itm.inventory_item_id = kbn.inventory_item_id
AND itm.organization_id = kbn.organization_id
AND itm.inventory_item_id = moqd.inventory_item_id
AND itm.organization_id = moqd.organization_id
AND moqd.subinventory_code = kbn.source_subinventory
AND kbn.card_status = 1
AND kbn.supply_status = 5
AND msc.inventory_item_id = itm.inventory_item_id
AND msc.organization_id = itm.organization_id
GROUP BY
kbn.last_update_date,itm.segment1,itm.description,kbn.kanban_card_number,kbn.kanban_size;
Thanks
PravnHi, Pravn,
Remember the ABC's of GROUP BY:
When you use a GROUP BY clause and/or an aggregate fucntion, then every item in the SELECT clause must be:
(A) an <b>A</b>ggregate function,
(B) one of the "group <b>B</b>y" expressions,
(C) a <b>C</b>onstant, or
(D) something that <b>D</b>epends entirely on the above. (For example, if you "GROUP BY TRUNC(dt)", you can "SELECT TO_CHAR (TRUNC(dt), 'Mon-DD')").
There's a GROUP BY clause in your main query, so every item in the main SELECT clause must be one of the above. The last item, the unnamed scalar sub-query, is none of the above.
How can you fix this problem? That depends on your data, the results you want, and perhaps on your Oracle version. If you'd like help, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved. Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
Always say which version of Oracle you're using.
You may have noticed that this site normally doesn't display multiple spaces in a row.
Whenever you post formatted text (including, but limited to, actual code) on this site, type these 6 characters:
\(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing. -
Oracle db wrong result on subquery error
Hi,
I work with Oracle databases up to 10g and I found an error and couldn’t find any documentation about it yet. Perhaps you can help me.
The error is quite easy to replicate. If you run the following query adapting the parameters you should get a result, the problem is that you should only get an error!
select * from user_tab_columns
where table_name in
select table_name from <TABLE_B>
Parameter: TABLE_B
Description: This should be an existing table of the schema which doesn’t have any table_name field.
As I said, the sub-query is wrong, so if you try to run it separately it fails. The problem is when you run both together because, if the link field has the same name, it returns all values of the table in the outer query.
Do you know if this is solved in 11g or in a specific patch of 10g?
Thanks in advance for your interest.
Best regards,
Leo ([email protected])user6396183 wrote:
I don't think a query whose inner query evaluates to ORA-00904 'Invalid identifier' should return anything, it's not logic. To me this is a bug.
If you execute the following query it will retrieve all records from the outer table when it should only return an exception as the inner query can not be evaluated at all.
select * from user_tab_columns
where table_name in (select table_name from user_role_privs);You still did not get it. Yes inner query by itself results in ORA-00904 'Invalid identifier' only if you execute it independently:
select table_name from user_role_privsOracle parser tries to figure out what table_name is. It is not a literal, therefore it concludes it is an identifier. Now the only table in FROM list is user_role_privs and it has no such column. Then parser checks if such function exists and it does not, etc... At the end ORA-00904 'Invalid identifier' is raised. However, look what happens if you issue it as a sub_query:
select * from user_tab_columns
where table_name in (select table_name from user_role_privs);Again, Oracle parser tries to figure out what table_name is. It is not a literal, therefore it concludes it is an identifier. Now the only table in FROM list is user_role_privs and it has no such column. Now, parser realizes it is a subquery and table_name can be a correlated name. So it checks main query FROM clause list and guess what - table user_tab_columns has a column table_name. So what subquery means is select a row from table user_tab_columns, which will give as some column table_name value and then use that value in subquery, get results and compare it with same table_name value. Now, I hope, you can see that no error should be raised. And, if user_role_privs is not empty, query will return every row in user_tab_columns. If user_role_privs is empty, query will not return any rows. But again, error is neither raised nor should be raised.
SY. -
Hi all,
I m getting error ORA-01427 single row subquery return more than one row when i execute the below query.
could some one help me in writing the below query
update dvd_genre set GENRE_I = (select GENRE_I from dvd_gen_data
where mov_name in (select mov_name from dvd_genre group by mov_name))
where mov_name in (select mov_name from dvd_gen_data group by mov_name)rgds
Saazsee:
SQL> select * from a;
IDX CNAME
1 e
2 f
SQL> select * from b;
IDX CNAME
1 c
2 d
1 e
2 f
SQL>
SQL> update a set cname=(
2 select cname from b
3 where idx=a.idx
4 );
update a set cname=(
select cname from b
where idx=a.idx
ORA-01427: single-row subquery returns more than one row
SQL>
SQL> update a set cname=(
2 select cname from (
3 select idx,max(cname) cname from b
4 group by idx
5 )
6 where idx=a.idx
7 );
2 rows updated
SQL> select * from a;
IDX CNAME
1 e
2 fEdited by: Garey on 2009-10-7 下午11:47 -
Getting Error - Single-row subquery returns more than 1 row (Help Needed)
I have the following SQL. It selects several rows of data. This data reflects changed records. I want to update PS_UNI_TEXTBK_SKEW for the values selected. Any ideas. For updating I used:
update ps_uni_textbk_skew s
set (s.ssr_txbdtl_title, s.ssr_txbdtl_isbn, s.ubs_skew_num, s.process_date, s.ubs_rec_type) = (
and then I included theselect listed below. (this selects does work). It always produces an error saying 'singl-row subjquery returns more than 1 row'.
Any help would be appreciated. I've worked on this for a week now trying many different ways. Thanks, Mary
SELECT NOW.SSR_TXBDTL_TITLE
,NOW.SSR_TXBDTL_ISBN
,0
,SUBSTR(SYSDATE,1,8)
,'C'
FROM
SELECT C.SUBJECT||C.CATALOG_NBR||C.CLASS_SECTION||C.STRM||B.SSR_TXBDTL_SEQNO AS TYINGKEEN
,C.CRSE_ID
,C.CRSE_OFFER_NBR
,C.STRM
,C.SUBJECT
,C.CATALOG_NBR
,C.CLASS_SECTION
,C.DESCR
,B.SSR_TXBDTL_SEQNO
,B.SSR_CRSEMAT_TYPE
,B.SSR_TXBDTL_STATUS
,B.SSR_TXBDTL_TITLE
,B.SSR_TXBDTL_ISBN
,B.SSR_TXBDTL_AUTHOR
,B.SSR_TXBDTL_PUBLISH
,B.SSR_TXBDTL_EDITION
,B.SSR_TXBDTL_PUBYEAR
,B.SSR_TXBDTL_NOTES
FROM PS_CLASS_TBL C,
PS_SSR_CLS_TXB_DTL B
WHERE C.CRSE_ID = B.CRSE_ID
AND C.CRSE_OFFER_NBR = B.CRSE_OFFER_NBR
AND C.STRM = B.STRM
AND C.CLASS_SECTION = B.CLASS_SECTION
) NOW,
SELECT SUBJECT||CATALOG_NBR||CLASS_SECTION||STRM||SSR_TXBDTL_SEQNO AS TYINGKEEL
,CRSE_ID
,CRSE_OFFER_NBR
,STRM
,SUBJECT
,CATALOG_NBR
,CLASS_SECTION
,DESCR
,SSR_TXBDTL_SEQNO
,SSR_CRSEMAT_TYPE
,SSR_TXBDTL_STATUS
,SSR_TXBDTL_TITLE
,SSR_TXBDTL_ISBN
,SSR_TXBDTL_AUTHOR
,SSR_TXBDTL_PUBLISH
,SSR_TXBDTL_EDITION
,SSR_TXBDTL_PUBYEAR
,SSR_TXBDTL_NOTES
FROM PS_UNI_TEXTBK_SKEW
) LAST
WHERE NOW.TYINGKEEN = LAST.TYINGKEEL
AND (NOW.SSR_TXBDTL_TITLE <> LAST.SSR_TXBDTL_TITLE
OR NOW.SSR_TXBDTL_ISBN <> LAST.SSR_TXBDTL_ISBN
OR NOW.SSR_TXBDTL_AUTHOR <> LAST.SSR_TXBDTL_AUTHOR
OR NOW.SSR_TXBDTL_PUBLISH <> LAST.SSR_TXBDTL_PUBLISH
OR NOW.SSR_TXBDTL_EDITION <> LAST.SSR_TXBDTL_EDITION
OR NOW.SSR_TXBDTL_PUBYEAR <> LAST.SSR_TXBDTL_PUBYEAR
OR NOW.SSR_TXBDTL_NOTES <> LAST.SSR_TXBDTL_NOTES
OR NOW.SSR_TXBDTL_STATUS <> LAST.SSR_TXBDTL_STATUS
OR NOW.SSR_CRSEMAT_TYPE <> LAST.SSR_CRSEMAT_TYPE
OR NOW.DESCR <> LAST.DESCR);1. Take your subqueries
2. Run those separately to see if they really can return more than one row. If needed modify the subquery by adding GROUP-BY and HAVING-COUNT>1 clauses to determien that.
3. If you see more than one row coming up from subqueries then the error message you named will arise.
This is what i would do.
But in first look you don't have subqueries, you have "inline-views". so i don't understand how the eroor could occur.
Edited by: CharlesRoos on 22.10.2010 16:38 -
Subquery + order by = syntax error?
Hi Oracle-SQL hackers ...
Anyone knows why oracle doesn't allow an ORDER BY clause, inside a subquery???.
For example, the following works ok:
SELECT * FROM ( (select 1 as kk from dual) MINUS (select 1 as kk from dual) )
But if you put an ORDER BY in any subquery, you receive this error message:
ORA-00907: missing right parenthesis
I've tested this on versions: 8.1.7 and 9.2.0. Is it a parser "feature", or what?
Thanks in advance.
saludos
dario estepario...I suspect that the problem would be that the inner ORDER BY would cause Oracle to do lots of work but wouldn't provide any guarantee of a benefit. Your average programmer might expect that the inner "order by" would have some implication on the results from the whole query (i.e. that after the minus operation, the results would be ordered) which is likely to be true most of the time, but occasionally false. It may be that Oracle expected that this feature would tend to cause significant frustration because it allowed people to write queries with obscure bugs without yielding any benefit.
Justin
Maybe you are looking for
-
Null Values to internal tables
I need to pass Null Value to couple of fields in Internal table and one of them is type i. Any way to do it?
-
How many custom-id:s / custom-numbers etc. customer has to register(minimum)in order to purchase All f-secure products on ALL possible platforms?
-
Can you lay out books in Pages 09
I am using an old version of QuarkEXpress and would like to use Pages 09 that I just purchased. Is it possible to layout small books (16-32 pages) with Pages?
-
Is there a Dvorak keyboard layout available for the iPhone? While I touch type on the standard QWERTY keyboard, I find the Dvorak layout much better suited for typing with my thumbs. Who do I ask for one if there isn't one now? Thanks, Byron
-
NLAG material to be add in BOM.
*Dear PP gurus,* *have a nice day.* *pls help me for adding the Nlag material in CS02 - BOM.* *Rgds.* *Muthu*