{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

scan0012 - (y r V P rikfif ‘(fid CREATE TYPE Point As...

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (y r \ ( V P rikfif ‘(fid/ CREATE TYPE Point As OBJECT ( _ “3 “2‘ Ci‘[ Qa’/ x NUMBER, Adr,,,._#~/» ’ £1}- ‘ y NUMBER, i¢r~—1-T "”” 3/9 391 ,Lw ? member function 133w) RETURN NUMBER, [W / PRAGMA RESTRICT_REFERENCES(Distance,WNDS) ); / t / /J" ktw TEL. tfrl CREATE TABLE City ( VJ‘ ‘ V)\N1 ‘ Name VARCHAR(30), ¥wp¢ {abnfifi a Country VARCHAR(30), ylvivynt. o£ Pop NUMBER(5,2>, ,4; b,“ n;‘mh , Capital CHAR(1), f ’ Shape Point); INSERT INTO City VALUES('Brasilia', 'Brazil‘,l.5,'Y',Point(755.4,—23.2)); INSERT INTO City VALUES('Ottawa',‘Canada',0.8,‘Y',POint(—75.65,45.70)); ‘6 % %cat point.body ‘ n.4‘ CREATE OR REPLACE TYPE BODY éEEEE>AS member function Distancgggg IN EQTQLI return NUMBER 15 x1 City.shape.x%type; yl City.Shape.y%type; BEGIN SELECT C.§Qag§.é INTO X1 FROM City C WHERE c.8hape.x = self.x; SELECT c.3hapgjx‘INTO yl FROM City c WHERE C.Shape.y : self.y; RETURN SQRT((X1—p2.x)*(x1—p2.x) + (yl—p2.y)*(yl—p2.y))*111 111; END; END; / snow ERRORS dp % % %cat pointTest.sql SET PAGES 100 SET ECHO ON SET PAUSE ON SELECT c.name,c.8hape.distance(d.Shape) from city C ,City d where c.name = 'Ottawa‘; 0 ‘6 %ADDDexit Frog 2 —— this is a variation in which we create a object type for employees ,, themselves; A TABLE OF OBJECTS is sqidAtp_haveuannjgpjeCt column" ,, in Objecteg3c.sql we create the table a differenttway; note that this is a more purely obj ct oriented approach; an employee is not ,, a scalar type 1ntu1t1vely -- this is for education employees, more or less, not baseball employees —— can use DROP TYPE address_type "ONLY IF" it is not part of an —— existing table, i.e. emped would have to be dropped first ,, the ‘/‘ at the end of CREATE TYPE seems to be pretty darned necessary ...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern