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

  • How to see the file at the application server

    HI TO ALL SDNERS ,                              THIS IS MY CODE WHERE TO CHECK THE DOWNLOADED FILE AT THE APPLICATION SERVER.IN TCODE AL11 I HAVE SEEN THERE IS NO FILE GETTING CREATED.WHEN TRANSFERRING THE SY-SUBRC VALUE IS ZERO. Program Name       

  • SAP_HTTPServicePort URLs in SLD for PI are updated by SLD host name itself

    We have upgraded our PI 7.0 to 7,1. We have a central SLD. After the upgrade, SAP_HTTPServicePort URLs (in SLD Content maintenance) for the PI are all getting initialized with SLD host name itself. Example: for port.CIDX.af.pip.<PIPhostname> URL: htt

  • Attachment with workitem

    Hi,   Is it possible to display an attachment in the SAP-Inbox along with work item. Please give some inputs. Thanks, Lakshmi.

  • Is there a way to remove the pulldown tab?

    Is there a way to remove the pull down tab that shows weather, stocks, reminders and ect? It's very annoying and even gets triggered while in other apps while unwanted. In fact its one of the worst ideas they have ever added to the ipod. If I wanted

  • Local Storage Used When Using iMatch?

    I'm using iMatch and streaming music to my iOS device.  I'm curious if I'm using local storage space on my iOS device when doing so, and if so, is there a way to clear space as needed?