Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Integrity constraint violated
mamin_at_o2.pl wrote:
> Hi,
> I have a database on Oracle 9.2. in schema TEST there're tables:
> zamowienia_pozycje and stawki_vat.
> While executing insert command::
>
> INSERT INTO ZAMOWIENIA_POZYCJE
> (ZAMOWIENIE_ID,OPERATOR_ID,POZYCJA_ASORTYMENTOWA_ID,POZYCJA_CENNIKA_ID,CENA,WARTOSC_WSPOLCZYNNIKOW,STAWKA_VAT_ID,
> STATUS_POZYCJI_ZAMOWIENIA_ID,LICZBA_SZTUK,ZLOZONA_NAZWA_POZYCJI)
> VALUES (4,1,6,1,2,1,1,1,1,'test')
>
> Oracle throws an exception:
> "ORA-02291: Integrity constraint violated (TEST.ZAM_POZ_STAWKA_VAT_FK)
> - parent key not found\n"
>
> There's a ZAM_POZ_STAWKA_VAT_FK constraint script:
>
> --ZAM_POZ_STAWKA_VAT_FK
> --
> ALTER TABLE ZAMOWIENIA_POZYCJE ADD (
> CONSTRAINT ZAM_POZ_STAWKA_VAT_FK FOREIGN KEY (STAWKA_VAT_ID)
> REFERENCES FAKTURY_VAT (ID));
>
>
> Anybody knows, why this constrain is blocking my insert command?
Please read the error message *carefully* and try to understand it. It tells you for the ZAMOWIENIA_POZYCJE record with stawka_vat_id 1, there is no corresponding FAKTURY_VAT record, with ID 1. Unless your constraints are deferred (so they are checked at commit), the FAKTURY_VAT parent record needs to be present and committed prior to inserting any ZAMOWIENIA_POZYCJE record with STAWKA_VAT_ID 1.
-- Sybrand Bakker Senior Oracle DBAReceived on Tue Aug 08 2006 - 06:19:36 CDT
![]() |
![]() |