Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Prompt User and Calculate?

352240Nov 11 2002
Hi, I need some guidance.
I want to take user input, store it in a value and then
calculate the average, now the output displayed will have to
only ouput all averages that are greater than the value entered.

So, if the user enters the number 50, I will only calculate the
average of all numbers that are greater than 50.

If the user inputs 30 I will calculate average of all numbers
that are greater than 30.
In both cases, all numbers that are less than the value entered
by the user will not be used for calculating the average.

Here's my code so far, It's only the beginning, but I don't
know how to go from where I am to where I need to be.

any ideas?


Code:
Declare
--local variables
average Course.Additional_fees%Type;
&Average_Of Number;
--Var for errMessages
staus Numeric:=0;
Begin
Select avg(Additional_fees)
From
Course
Where
average := Average_Of;
Exception
When
Value_Error Then
status := SQLCODE;
Dbms_Output.Put_Line('Value Error: ' ||SQLERRM(status));
Dbms_Output.Put_Line('Course Table: Exiting.');
When Invalid_Number Then
status := SQLCODE;
Dbms_Output.Put_Line('Invlaid Number Error: ' ||SQLERRM(status));
Dbms_Output.Put_Line('Course Table: Exiting.');
When Too_Many_Rows Then
status := SQLCODE;
Dbms_Output.Put_Line('To Many Rows Error: ' ||SQLERRM(status));
Dbms_Output.Put_Line('Course Table: Exiting.');
End;

/
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 10 2002
Added on Nov 11 2002
10 comments
397 views