473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

single-row subquery return more than one row

the following function show no any error when compiling it but when call this fuction it return the following error
"single-row subquery returns more than one row"
on the second select statement
even it return only one row when i check it indivisually
please check the code and give your kind suggestion.

trully yours

zia
Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE function IssuanceBalanceQTY (
  2. Issuance_ID in number
  3. )
  4. return number
  5. IS
  6. sumissuance number;
  7. sumreturn number;
  8. difference number;
  9. begin
  10.  
  11. -- GET SUM OF ISSUANCE QUANTITY ----
  12.    select sum(WT_BD_ISSUEDETAIL.QUANTITY) into sumissuance
  13.    from wt_bd_issuedetail
  14.    where wt_bd_issuedetail.ISSUANCE_ID = Issuance_ID;
  15.  
  16. -- GET SUM OF RETURN QUANTITY --
  17.    select sum(WT_BARDANARETURNDT.QUANTITY) into sumreturn
  18.    from  WT_BARDANARETURNDT
  19.    where wt_bardanareturndt.RETURNID= (select wt_bardanareturn.RETURNID from WT_BARDANARETURN where wt_bardanareturn.ISSUANCE_ID = Issuance_ID);
  20.  
  21. -- CALCULATE DIFFERANCE --
  22.    difference := (sumissuance - sumreturn);
  23.    return difference;
  24. end;
Sep 5 '07 #1
2 4285
amitpatel66
2,367 Expert 2GB
Use the below code for second Query and check if it works:

Expand|Select|Wrap|Line Numbers
  1. select sum(WT_BARDANARETURNDT.QUANTITY) into sumreturn
  2. from WT_BARDANARETURNDT
  3. where wt_bardanareturndt.RETURNID IN (select wt_bardanareturn.RETURNID from WT_BARDANARETURN where wt_bardanareturn.ISSUANCE_ID = Issuance_ID);
I have used IN instead of '=' sign for RETURNID. This might produce different result. If u expect only one RETURNID to be returned by the inner subquery then check if u r not missing any more JOIN between WT_BARDANARETURNDT and WT_BARDANARETURN

or

if the table WT_BARDANARETURN contains repeated values and u want only one, then use DISTINCT in Inner subquery
Sep 5 '07 #2
thanx mr amitpatel
i did it with IN and got the desired results

yours

zia ul murtaza
Sep 6 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: sinister | last post by:
The examples in the online manual all seem to use double quotes, e.g. at http://us3.php.net/preg_replace Why? (The behavior is different with single quotes, and presumably simpler to...
12
by: Dennis Plöger | last post by:
Hi all! I'm currently having some problems parsing a char array in c++. (And yes, I'm a half-newbie ;-)) Perhaps you can help me with this: #include <iostream> using std::cout; void...
5
by: Joel | last post by:
Hi, I incorporated a function in my code that whenever I use a string variable in an sql statement if the string contains a single quote it will encase it in double quotes else single quotes. ...
9
by: MrSpock | last post by:
1. Create a new Windows Application project. 2. Open the project properties and check "Make single instance application". 3. Build. 4. Go to the release folder and run the application. 5. Try to...
13
by: Kevin Walzer | last post by:
Which of the Windows/Unix package builders for Python applications is capable of creating single-file executables? I'm thinking of: 1. py2exe 2. Mcmillan Installer/PyInstaller 3. cxfreeze ...
11
by: Elmo | last post by:
Hi all! I am not very proud to ask this but here is my problem: string code = "\'13\'" The string code will have to contain following info: '51','52','63','other'... to get certain info...
3
by: Eric Layman | last post by:
Hi, I've saved data into the db by doing a replace() on single quote. Right now on data display on a datagrid, it shows double single quote. How do I make changes during run time of datagrid...
4
by: fniles | last post by:
I am looping thru DataReader and constructing a sql query to insert to another database. When the data type of the field is string I insert the field value using a single quote. When the value of...
2
by: Reporter | last post by:
I got the following example from http://www.evolt.org/article/User_Friendly_Forms_in_PHP/20/60144/index.html : echo '<tr><td>First name:</td><td><input type="text" name="first_name"...
3
by: sklett | last post by:
I suspect the answer might be in one of the words of my subject, but here goes anyway. I'm working on a system that will execute a very long (300+) chain of task objects. Here is some quick...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.