- Functions:
The following statement creates the functionget_bal on the sample tableoe.orders :
CREATE FUNCTION get_bal(acc_no IN NUMBER)
RETURN NUMBER
IS acc_bal NUMBER(11,2);
BEGIN
SELECT order_total
INTO acc_bal
FROM orders
WHERE customer_id =acc_no;
RETURN(acc_bal);
END;
/
Write a function that returns the total amount a customer paysfor an order when the orderID is known.
NOTE: Can you provide the screenshot of the answers?
Solution
This is dummy table i have created
create table orders
(
id number(11) primary key,
product_name varchar2(30),
order_amount number(11,2)
)
Insert some data into table
insert ALL
into orders (id, product_name, order_amount) values(1,’SHOES’,200)
into orders (id, product_name, order_amount) values(2,’MOBILE’,32000)
into orders (id, product_name, order_amount) values(3,’CAR’,200000)
into orders (id, product_name, order_amount) values(4,’BIKE’,26000)
into orders (id,