I am trying to do an exercise with objects within the database and I am somewhat stuck, I have created the objects and tables as follows:
--------------------------------------------------------
-- TAREA PROG10: CREACIÓN DE LOS TIPOS Y TABLAS
--------------------------------------------------------
--------------------------------------------------------
-- DDL for Type TIPO_MUEBLE
--------------------------------------------------------
CREATE OR REPLACE TYPE TIPO_MUEBLE AS OBJECT(
IDMUEBLE NUMBER(4),
DESCRIPMUEBLE VARCHAR2(50),
PRECIOUNITARIO NUMBER(8,2),
UNIDADESEXISTENTES NUMBER(4)
)
/
--------------------------------------------------------
-- DDL for Type TIPO_VENTA
--------------------------------------------------------
CREATE OR REPLACE TYPE TIPO_VENTA AS OBJECT(
IDVENTA NUMBER(6),
NOMBRECLI VARCHAR2(30),
UNIDADESVEND NUMBER(4),
MUEBLE REF TIPO_MUEBLE -- Mueble que se ha vendido
)
/
--------------------------------------------------------
-- Tabla MUEBLES
--------------------------------------------------------
-- CREAR TABLA MUEBLES_OBJ
CREATE TABLE MUEBLES_OBJ OF TIPO_MUEBLE(
IDMUEBLE PRIMARY KEY);
--------------------------------------------------------
-- Tabla VENTAS
--------------------------------------------------------
-- Crear tabla VENTAS_OBJ
CREATE TABLE VENTAS_OBJ OF TIPO_VENTA(
IDVENTA PRIMARY KEY);
I have inserting an object of type_furniture without problems using:
INSERT INTO MUEBLES_OBJ VALUES(0001, 'Mesa comedor', 15, 10);
But when I want to include an object of type_sales in the following way, this error is returned:
INSERT INTO VENTAS_OBJ VALUES(000001, Luis, 2, 0001);
--ERROR
Error que empieza en la línea: 51 del comando -
INSERT INTO VENTAS_OBJ VALUES(000001, Luis, 2, 0001)
Error en la línea de comandos : 51 Columna : 39
Informe de error -
Error SQL: ORA-00984: column not allowed here
00984. 00000 - "column not allowed here"
*Cause:
*Action:
I think I have the error in 0001 that I have to put a type_furniture, but I don't know how to do that.
Let's see if this works for you. I have not been able to test it, so you will tell us:
Anyway, I tell you that this way of managing data is highly discouraged. It is unclear, and gives many errors. But if it works for you, perfect.
Ok, for future reference, the problem was that you had put Luis in the field of type VARCHAR, leaving the quotes, so the handler was assuming that you were giving it the name of a column.
I have tried what you tell me, but it throws the following error.