Error "No matching unique or primary key for this column-list" with a compound station

1

Doing a job I found the error:

  

DAN_FACTURA (INVOICE), "No matching unique or primary key for this   column-list "

Reviewing my table DAN_FACTURA I checked the statement and, as far as I know, I have correct my syntax for the Primary Key in this table. However, when referencing it, I will not allow it.

I'm sure it's a syntax error somewhere but I've given it for hours and I can not find it.

CREATE TABLE DAN_FACTURA
    (
    FACTURA     NUMBER(10),
    SUCURSAL    NUMBER(5)  CONSTRAINT FK_SUC REFERENCES
    DAN_SUCURSAL(SUCURSAL),
    FECHA       DATE,
    IMPUESTO    NUMBER(5,2) CONSTRAINT CK_IMP CHECK (IMPUESTO >= 0),
    TOTAL_SIN_IMP   NUMBER(12,2) CONSTRAINT CK_TOT_SIMP CHECK (TOTAL_SIN_IMP >0),
    TOTAL_CON_IMP   NUMBER(12,2) CONSTRAINT CK_TOT_CIMP CHECK (TOTAL_CON_IMP >0),
    CLIENTE     NUMBER(10) CONSTRAINT FK_FAC_CLI REFERENCES
    DAN_CLIENTE(CLIENTE),
    FORMA_PAGO  CHAR(2) CONSTRAINT CK_FAC_FOR CHECK(FORMA_PAGO IN('C','E','TC','TD')),
    EMPLEADO    NUMBER(10) CONSTRAINT FK_FAC_EMP REFERENCES
    DAN_EMPLEADO(EMPLEADO),
    CONSTRAINT PK_FAC PRIMARY KEY(FACTURA,SUCURSAL)
    );

    CREATE TABLE DAN_DETALLE_FACTURA
    (
    FACTURA     NUMBER(10) CONSTRAINT FK_FACT REFERENCES
    DAN_FACTURA(FACTURA),
    SUCURSAL    NUMBER(5) CONSTRAINT FK_FAC_SUC REFERENCES
    DAN_SUCURSAL(SUCURSAL),
    ARTICULO    NUMBER(10) CONSTRAINT FK_FAC_ART REFERENCES
    DAN_ARTICULO(ARTICULO),
    PRECIO      NUMBER(10,2) CONSTRAINT CK_PRECIO CHECK(PRECIO >0),
    DESCUENTO   NUMBER(3,2) CONSTRAINT  CK_DESC CHECK(DESCUENTO>=0),
    CANTIDAD    NUMBER(5) CONSTRAINT    CK_CANT CHECK(CANTIDAD >=0),
    TOTAL_POR_LINEA NUMBER(10,2) CONSTRAINT CK_TOT_LINEA CHECK(TOTAL_POR_LINEA>0),
    CONSTRAINT PK_DETALLE PRIMARY KEY(FACTURA,SUCURSAL,ARTICULO)
    );
    
asked by LeinadDC 12.10.2016 в 22:41
source

1 answer

0

I am afraid that you will have to add a restriction of uniqueness on the INVOICE field of the DAN_FACTURA table, since otherwise the external reference in the INVOICE field of the DAN_DETALLE_FACTURA table would be ambiguously defined and could "return" several rows.

    
answered by 13.10.2016 / 09:36
source