Have this objects and table types:
CREATE TYPE Person_typ AS OBJECT
(
name CHAR(20),
ssn CHAR(12),
address VARCHAR2(100)
);
CREATE TYPE Person_nt IS TABLE OF Person_typ;
CREATE TYPE dept_typ AS OBJECT
(
mgr Person_typ,
emps Person_nt,
MEMBER PROCEDURE getEmp(name IN CHAR(20)),
);
CREATE TABLE dept OF dept_typ;
How i can get the employer with the function getEmp and argument name ?
CREATE TYPE BODY dept_typ AS
MEMBER PROCEDURE getEmp(name IN CHAR(20)),
BEGIN
????? What i put where ????
END;
END;
My problem is that i can’t make self.emps like I can do with self.mgr … and i don’t know why….
Thanks,
Joao
My guess is that you want something like this
You could also, I suppose, define it as a procedure with an OUT
parameter but that’s generally not what you want.
ISor anASin the definition of the member function or procedure in the type body.PERSON_NTis a collection, you need to iterate over the collection. Note here that I’m assuming that the collection is dense in this code. You could use the FIRST and NEXT methods on the collection to loop over the elements in a sparse collection as well.If you really want to select from the collection, you’d need to use the
TABLEoperator. This approach, however, is less efficient and generally more cumbersome than simply iterating over the collection.If you want to add elements to the collection (assuming the collection has previously been initialized)