473,378 Members | 1,346 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,378 software developers and data experts.

pl/sql problem, please help!!!

1
hi,

I'm using nested explicit cursors, the outer cursor retrieves info about a student and the inner retrieves info about credits for a course, grade (where not null) for each student . I need to calculate gpa SUM(credits * grade points)/SUM(credits). See below, the grade_points_cursor doesn't seem to be reading the if part, I'm not getting any kind of results on the calculations.

DECLARE

CURSOR student_cursor IS
SELECT s.s_id, concat(concat(s_first, ' '), s_last) Name
FROM student s, enrollment e
WHERE e.s_id = s.s_id(+)
AND grade IS NOT NULL;

-- student_row student_cursor%ROWTYPE;

grade_points_A NUMBER;
grade_points_B NUMBER;
grade_points_C NUMBER;
grade_points_D NUMBER;
grade_points_F NUMBER;
total_grade_points NUMBER;
credits_A NUMBER;
credits_B NUMBER;
credits_C NUMBER;
credits_D NUMBER;
total_credits NUMBER;
gpa NUMBER(3,2);
CURSOR grade_points_cursor IS
SELECT s_id, credits, grade
FROM enrollment e, course c, course_section cs
WHERE e.c_sec_id = cs.c_sec_id
AND cs.course_id = c.course_id
AND grade IS NOT NULL;


-- grade_points_row grade_points_cursor%ROWTYPE;

BEGIN
FOR student_row IN student_cursor
LOOP
DBMS_OUTPUT.PUT_LINE('+' || ' +');
DBMS_OUTPUT.PUT_LINE('Student: ' || student_row.Name);
DBMS_OUTPUT.PUT_LINE('s_id = ' || student_row.s_id);


FOR grade_points_row IN grade_points_cursor
LOOP

if grade_points_row.grade = 'A' THEN
grade_points_A := grade_points_A + (grade_points_row.credits*4);
credits_A := credits_A + grade_points_row.credits;
elsif grade_points_row.grade = 'B' THEN
grade_points_B := grade_points_B + (grade_points_row.credits*3);
credits_B := credits_B + grade_points_row.credits;
elsif grade_points_row.grade = 'C' THEN
grade_points_C := grade_points_C + (grade_points_row.credits*2);
credits_C := credits_C + grade_points_row.credits;
elsif grade_points_row.grade = 'D' THEN
grade_points_D := grade_points_D + (grade_points_row.credits*1);
credits_D := credits_D + grade_points_row.credits;
elsif grade_points_row.grade = 'F' THEN
grade_points_F := 0;
end if;
total_grade_points := grade_points_A + grade_points_B + grade_points_C + grade_points_D;
total_credits := credits_A + credits_B + credits_C + credits_D;
gpa := (total_credits * total_grade_points)/(total_credits);
-- DBMS_OUTPUT.PUT_LINE('GPA: ' ||gpa || ' ' || 'Grade Points = ' || total_grade_points);

END LOOP;
END LOOP;

-- total_grade_points := grade_points_A + grade_points_B + grade_points_C + grade_points_D;
-- total_credits := credits_A + credits_B + credits_C + credits_D;
-- gpa := (total_credits * total_grade_points)/(total_credits);

DBMS_OUTPUT.PUT_LINE('GPA: ' ||gpa || ' ' || 'Grade Points = ' || total_grade_points);
--DBMS_OUTPUT.PUT_LINE('GPA: ' ||current_gpa || ' ' || 'Grade Points = ' || current_grade_points);
END;
Apr 25 '07 #1
0 1166

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

Similar topics

15
by: Holly | last post by:
I'm trying to get this page to look the same in Netscape and IE. I have a box that says 'Upcoming Events' on the lower left of the page. It's supposed to have a gray background, but in NS 4.x it...
1
by: Hui | last post by:
Hi gurus, I'm having data conversion (marshalling) problems with VB.NET DLL calling a old C DLL. The problem is that when the return type is a Long, I'm getting some garbage large number. eg....
15
by: Alfonso Morra | last post by:
Hi, I have some code from an example, that I want to retrofit into my project. The code from the example has the following line: SharedAppenderPtr myAppender( new...
25
by: bruce.james.lee | last post by:
hi i have a problem with integer subtraction in C. printf("%d", c < (a - b)); a is got from a #define and is 0x80000000 and b is got from input and is also 0x80000000. c is ffffffff (-1). Now,...
4
by: Madhu Gopinathan | last post by:
Hi All, I am faced with a horrible hang problem. I have a COM exe server that executes some tasks. The task execution manager is a thread that manages the pool of threads, which is 4 per processor....
1
by: Simon Harvey | last post by:
Hi, I'm hoping someone can help me witht he following problem: I have a fairly simple page that has a sort form and a button for adding the forms details to an arraylist. When the button is...
4
by: Jeff User | last post by:
Hi I tryed to solve this problem over in the framework.asp group, but still am having trouble. Hope someone here can help. using .net 1.1, VS 2003 and C# I have an asp.DataGrid control with a...
3
by: gauravkg via DotNetMonster.com | last post by:
Hi i have a problem I have a product product_name=taj Mahal product_id=111 i and different users will be putting reviews title and review description. this is the following xml file i...
1
by: rxgmoral | last post by:
dll problem,help me:) i create dll project ,the dll is Use MFC in a Static Library i hope exe call ListCtrl class from dll ==================DLL====================...
8
by: Dhananjay | last post by:
hello everyone Do you have any information how to generate a tool using .net which is used to translate the web page contents to html format. Plz reply me asap Thanks in advance Dhananjay
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...

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.