Board index » delphi » Constraint question

Constraint question

Hi,
When I try to create a constraint REFERENCES of FK with this
command:
  ALTER TABLE TESTE
     ADD CONSTRAINT TESTE_FK
         FOREIGN KEY (LOC_ID)
         REFERENCES LOCALIDADE (LOC_ID);

  Since the index TESTE_FK already exists in the column LOC_ID
  But occurs the error message:

  Unsuccessful metadata update
  STORE RDB$REF_CONSTRAINTS failed
  action cancelled by trigger (1) to preserve data integrity
  Name of Referential Constraint not defined in constraints table
  Statement: ALTER TABLE TESTE
                ADD CONSTRAINT TESTE_FK
                FOREIGN KEY (LOC_ID)
                REFERENCES LOCALIDADE (LOC_ID)

  What is the problem?
  Thanks
  Udo

 

Re:Constraint question


IB 6.01

Quote
Thomas Miller <tmil...@bss-software.com> wrote:
>Which database and version?

>Udo wrote:
>> Hi,
>> When I try to create a constraint REFERENCES of FK with this
>> command:
>>   ALTER TABLE TESTE
>>      ADD CONSTRAINT TESTE_FK
>>          FOREIGN KEY (LOC_ID)
>>          REFERENCES LOCALIDADE (LOC_ID);

>>   Since the index TESTE_FK already exists in the column LOC_ID
>>   But occurs the error message:

>>   Unsuccessful metadata update
>>   STORE RDB$REF_CONSTRAINTS failed
>>   action cancelled by trigger (1) to preserve data integrity
>>   Name of Referential Constraint not defined in constraints table
>>   Statement: ALTER TABLE TESTE
>>                 ADD CONSTRAINT TESTE_FK
>>                 FOREIGN KEY (LOC_ID)
>>                 REFERENCES LOCALIDADE (LOC_ID)

>>   What is the problem?
>>   Thanks
>>   Udo

>--
>Thomas Miller
>Delphi Client/Server Certified Developer
>BSS Accounting & Distribution Software
>BSS Enterprise Accounting FrameWork

>http://www.bss-software.com

Re:Constraint question


Unfortunately I don't know all the particulars with IB.  You
might want to try this in the Interbase news group.

Quote
Udo wrote:
> IB 6.01

> Thomas Miller <tmil...@bss-software.com> wrote:

>>Which database and version?

>>Udo wrote:

>>>Hi,
>>>When I try to create a constraint REFERENCES of FK with this
>>>command:
>>>  ALTER TABLE TESTE
>>>     ADD CONSTRAINT TESTE_FK
>>>         FOREIGN KEY (LOC_ID)
>>>         REFERENCES LOCALIDADE (LOC_ID);

>>>  Since the index TESTE_FK already exists in the column LOC_ID
>>>  But occurs the error message:

>>>  Unsuccessful metadata update
>>>  STORE RDB$REF_CONSTRAINTS failed
>>>  action cancelled by trigger (1) to preserve data integrity
>>>  Name of Referential Constraint not defined in constraints table
>>>  Statement: ALTER TABLE TESTE
>>>                ADD CONSTRAINT TESTE_FK
>>>                FOREIGN KEY (LOC_ID)
>>>                REFERENCES LOCALIDADE (LOC_ID)

>>>  What is the problem?
>>>  Thanks
>>>  Udo

>>--
>>Thomas Miller
>>Delphi Client/Server Certified Developer
>>BSS Accounting & Distribution Software
>>BSS Enterprise Accounting FrameWork

>>http://www.bss-software.com

--
Thomas Miller
Delphi Client/Server Certified Developer
BSS Accounting & Distribution Software
BSS Enterprise Accounting FrameWork

http://www.bss-software.com

Re:Constraint question


In article <3ddd1b0...@newsgroups.borland.com>, udo_ma...@yahoo.com
says...
Quote
>   What is the problem?

        Drop the second (LOC_ID).  Presuming that's the PK of LOCALIDADE,
you don't need it.

        -Craig

--
Craig Stuntz [TeamB] Vertex Systems Corp. Columbus, OH
Delphi/InterBase Weblog : http://delphi.weblogs.com
InterBase Perf. Monitor : http://delphi.weblogs.com/IBPerformanceMonitor
InterBase PLANalyzer 1.1: http://delphi.weblogs.com/IBPLANalyzer

Other Threads