The default constructor does not work for me (Relational Object Database)

0

I would like to know if you see the error, is that I do not understand why I can not insert records with the constructor by default, only by the constructor that I have defined

    create or replace type MiembroEscolar force as object
(
    codigo INTEGER,
    dni VARCHAR2(10),
    nombre VARCHAR2(30),
    apellidos VARCHAR2(30),
    sexo VARCHAR2(1),
    fecha_nac DATE
)not final;
/

    create or replace type Profesor force under MiembroEscolar
    (
        especialidad VARCHAR2(20),
        antiguedad INTEGER,

    constructor function Profesor 
    (
        codigo INTEGER,
        nombre VARCHAR2,
        pr_apellido VARCHAR2,
        seg_apellido VARCHAR2,
        especialidad VARCHAR2
    )return self as result,

    member function getNombreCompleto return varchar2
);

/

create or replace type body Profesor as

    constructor function Profesor 
    (
        codigo INTEGER,
        nombre VARCHAR2,
        pr_apellido VARCHAR2,
        seg_apellido VARCHAR2,
        especialidad VARCHAR2
    )return self as result 

    is

        begin
            self.codigo := codigo;
            self.nombre := nombre;
            self.apellidos := pr_apellido || ' ' || seg_apellido;
            self.especialidad := especialidad;
        return;
        end;

    member function getNombreCompleto return varchar2

    is
        begin
        return self.apellidos ||' '|| self.nombre;
        end;
end;

/

create table Profesorado of Profesor;
/

    insert into Profesorado values 
    (
/* El primer registro no me funciona, me salta Error SQL: ORA-00947: not enough values*/
        Profesor(2,'51083099F','MARIA LUISA','FABRE BERDUN','F','31/03/1975','TECNOLOGIA',4),
/* Si ejecuto solo este registro me funciona correctamente */
        Profesor(3,'JAVIER','JIMENEZ','HERNANDO','LENGUA')
    );

Greetings and thanks in advance

    
asked by TaGy 01.04.2018 в 13:23
source

1 answer

0

Ok, I solved it by separating each insert

insert into Profesorado values 
(

    Profesor(3,'JAVIER','JIMENEZ','HERNANDO','LENGUA')
);
insert into Profesorado values 
(

    Profesor(2,'51083099F','MARIA LUISA','FABRE BERDUN','F','31/03/1975','TECNOLOGIA',4)
);

This is how the two constructors work for me, I thought you could use the different constructors in the same insert, but you can see that they are not: s

    
answered by 01.04.2018 в 13:31