473,408 Members | 2,402 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,408 software developers and data experts.

finding Difference in pl/sql

Hi
I have a problem.
I have two tables...table1 and table2.
table1 has the column latitude and sno(serial number) and table2 has the column lat and sno(serial number) .
i have to find the difference of all the values in column latitude from table 1 with all the values in column lat from table 2 and place it in a new table result having column difference

i have written this code but i am getting error as missing elements. Can anyone please guide me?
Expand|Select|Wrap|Line Numbers
  1. DECLARE
  2. NO INTEGER :=1;
  3. NUM INTEGER :=1;
  4. BEGIN
  5. for no in 1..10 loop
  6. for Num in 1..10 loop
  7. insert into result (difference)  select (select T1.latitude from table1 T1 where sno=no - select T2.table2 from table2 T2 where sno=Num ) from table1 T1, table2 T2 ;
  8. end loop;
  9. end loop;
  10. END;
Please help me in debugging this....
thanks a lot
Ashwini
Jan 25 '08 #1
3 1789
debasisdas
8,127 Expert 4TB
Try to use cursor for the purpose.
Jan 28 '08 #2
Expand|Select|Wrap|Line Numbers
  1.  
  2. DECLARE
  3.  NO INTEGER :=1;
  4.  NUM INTEGER :=1;
  5.  BEGIN
  6.  FOR no IN 10..10 LOOP
  7.  FOR Num IN 10..10 LOOP
  8.  INSERT INTO result (difference)
  9.  VALUES((SELECT T1.DEPTNO FROM DEPT T1 WHERE DEPTNO=no) - (SELECT T2.DEPTNO FROM DEPT T2
  10.                                                           WHERE DEPTNO=Num )) ;
  11.  END LOOP;
  12.  END LOOP;
  13.  END;
  14. /
  15.  
  16.  
Jan 30 '08 #3
Expand|Select|Wrap|Line Numbers
  1.  
  2. DECLARE
  3. NO INTEGER :=1;
  4. NUM INTEGER :=1;
  5. BEGIN
  6. FOR no IN 1..10 LOOP
  7. FOR Num IN 1..10 LOOP
  8. INSERT INTO result (difference)
  9. VALUES((SELECT T1.latitude FROM table1 T1 WHERE sno=no) - (SELECT T2.LAT FROM table2 T2 WHERE s
  10. END LOOP;
  11. END LOOP;
  12. END;
  13. /
  14.  
  15.  
Jan 30 '08 #4

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

Similar topics

11
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows...
22
by: Annajiat | last post by:
Hi, a) int grid; Which of the following is faster? 1. memset(grid,0,1010*1010); 2. memset(grid,0,sizeof(grid)); b) Is there any faster alternative to initializing memory? c) What is the...
15
by: cwsullivan | last post by:
Hi gang, I have a grid full of particles in my program, and I want to find an angle between two particles. I'm having trouble because it seems like the answer depends on whether or not the target...
4
by: lakshmananl | last post by:
hi, i am doing a report generation work in which i take the count of two columns. and i need to calculate the difference of the counted value as a new column. for example in SQL we use ...
5
by: prileep | last post by:
Hi, I want to find the the exact difference between two dates in seconds through MySQL query. Version: 4.1 Platform: Linux Source code: >select datediff('2007-01-09 10:24:46','2007-01-09...
1
by: indiarocks | last post by:
This is probably a very basic question, how do I find out the difference between two system time. I tried x1 = t1.clock x2 = t2.clock x2 - x1 doesn't seem to give me the difference. ...
17
by: abhimanyu.v | last post by:
Hi Guys, I have one doubt. The test program is given below. It uses two way of finding out the offset of a variable in structure. I executed the program and found the same result. My question...
2
by: Shamim1983 | last post by:
I want to find difference between 2 dates in number of months using GregorianCalendar utility. I want it to work fine considering the year having 28, 29, 30 or 31 days in month. It should give me...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.