Firebird Insert Distinct Data Using ZeosLib and Delphi

Posted by Brad on Stack Overflow See other posts from Stack Overflow or by Brad
Published on 2010-05-10T01:54:25Z Indexed on 2010/05/10 1:58 UTC
Read the original article Hit count: 539

Filed under:
|
|
|

I'm using Zeos 7, and Delphi 2K9 and want to check to see if a value is already in the database under a specific field before I post the data to the database.

Example: Field Keyword
Values of Cheese, Mouse, Trap

tblkeywordKEYWORD.Value = Cheese

What is wrong with the following? And is there a better way?

zQueryKeyword.SQL.Add('IF NOT EXISTS(Select KEYWORD from KEYWORDLIST ='''+ tblkeywordKEYWORD.Value+''')INSERT into KEYWORDLIST(KEYWORD) VALUES ('''+ tblkeywordKEYWORD.Value+'''))'); zQueryKeyword.ExecSql;

I tried using the unique constraint in IB Expert, but it gives the following error: Invalid insert or update value(s): object columns are constrained - no 2 table rows can have duplicate column values. attempt to store duplicate value (visible to active transactions) in unique index "UNQ1_KEYWORDLIST".

Thanks for any help

-Brad

© Stack Overflow or respective owner

Related posts about firebird

Related posts about zeos