Amit Kumar Singh

Amit Kumar Singh

  • 387
  • 3.9k
  • 195.9k

Related to Functions

Nov 10 2020 8:36 AM
Hi Friends,
 
I am new to oracle database  and my requirements is :
 
Please create a function with commented code to calculate the subtotal which is returned to the calling program.
 
The following particulars to help you with the task:
 
? The table for the data is BB_Basketitem
? Subtotal column is an aggregated calculated field (quantity * price) based on basket id that is a parameter of the function
? Define a local variable in the function to hold the subtotal calculated (hint:
 
SELECT……….. INTO local variable 
CREATE OR REPLACE FUNCTION SUBTOTALS
RETURN number
IS
total number(8);
BEGIN
Select Quantity * Price INTO total from BB_Basketitem where idBasket = 5;
RETURN total;
END;
DECLARE
result number(8);
BEGIN
result := SUBTOTALS();
dbms_output.put_line('Total is' || result);
END;
 
Pls. help me in this

Answers (1)