Map Method

PHOTO EMBED

Thu Sep 23 2021 06:18:34 GMT+0000 (UTC)

Saved by @kaveen

CREATE TYPE Rectangle_type AS OBJECT
(
	length NUMBER, 
  	width NUMBER,
	MAP MEMBER FUNCTION area RETURN NUMBER
);

CREATE TYPE BODY Rectangle_type AS MAP MEMBER FUNCTION area RETURN NUMBER IS 
BEGIN
	RETURN length * width; 
END area;
END;

CREATE TABLE rectangles OF Rectangle_type;

INSERT INTO rectangles VALUES (1,2);
INSERT INTO rectangles VALUES (2,1);
INSERT INTO rectangles VALUES (2,2);

SELECT DISTINCT VALUE(r) FROM rectangles r;

content_copyCOPY