Explicit assignment to the ref parameter in member function doesn't work

I've created new member procedure in a simple DB schema (Profesor-Asignatura-Departamento). In this procedure I'd like to change explicitly the value of departamento parameter which stores references to departamento objects.
So what I'm doing is:
select ref(d) into ref_departamento from departamento d where d.codigo=n_departamento; -- retrieve reference to the departament which has a code=n_departamento
then I'd just like to assign the result to objects attribute like this:
self.departamento:=ref_departamento;
and here it doesn't work and I'm wondering why; I haven't found explaination in web. No error is displayed, simply it doesn't change the previous value of the parameter.
Maybe there are some restrictions. I've managed to find another solution here with UPDATE statement but I'm curious why the simple assignment doesn't work.
Thanks in advance,
Wojtek

OK, I'm not spanish however I like my code to be kept that way because I'm still learning :)
Most important classess are these (then tables are created for them):
create or replace type ot_departamento as object
codigo number,
nombre varchar2(32),
telefono vt_telefono, -- vector type of size 3
profesores tt_departamento_profesores, -- table type of references to ot_profesor objects
asignaturas tt_departamento_asignaturas -- table type of references to ot_asignatura objects
create or replace type ot_profesor as object
codigo number,
nombre varchar2(32),
direccion ot_direccion, --object type with street, city, etc.
telefono vt_telefono,
departamento ref ot_departamento, -- reference to ot_departamento
docencia tt_profesor_docencia, -- table type of objects which attributes are (reference to ot_asignatura, credits for a subject)
create or replace type ot_asignatura as object
codigo number,
nombre varchar2(32),
departamento ref ot_departamento, -- reference to ot_departamento
docencia tt_asignatura_docencia, -- table type of objects which attributes are (reference to ot_profesor, credits for a subject)
member procedure cambio_departamento(n_departamento number) *<- That's the procedure, where I had this issue* its task is to change current department,it takes as an argument code of new department which needs to be assigned
So now the code for my procedure is:
create or replace
type body ot_asignatura as
member procedure cambio_departamento(n_departamento number) is
asig_count number:=self.docencia.count;
no_cambio exception;
docencias_adscritas exception;
ref_departamento ref ot_departamento;
begin
--first check if a department of given code (n_departamento) exists at all, if not then raise NO_DATA_FOUND exception
select ref(d) into ref_departamento from departamento d where d.codigo=n_departamento;
--check if the given department is not the same as asignatura has already assigned, if so then raise NO_CAMBIO (NO_CHANGE) exception
if ref_departamento=self.departamento then
raise no_cambio;
end if;
--if there are any docencias (subject is declared with professor who's teaching and credits) already assigned to current department then department can't be changed
if asig_count>0 then
raise docencias_adscritas;
end if;
--first delete our assignatura from list of assignaturas already assigned to current department in the corresponding ot_department
delete from the (select d.asignaturas from departamento d where ref(d)=self.departamento) a
where a.COLUMN_VALUE.codigo=self.codigo;
--now assing (update) to current assignatura reference to the new department
--self.departamento:=ref_departamento; <- THIS IS NOT WORKING HERE*, so the workaround is given below by using explicit UPDATE on the whole table
update asignatura a set a.departamento=(select ref(d) from departamento d where d.codigo=n_departamento)
where a.codigo=self.codigo;
--what's left is to add current assignatura to the list of assignatures for new ot_departamento
insert into the (select d.asignaturas from departamento d where d.codigo=n_departamento)
select ref(a) from asignatura a where a.codigo=self.codigo;
exception
when no_data_found then
raise_application_error(-20003,'No hay este departamaneto');
when no_cambio then
raise_application_error(-20002,'Asignatura ya adscrita a este departamento');
when docencias_adscritas then
raise_application_error(-20001,'Asignatura tiene docencias adscritas !!!');
end cambio_departamento;
end;
I hope it's quite clear here. I'm still curious, why it's not working.
Thanks,
Wojtek

Similar Messages

Maybe you are looking for

  • Message history won't erase in iOS 8

    I am using an iPad 3rd generation with iOS 8. When I set the Message History: Keep Messages to "30 Days" I expect all older messages to vanish.  But they're still here. Interestingly, before iOS 8, I noticed that my messages would not disappear when

  • About routing text read using fm CP_EX_PLAN_READ

    Hi, I am writing a program to copy routing from one plant to another. Everything works great except for long text. I did search the forum but could not find any helpful tips. 1>  I am reading the routing using fm CP_EX_PLAN_READ        CALL FUNCTION

  • Question about JTable...

    Hi people, I have a question about class JTable of Java and how can i add dynamic content to it. More specific i would like to create a table which has a dynamic content at its rows and columns (etc i will use a method which will generate dates of 1/

  • Slideshow Music and iTunes on Mac?

    How do I get a Playlist that I have in iTunes on my Mac to be selectable in the LR Slideshow Module?  I have an iTunes Playlist on my Mac that I want to use as music on a LR Slideshow.  How do I do that?  I have the latest Lightroom and the Latest OS

  • Preview of approval chain before workflow gets triggered

    Hi Guys,      I have a different requirement where users want to see the preview of approval chain before workflow gets triggered. I mean once we enter all the data in transaction, after the data validation is done then they want to see the approval