Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 trianlge table

Author  Topic 

sivasc
Starting Member

3 Posts

Posted - 2007-04-26 : 23:36:48
hi
i am trying to solve this in oracle
but having some trouble
1. The triangle table has three columns, side_a, side_b and side_c. These represent the three sides of a triangle. Write a function or procedure in a package that will read all rows out of this table and output to a different table of your own creation whether the values contained form an equilateral triangle, an isosceles triangle or a scalene triangle, based on:
• An equilateral triangle is a triangle with all three sides of equal length.
• An isosceles triangle is a triangle with any two sides of equal length.
• A scalene triangle is a triangle with no two sides equal.

2. In a separate package, create a function or procedure to adequately test your code by populating values to the triangle table, executing the code in step 1, reading the output from the output table and validating the output to the expected values. Your test code should essentially assert that three particular values result in some expected output. Your tests should not contain their own logic except to determine whether or not your assertion matches what your program outputs.

so far i tried doing

CREATE OR REPLACE Procedure Addsides (side_a in number, side_b in number, side_c number)
Is
Cursor c_traingle is
Select side_a,side_b,side_c from triangle;

p varchar2(10);
Begin
For rec in c_traingle
loop
if (rec.side_a = rec.side_b and rec.side_a =rec.side_c and rec.side_b = rec.side_c)
then
p := 'Equilateral';
end if;
if (rec.side_a = rec.side_b or rec.side_b = rec.side_c or rec.side_a = rec.side_c)
then
p := 'Associate';
end if;
if (rec.side_a + rec.side_b > rec.side_c or rec.side_a + rec.side_c >rec.side_b or rec.side_b + rec.side_c >rec. side_a )
then
p := 'Scalen';
end if ;
end loop;

execute immediate
'Insert into triangle1 values(rec.side_a, rec.side_b, rec.side_c, p)';
commit;
end Addsides;

but getting error and not able to d the second part if someone can help it will great

pbguy
Constraint Violating Yak Guru

319 Posts

Posted - 2007-04-27 : 00:35:00
Post in an approapriate forum and for logic search in this forum for "triangle"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-27 : 01:10:13
Same text book? Same lectures?
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81781


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-27 : 01:11:56
If you are using ORACLE, maybe the forum www.orafaq.com is better suited for you?
Or www.dbforums.com?



Peter Larsson
Helsingborg, Sweden
Go to Top of Page

sivasc
Starting Member

3 Posts

Posted - 2007-04-27 : 04:38:08
quote:
Originally posted by Peso

If you are using ORACLE, maybe the forum www.orafaq.com is better suited for you?
Or www.dbforums.com?



Peter Larsson
Helsingborg, Sweden



Thanks for your help Peter

siva
Go to Top of Page
   

- Advertisement -