Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/01/2008, 02:18
Carmax
 
Fecha de Ingreso: enero-2008
Mensajes: 3
Antigüedad: 16 años, 4 meses
Puntos: 0
S.O.S. con ORACLE y tablas anidadas!!!!

buenas noches.. por lo menos aqui en vzla.. tengo un pequeño problema, a ver si alguien puede ayudarme:
y es que necesito validar atributos que estan dentro de tablas anidadas como ej FOT_DS_DIRECCION que la ruta de una foto no este vacia. lo intentaba hacer con un procedimiento que me recorra todos los registros y, si ve alguno que no tiene la ruta de la foto, eliminarlo.. pues no me sale el validarlo antes de insertar.. aqui les mando las tablas a ver si alguien puede ayudar: y gracias!

CREATE TABLE TIENDA_TABLE (
TIE_PK_TIENDA NUMBER (10) NOT NULL,
TIE_DS_DATOS DATOS_GENERALES_TDA,
TIE_DS_FOTOS FOTOS_TDA,
TIE_DS_HORARIO HORARIOS_TDA,
TIE_FK_CIUDAD NUMBER (10) NOT NULL,
CONSTRAINT TIENDA_PK PRIMARY KEY (TIE_PK_TIENDA) )
NESTED TABLE TIE_DS_DATOS.DG_DS_TELEFONOS STORE AS TIE_DS_TELEFONOS_TABLE,
NESTED TABLE TIE_DS_FOTOS STORE AS TIE_DS_FOTOS_TABLE,
NESTED TABLE TIE_DS_HORARIO STORE AS TIE_DS_HORARIO_TABLE;

CREATE OR REPLACE TYPE FOTO_TDA AS OBJECT (
FOT_DS_DIRECCION BFILE );


lo que yo mas o menos trataba de hacer era esto:

CREATE OR REPLACE procedure sirve is
cursor cursorFotos is select * from TIENDA_TABLE;
aux FOT_DS_DIRECCION%rowtype;
cursor cursory(var in number) is select a.tabla1 from THE(select TIE_DS_FOTOS from TIENDA_TABLE where TIE_PK_TIENDA = var)a;
aux3 cursory%rowtype;
aux2 number;
begin
open cursorFotos;
loop
fetch cursorFotos into aux;
exit when cursorx%notfound;
open cursory(aux.TIE_PK_TIENDA);
loop
fetch cursory into aux3;
exit when cursory%notfound;
if aux3.tabla1 = 0 then
delete from THE(select TIE_DS_FOTOS from TIENDA_TABLE where TIE_PK_TIENDA = aux.TIE_PK_TIENDA)a where a.tabla1 = aux3.tabla1;
end if;
end loop;
close cursory;

end loop;
close cursorFotos;
end;
/


pero es que la cabeza ya no me da para mas..


ah.. y otra cosita.. como puedo hacer para acceder a los atributos de telefono_tda como TEL_CD_AREA?.. he intentado y no me sale.. DATOS_GENERALES_TDA es atributo de la misma tabla TIENDA_TABLE

CREATE OR REPLACE TYPE DATOS_GENERALES_TDA AS OBJECT (
DG_NM_ENTE VARCHAR2 (100),
DG_DS_DIRECCION DIRECCION_TDA,
DG_DS_TELEFONOS TELEFONOS_TDA );

CREATE OR REPLACE TYPE TELEFONO_TDA AS OBJECT (
TEL_CD_AREA NUMBER (5),
TEL_NR_TELEFONO NUMBER (10),
TEL_TP_TELEFONO VARCHAR2 (10) );
/
CREATE OR REPLACE TYPE TELEFONOS_TDA AS TABLE OF TELEFONO_TDA;



gracias a quien puede responderme y aclarar mis dudas.