Oracle tutorial : Object oriented programming in Oracle PL SQL

Oracle tutorial : Object oriented programming in Oracle PL SQL

oracle tutorial for beginners

This video Oracle tutorial will tell you how to implement object oriented concept in oracle

CREATE OR REPLACE TYPE MyInput AS object
(
num1 NUMBER,
num2 NUMBER
);

CREATE OR REPLACE TYPE MyCal AS object
(
mynum MyInput,

member FUNCTION Plus RETURN NUMBER ,
member FUNCTION Sub RETURN NUMBER,
member FUNCTION Mul RETURN NUMBER,
member FUNCTION Div RETURN NUMBER
);
/

CREATE OR REPLACE TYPE BODY MyCal as
member FUNCTION Plus RETURN NUMBER AS
result NUMBER ;
BEGIN
result := mynum.num1 + mynum.num2;
RETURN result;
END Plus ;

member FUNCTION Sub RETURN NUMBER AS
result NUMBER;
BEGIN
result := mynum.num2 – mynum.num1;
RETURN result;
END Sub;

member FUNCTION Mul RETURN NUMBER AS
result NUMBER ;
BEGIN
result := mynum.num1 * mynum.num2;
RETURN result;

END;

member FUNCTION Div RETURN NUMBER AS
result NUMBER (10, 3);
BEGIN
result := mynum.num1 / mynum.num2 ;
RETURN result;
END;

END ;
/

DECLARE
obj1 MyInput := MyInput(50, 100);
obj2 MyCal := MyCal(obj1);
BEGIN

Dbms_Output.Put_Line(obj2.Plus);
Dbms_Output.Put_Line(obj2.Sub);
Dbms_Output.Put_Line(obj2.Mul);
Dbms_Output.Put_Line(obj2.Div);
END;

#techquerypond

https://techquerypond.com

https://techquerypond.wordpress.com

Comments

 Write a comment

*

Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!