Subquery returned more than one value
Hi,
I have this statement which has been working fine - not I get a 'Subquery returned more than one value" error:
SELECT
'WAS3' AS 'Rec ID',
E.EecEEID AS 'Emp ID',
eepNameFirst AS 'First Name',
eepNameLast AS 'Last Name',
EecDateOfOriginalHire AS 'Service Date',
(SELECT DATEDIFF(YEAR, EecDateOfOriginalHire, getdate()) from empcomp EC WHERE EC.EecEEID = E.EECEEID) as 'Yrs of Serv'
FROM
EmpPers
JOIN EmpComp E
ON E.eecEEID = eepEEID
JOIN Company
ON eecCoID = cmpCoID
WHERE
EecDateOfTermination IS NOT NULL
AND EXISTS
(SELECT 1
FROM EmpComp e2
WHERE e2.EecEEID = E.EecEEID
--AND e2.eecEmplStatus <> 'A')-- changed to <> ...this WAS/is to filter out anyone that was termed then re-hired
--AND E.EecTermReason NOT IN ('I01','I02','I03','I14','I22','V05','V07','V09','V12','V22','V13', 'TRO')
AND E.eecDateOfTermination
IN (SELECT (EC.eecDateOfTermination)
FROM EMPCOMP EC
WHERE EC.EecEEID = E.EECEEID
AND EC.eecDateOfTermination IS NOT NULL
AND eC.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
AND EC.eecDateOfTermination <=DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6)
AND e.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
AND E.eecDateOfTermination <= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6)))
--AND eC.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,('12/30/2007')),0)
-- AND EC.eecDateOfTermination <=DATEADD(wk,DATEDIFF(wk,0,('12/30/2007')),6)
-- AND e.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,('12/30/2007')),0)
-- AND E.eecDateOfTermination <= DATEADD(wk,DATEDIFF(wk,0,('12/30/2007')),6)
-- AND E.eecDateOfTermination IS NOT NULL ))
--added below per Paul Cottle to exclude employeess less than four years
AND E.eecdateoforiginalhire >=dateadd(year,-4, CURRENT_TIMESTAMP)
qeqw
Check this, if it works:
SELECT
'WAS3' AS 'Rec ID',
E.EecEEID AS 'Emp ID',
eepNameFirst AS 'First Name',
eepNameLast AS 'Last Name',
EecDateOfOriginalHire AS 'Service Date',
DATEDIFF(YEAR, EecDateOfOriginalHire, getdate()) as 'Yrs of Serv'
FROM EmpPers
JOIN EmpComp E ON E.eecEEID = eepEEID
JOIN Company ON eecCoID = cmpCoID
WHERE EecDateOfTermination IS NOT NULL
AND EXISTS
(SELECT 1
FROM EmpComp e2
WHERE e2.EecEEID = E.EecEEID
AND E.eecDateOfTermination
IN (SELECT (EC.eecDateOfTermination)
FROM EMPCOMP EC
WHERE EC.EecEEID = E.EECEEID
AND EC.eecDateOfTermination IS NOT NULL
AND eC.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
AND EC.eecDateOfTermination <=DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6)
AND e.eecDateOfTermination >= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
AND E.eecDateOfTermination <= DATEADD(wk,DATEDIFF(wk,0,GETDATE()),6)))
AND E.eecdateoforiginalhire >=dateadd(year,-4, CURRENT_TIMESTAMP)
If this post answers your query, please click "Mark As Answer" or "Vote as Helpful".
Similar Messages
-
TWO ERRO ORA-01427: single-row subquery returns more than one row
Hi,
I have a procedure which contains a cursor. If i run the select statement in the cursor separetly, it returns only value and works fine. But the same select statement in the cursor of a procedure throws me the error as below:
TWO ERRO ORA-01427: single-row subquery returns more than one row
Not sure what going on...any help appreciated.
Below is the select statement:
SELECT DISTINCT PSE.PARENT_POSITION_ID,
(SELECT DISTINCT PPD1.SEGMENT2
FROM PER_POSITION_DEFINITIONS PPD1,
HR_ALL_POSITIONS_F HAPF2,
PER_POS_STRUCTURE_ELEMENTS PSE2
WHERE TRUNC(SYSDATE) BETWEEN
HAPF2.EFFECTIVE_START_DATE AND
HAPF2.EFFECTIVE_END_DATE
AND PPD1.POSITION_DEFINITION_ID =
HAPF2.POSITION_DEFINITION_ID
AND
HAPF2.POSITION_ID = PSE2.PARENT_POSITION_ID
AND PSE2.PARENT_POSITION_ID =
PSE.PARENT_POSITION_ID
AND ROWNUM = 1) SEGMENT2,
(SELECT DISTINCT PAPF1.FIRST_NAME || ' ' ||
PAPF1.LAST_NAME CHIEF_NAME
FROM PER_ALL_PEOPLE_F PAPF1,
PER_ALL_ASSIGNMENTS_F PAAF1
WHERE TRUNC(SYSDATE) BETWEEN
PAPF1.EFFECTIVE_START_DATE AND
PAPF1.EFFECTIVE_END_DATE
AND TRUNC(SYSDATE) BETWEEN
PAAF1.EFFECTIVE_START_DATE AND
PAAF1.EFFECTIVE_END_DATE
AND PAAF1.POSITION_ID = PSE.PARENT_POSITION_ID
AND PAPF1.PERSON_ID = PAAF1.PERSON_ID
AND ROWNUM = 1) CHIEF_NAME
FROM PER_POS_STRUCTURE_ELEMENTS PSE,
HR_ALL_POSITIONS_F HAPF,
PER_POSITION_DEFINITIONS PPD
WHERE PSE.SUBORDINATE_POSITION_ID = 52744
AND TRUNC(SYSDATE) BETWEEN HAPF.EFFECTIVE_START_DATE AND
HAPF.EFFECTIVE_END_DATE
AND HAPF.POSITION_ID = PSE.SUBORDINATE_POSITION_ID
AND HAPF.POSITION_DEFINITION_ID = PPD.POSITION_DEFINITION_ID;
Thanks
PK
Edited by: user539616 on Jun 30, 2009 6:30 PMHi,
The cursor has a different parameter? Maybe the query is not exactly the same. Could you check this?
This is your query (formatted):
SELECT DISTINCT PSE.PARENT_POSITION_ID,
(SELECT DISTINCT PPD1.SEGMENT2
FROM PER_POSITION_DEFINITIONS PPD1,
HR_ALL_POSITIONS_F HAPF2,
PER_POS_STRUCTURE_ELEMENTS PSE2
WHERE TRUNC(SYSDATE) BETWEEN HAPF2.EFFECTIVE_START_DATE AND
HAPF2.EFFECTIVE_END_DATE
AND PPD1.POSITION_DEFINITION_ID = HAPF2.POSITION_DEFINITION_ID
AND HAPF2.POSITION_ID = PSE2.PARENT_POSITION_ID
AND PSE2.PARENT_POSITION_ID = PSE.PARENT_POSITION_ID
AND ROWNUM = 1) SEGMENT2,
(SELECT DISTINCT PAPF1.FIRST_NAME || ' ' || PAPF1.LAST_NAME CHIEF_NAME
FROM PER_ALL_PEOPLE_F PAPF1,
PER_ALL_ASSIGNMENTS_F PAAF1
WHERE TRUNC(SYSDATE) BETWEEN PAPF1.EFFECTIVE_START_DATE AND
PAPF1.EFFECTIVE_END_DATE
AND TRUNC(SYSDATE) BETWEEN PAAF1.EFFECTIVE_START_DATE AND
PAAF1.EFFECTIVE_END_DATE
AND PAAF1.POSITION_ID = PSE.PARENT_POSITION_ID
AND PAPF1.PERSON_ID = PAAF1.PERSON_ID
AND ROWNUM = 1) CHIEF_NAME
FROM PER_POS_STRUCTURE_ELEMENTS PSE,
HR_ALL_POSITIONS_F HAPF,
PER_POSITION_DEFINITIONS PPD
WHERE PSE.SUBORDINATE_POSITION_ID = 52744
AND TRUNC(SYSDATE) BETWEEN HAPF.EFFECTIVE_START_DATE AND HAPF.EFFECTIVE_END_DATE
AND HAPF.POSITION_ID = PSE.SUBORDINATE_POSITION_ID
AND HAPF.POSITION_DEFINITION_ID = PPD.POSITION_DEFINITION_ID;Tips: To put formatted code you must use {noformat}{noformat} tags, start tag and end tag are the same,you don't need to put '/' in the close tag.
Regards, -
ORA-01427: single-row subquery returns more than one row HELP
I need to update baemployee.Stock_nbr field with select substr(C.CHECK_DIGIT, 3, 10)
from EMP_CHECK_DIG c where C.EMPLOYEE = e.EMPLOYEE
Please help.
update baemployee e
set Stock_nbr = (select substr(C.CHECK_DIGIT, 3, 10)
from EMP_CHECK_DIG c where C.EMPLOYEE = e.EMPLOYEE)
where exists
(select C.CHECK_DIGIT
from EMP_CHECK_DIG c where C.EMPLOYEE = e.EMPLOYEE)
and exists (select 1 from EMPLOYEE ee where ee.employee = e.employee and ee.emp_status like 'A%');
ORA-01427: single-row subquery returns more than one rowHi,
Welcome to the forum!
Whenever you have a question, please post some sample data, so that people can re-create the problem and test their solutions.
CREATE TABLE and INSERT statements, like the ones below, are great:
CREATE TABLE baemployee
( employee NUMBER (4)
, stock_nbr VARCHAR2 (10)
INSERT INTO baemployee (employee, stock_nbr) VALUES (1234, 'FUBAR');
CREATE TABLE employee
( employee NUMBER (4)
, emp_status VARCHAR2 (10)
INSERT INTO employee (employee, emp_status) VALUES (1234, 'ACTIVE');CREATE TABLE AS is good, too:
CREATE TABLE emp_check_dig
AS SELECT 1234 AS employee, 'AA1234567890ZZZ' AS check_digit FROM dual
UNION ALL SELECT 1234, 'AA2121212121ZZZ' FROM dual
;Also post the results you want from that data. In this case, the results would be the contents of the baemployee table after you run the UPDATE.
Would you want:
employee stock_nbr
1234 1234567890or would you want
employee stock_nbr
1234 2121212121If you run the UPDATE statement you posted with the data above, you'll get the "ORA-01427: single-row subquery returns more than one row" error, and you can see what causes it: there is more than one row from emp_check_dig that could be used to UPDATE the same row of baemployee. Say what you want to do in this situation (and why), and someone will help you find a way to do it. -
Update gives "single-row subquery returns more than one row"
Hi,
I have to update a table by getting values from two other tables. While doing that the inner query returns more than one value. I am not sure how to implement the logic without returning more than one row in sub quesry. Need help on that.
My query:
update buf_office_str o
set o.manager_ident =
(select sp.ident
from se2_r_src_sourceperson sp ,
(select distinct director_name, team_name from buf_sales_dump )t
where SP.SRCNAME = upper(substr(t.director_name,instr(t.director_name,' ')+1,length(t.director_name))||', '||substr(t.director_name,1,instr(t.director_name,' ')-1 ) )
and o.office_descr = t.team_name
Basically the query gets teh manager id from sp table where sp.srcname = t.team-name.
The office descr should be equal to the team_name.
This is the logic I am working towards:
For each office, i get the office_descr and get corresponding team_name. Match the team's director_name (from table t) with the sp.name and return the employee's id (sp.ident) for that office_descr.
I need to update all 50 offices with corresponding managerid for that office in buf_office_str table.
Is it possible to get done in one update? Pls let me know.Hi,
"Single-row subquery returns more than one row" is one of those error messages that actually means what it says: the correlated sub-query in your SET clause is sometimes returning 2 or more rows .
The solution could be as simple as making the sub-query SELECT DISTINCT , as its in-line view, t, already is.
It's possible you have bad data, or a mistake in your statement.
To find the problem cases, you can run something like this:
WITH sub_q AS
SELECT -- DISTINCT ?
sp.ident
, t.team_name
, COUNT (*) OVER (PARTITION BY t.team_name) AS cnt
FROM se2_r_src_sourceperson sp
, ( SELECT DISTINCT director_name
, team_name
FROM buf_sales_dump
) t
WHERE sp.srcname = UPPER ( SUBSTR ( t.director_name
, INSTR ( t.director_name
) + 1
, LENGTH (t.director_name)
|| ', '
|| SUBSTR ( t.director_name
, 1
, INSTR ( t.director_name
) - 1
SELECT o.* -- or whatever helps you
, sq.*
FROM buf_office_str o
JOIN sub_q sq ON o.office_descr = sq.team_name
WHERE sq.cnt > 1
;If you'd like more help, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables as they exist before the UPDATE, and the results you want from that data (that is, the contents of buf_office_str after the UPDATE). Make sure the problem occurs with the sample data you post. -
Can Function Return more than One Values ??
Hi Experts,
I would like to ask you Can Function Return more than one values. I Used Function with Out and In out parameter and its working Fine..
1. what is harm using Out and In out parameter in function
2. if we can use Out and In out parameter in Function so what is deffernce between procedure and Function.
3. Is there any Other Way Though which we can return more the One values in Function.
Please advice me...
Thanks
Umesh GoelYes/No.
You can return multiple value from function. But, in PL/SQL and not in a SQL.
The following examples demonstrate that -
SQL*Plus: Release 9.2.0.1.0 - Production on Wed Mar 28 17:41:15 2007
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> create or replace package glob
2 as
3 b varchar2(20);
4 c varchar2(20);
5 end;
6 /
Package created.
SQL>
SQL> create or replace function test_mul_out(a in number)
2 return number
3 is
4 cursor c1(eno in number)
5 is
6 select ename,job,sal
7 from emp
8 where empno = eno;
9
10 rec c1%rowtype;
11 d number(10);
12 begin
13 open c1(a);
14 loop
15 fetch c1 into rec;
16 exit when c1%notfound;
17 glob.b:= rec.ename;
18 glob.c:= rec.job;
19 d:= rec.sal;
20 end loop;
21 close c1;
22 return d;
23 end;
24 /
Function created.
SQL> set serveroutput on
SQL>
SQL> declare
2 zz number(10);
3 begin
4 select test_mul_out(7777)
5 into zz
6 from dual;
7
8 dbms_output.put_line('Ename: '||glob.b);
9 dbms_output.put_line('Job: '||glob.c);
10 dbms_output.put_line('Sal: '||zz);
11 end;
12 /
Ename: Avik
Job: CLERK
Sal: 3456
PL/SQL procedure successfully completed.
SQL> Regards.
Satyaki De. -
Possible to return more than one value?
If I have a somethign like this:
public int test()
return 5;
}Is it possible to have test() return more than one value? And if it can, can you post an example showing how?Could you post an example of how to do this?If you do not know how to define a class, you need to start from the very beginning.
Sun's basic Java tutorial
Sun's New To Java Center. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
http://javaalmanac.com. A couple dozen code examples that supplement The Java Developers Almanac.
jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
Bruce Eckel's Thinking in Java (Available online.)
Joshua Bloch's Effective Java
Bert Bates and Kathy Sierra's Head First Java.
James Gosling's The Java Programming Language. Gosling is
the creator of Java. It doesn't get much more authoratative than this. -
Can a method return more than one value?
I was studying for my biology exam and I got bored and I started thinking and then I wandered if a method can return more than one value...?
For example, if I want a method to return a row a column, I make a method that returns an int. But what if I want to return two ints? Or what If I want to return an integer and a string? Is it possible or do I have make two methods, each returning one thing?
What I always did until now is is I want for example to return a few integers, I would store them in a String and then when I return the string, I parse the numbers out using stringtokenizer... but it doesn't look like the best way... and it's pretty annoying...I'm weak on terminology, hence I don't even know what
AFAIK means...As Far As I Know
This doesn't really make sense for me. It's more
efficient to make a whole class just for two
integers, than having two methods? Efficiency is not the point. The flow is.
If you have two methods, the caller must be aware of both of them. The other way it's up to the callee.
Just because the
two integers are related to each other? Doesn't
making a class require more memory usage than just
making two one-line methods?The memory usage is not wholly irrelevant, but there are ways to handle that (caching, inlining, etc.).
It's a bit hard to counter your point for me, but if you had done a lot of GUI painting stuff, you'd see all those Points, Dimensions, Rectangles, you name it, are quite invaluable. -
Can oracle function return more than one value
Hi All
please answer can oracle function return more than one value
need one schenario
regardsCan any function, irrespective of the language, return multiple values?
OF COURSE NOT!!
So why do you think Oracle will now suddenly do it differently than all other languages? Never mind that it is impossible for a function (a unit/module of code) returning a memory address, to return multiple memory addresses. The machine code that does that, has not been yet been designed/implemented.
I am continually amazed that this question is asked. It is about something so fundamental in almost every single 3rd and 4th generation language... something that is taught right at the start... the definition of what a procedure and what a function is.
Sorry, but I simply cannot pull punches on this subject and smooth it over. There is something fundamentally wrong with your training as a programmer if you have to ask such a question about a function.
And whatever programming skills you build on such a foundation, will be seriously lacking.
I kindly suggest that you get back to the very basics of programming - and review and revisit until you fully understand it. There are no shortcuts in becomming a good programmer.
Message was edited by:
Billy Verreynne -
ORA-01427: single-row subquery returns more than one row
I have a problem something like this:
table A
id col1 after_update
1 ? 11
2 ? 22
3 ? 33
3 ? 44
3 ? 55
4 ? 66
5 ? 88
5 ? ? /* won't be updated */
6 ? 99
7 ? null /* updated to null */
9 ? 20
table B
id col2
1 11
2 22
3 33
3 44
3 55
4 66
4 77
5 88
6 99
8 10
9 20
When I try the query:
update table A
set col1 = (select distinct col2 from table B) it gives me the error ORA-01427: single-row subquery returns more than one row
When I try the query:
update (select x.col1 x_col1,y.col2 y_col2
from (select id,col1,row_number() over (partition by id order by null /*col1*/) rn
from table_a
) x,
(select id,col2,row_number() over (partition by id order by col2) rn
from table_b
) y
where x.id = y.id
and x.rn = y.rn
set x_col1 = y_col2
it gives me an error saying ora-01779 :cannot modify a column which maps to a non key- preserved table. It shows the same even when I add the key to the tables.
My Database version is Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
Kindly help.Another way, not waterproof too relay on rowid, but in your case it could work.
You have to verify it by yourself
update test_a aa
set col1 =
(select b.col1 from
(select
id, col1
,row_number() over
(partition by id order by col1) rn
from table_b) b,
( select
rowid, id, col1
,row_number() over (partition by id order by col1) sort_order
from test_a
) a
where
a.id=b.id
and
sort_order = rn
and
aa.rowid=a.rowid
)Edited by: chris227 on 03.04.2013 06:42
Table name corrected -
ORA-01427: single-row subquery returns more than one row -- no solution
Hello to all:
I have to tables:
Table a anwender (Email,Dept). --> all fields are filled
Table b dingo (Name,email,dept) --> all fields are filled
I now want to update the table a with the data from table b:
update anwender a set a.abteilung = ( select distinct b.abteilung from dingo b where b.email = a.email);
Then I got the error: ORA-01427: single-row subquery returns more than one row
Every dept is about 100x in the database, so it is clear that i got more than one row back. But how can I update the table now?Okay, I got several duplicates, and I deletet a lot of data in my database.
Now I want to remove all entries with more than one departments per mail adresses.
a
select email,count(abteilung) from dingo group by email having count(abteilung)>1 order by count(abteilung)
shows me all the fake mailadresses.
But a
delete from dingo where email in (select email,count(abteilung) from dingo group by email having count(abteilung)>1 order by count(abteilung) );
gives me a
SQL Error: ORA-00907: missing right parenthesis
I´m very confused now ...
Oops, now I got the solution:
delete from dingo where email in (select email from (select email,count(abteilung) from dingo group by email having count(abteilung)>1 )) ;
Edited by: user8309218 on Dec 18, 2009 6:24 AM -
Still problem with single-row subquery returns more than one row
//i did join each table but query runs forever and fail. looks Cartesian join so comes up the following SQL
the following query has a problem. would you please help me, please
Select pe.expense_id
,PE.CODE
,PE.PROJECT_ID
,PE.LDATE
,PE.INAMOUNT pe_amount
,(SELECT TRX.INV_AMOUNT FROM TRXEXPENSES TRX
WHERE PE.EXPENSE_ID=TRX.EXPENSE_ID) AS invamount
,(SELECT RE.AMOUNT FROM REEXPENSES RE WHERE
PE.EXPENSE_ID=RE.EXPENSE_ID) AS recogamount
,(SELECT MLE.M_AMOUNT FROM MATEXPENSES MLE
WHERE PE.EXPENSE_ID=MLE.EXPENSE_ID) AS matamount
from EXPENSES PE
where pe.expense_id=5600
group by expense_id,CODE,PROJECT_ID,LDATE,inamount
//get error message
ora-01427:single-row subquery returns more than one row
//check database
select expense_id,count(*) from TRXEXPENSES
where expense_id in(select expense_id from
expenses)
group by expense_id
having count(*)>1
//here is duplicate record a lot
EXPENSE_ID COUNT(*)
4176 2
5600 3
9572 2
9573 2
9574 2Yes, Expense_id has so many returning rows for trx.inv_amount from trxexpenses in subquery.
I want to show Expense_id with retruning rows using the above query.
ex)The result of the query is like that;
Expense_ Id project_id Ldate InvAmount RecogAmount MatAmount
5600 123 3/2/02 $100(InvAmount)
5600 432 3/12/02 $200(recogAmount)
5600 432 4/12/02 $250(MatAmount)
Thank you so much
Message was edited by:
user524064
Message was edited by:
user524064 -
Single-row subquery returns more than one query
Hi,
i'm receiving the following error: Single-row subquery returns more than one query. I have no idea how I should debug this query. For all I know, the subqueries can only return 1 row... :S
I only have Oracle SQL Developer to run/test my queries. I can run the query with ROWNUM < 5000, which gives no errors. If I run with ROWNUM > 5000 and ROWNUM < 6000 then the error appears....
Here's the query:
with
DATES as
(select (select min(REC_DATE) from STOCK) as FROM_DT, (select max(CHANGE_DATE) from STOCK_ADJUST) as TO_DT from DUAL),
MONTHS as
(select add_months(trunc(FROM_DT,'MM'),ROWNUM-1) as DT from DATES connect by ROWNUM <= months_between(TO_DT, FROM_DT)+1),
CALCULATIONS as
(select
PNM.PNM_AUTO_KEY PNM_KEY,
MONTHS.DT DT,
NVL((select sum(stm.qty_rec) from stock stm WHERE STM.REC_DATE < MONTHS.DT AND STM.PNM_AUTO_KEY = PNM.PNM_AUTO_KEY GROUP BY pnm_auto_key),0) INCOMING,
NVL((select sum(saj.qty_adj) from stock_adjust saj
inner join stock stm on saj.stm_auto_key = stm.stm_auto_key
inner join parts_master pnm on stm.pnm_auto_key = pnm.pnm_auto_key where SAJ.CHANGE_DATE < MONTHS.DT AND STM.PNM_AUTO_KEY = PNM.PNM_AUTO_KEY group by pnm_auto_key),0) OUTGOING
from MONTHS, PARTS_MASTER PNM)
SELECT
ROWNUM, CALCULATIONS.PNM_KEY PNM_AUTO_KEY, CALCULATIONS.DT COUNT_DATE,CALCULATIONS.INCOMING QTY_RECEIVED, CALCULATIONS.OUTGOING QTY_USED, (CALCULATIONS.INCOMING + CALCULATIONS.OUTGOING) QTY_BALANCE
FROM
CALCULATIONS;Edited by: user574699 on Nov 17, 2008 2:10 AM code formattingI suppose (how can i be sure?) that the queries in question are:
NVL((select sum(stm.qty_rec) from stock stm WHERE STM.REC_DATE < MONTHS.DT AND STM.PNM_AUTO_KEY = PNM.PNM_AUTO_KEY GROUP BY pnm_auto_key),0) INCOMINGand
NVL((select sum(saj.qty_adj) from stock_adjust saj
inner join stock stm on saj.stm_auto_key = stm.stm_auto_key
inner join parts_master pnm on stm.pnm_auto_key = pnm.pnm_auto_key where SAJ.CHANGE_DATE < MONTHS.DT AND STM.PNM_AUTO_KEY = PNM.PNM_AUTO_KEY group by pnm_auto_key),0) OUTGOINGBoth queries have an aggregate function based on the grouping on PNM_AUTO_KEY. Both WHERE clauses also include the = PNM_AUTO_KEY statement. So how can these return more than 1 row?
As I stated I cannot run the subqueries without the rest. The database contains over 200000 PNM_AUTO_KEYS, and I don't know which one is causing the problems.... -
Update column with subquery returning more than one row
Hi Everybody,
Please let me know how to handle this. I am writing update statement in procedure with subquery and it is returning multiple rows. Please help me, how i can handle this :
UPDATE TABLEA A
SET A.ERROR_MESSAGE = (Select B.XERROR_MESSAGE from TABLEB B, TABLEA A WHERE B.id = A.id)
WHERE A.id = (Select B.id from TABLEB B, TABLEA A WHERE B.id = A.id);
(Select B.XERROR_MESSAGE from TABLEB B, TABLEA A WHERE B.id = A.id) --- This subquery is returning more than one rows. How i can handle this in Pl/SQL?
Please let me know. I will be very thankful to you all.
I will really appreciate your replies and comments.
Thank youTry getting rid of tablea in your subqueries. You already have it in the UPDATE statement.
UPDATE TABLEA A
SET A.ERROR_MESSAGE = (Select B.XERROR_MESSAGE
from TABLEB B
WHERE B.id = A.id
WHERE A.id = (Select B.id
from TABLEB B
WHERE B.id = A.id);You can also try a simple MERGE:
merge into tablea a
using tableb b
on (a.id = b.id)
when matched then update
set a.error_message = b.xerror_message; -
LOV Return more than one value to differenent items on page
New to express. I need to returm more than one value from list of LOV. For example: LOV => select a, b, c from testtable
I would then like to
a to populate item1 => with submit
b to populate item2 => hidden
c to pupulate item3 => hidden
as items on my page
when a user chooses a (with submit) in item1 b and c would populate also, b and c are hidden to the user. Any advice?Dear Frank
I did it as like as the following link lead me:
http://www.oracle.com/technology/obe/obe11jdev/11/adfbc_new_features/adfbc.html
The problem has been appeared when I attached the "Create" button and when press on it to create new record, then the "LOV" couldn't work correctly.
Thanks for your reply -
How to return more than one value from a function
hello everybody,
Can anyone tell me how to return more than a single value from a function, the problem is i have 4 points,
2 points form one line ,another 2 points form 2nd line ,each point is 3 dimensional(x,y,z coorinates) so i will pass these values to func(x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4), i will find the point of intersecton of two lines and i will get it as x,y,z , now how to return these 3 coordinates,usually the function returns only one value, please help me to solve it out.
Thanks.I think the easiest way or trick here is (easiest isn't always the best as we know, but atleast this one will work) to create simple data array. and pass that. Create an array with:
<code>
class justArray {
int x=0
int y=0;
int z= 0;
...somewhere
justArray[] points= new justArray[4];
points[0].x= ..
points[0].y= ..
points[0].z= ..
points[1].x= ..
return points[]
</code>
Maybe you are looking for
-
Thread settings in the Application Sharing Server
Hi,,, Iam doing the RTC Application Sharing implementation in the portal.For that we hve to enable the Application Sharing server,Configure the thread settings and finally we have to monitor the application sharing server. In the Configure the Thread
-
Hi there, I have a Table with an Order Id field as A0301000 A0301011 A0301012 A0307090 A0349870 A0301055 A0306056 and so on. I need an SQL Query to list out all the missing Order Ids between A0301000 and A0399999 for re-allocation. How's the above po
-
ITunes will not launc after latest update (Mac version)
Hi I was prompted by the software updater to update iTunes the other day, and so I did. When I first launched iTunes after the update, there was the usual window where i had to agree on Apple's this-and-that that always follows an update, but then no
-
hi this mycode : im biding data but i don't see on this column if ls_master_nd-state1 = '1'. > im use for enable column lr_column = lr_config->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'G_ANZHL' ). CREATE OBJECT lr_inputfield EXPOR
-
HT1688 Is there a way to retrieve deleted messages
How can I restore deleted messages to my iphone