Solved

Firebird/Interbase Database Indexes

Posted on 2006-11-02
4
424 Views
Last Modified: 2010-04-05
I have a firebird database which having a table well indexed, eg unique index transactionnumber.  However after some times, I find that I am able to save the record with the same transactionnumber twice.  Finally when I look into this database, I find this unique index is somehow inactive.

Do anyone know what may cause this happen whereas I do not do anything to inactivate this index ?
0
Comment
Question by:ivylnm
4 Comments
 

Author Comment

by:ivylnm
ID: 17863836
By the way, is there a quick way for me to list out all inactive indexes ?
0
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 30 total points
ID: 17864127
Is this an index, or is it the primary key constraint?
sometimes a backup/restore can fail to reindex, but usually only if there has been a data corruption.
gfix should be able to tell you this

1 way I can think of to find all the duplicates is to use a stored procedure that does something like this (excuse typos)
create procedure finddupes
returns
( mykeyfield varcahr(32) )
as
declare variable lastkeyfield varchar(32);
begin
  :lastkeyfield = null;
  for select T.field1 from table1 t into :mykeyfield do
  begin
    if (:mykeyfield = :lastkeyfield) then suspend;
    :lastkeyfield = :mykeyfield;
  end
end;

something like that anyway...
0
 
LVL 9

Expert Comment

by:sun4sunday
ID: 17864227
>> unique index transactionnumber
In the table if you define the field as unique/primary key, then when you try to post it should through the error.
I think it is not the problem with the index. Check out your table structure and set the transactionnumber as unique.
Check in your code some where the index is deactivating. Any how it looks strange.

Also When the table is open don't do the backup for the interbase. it may get corrept.

http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_db_corr

sun4sunday
0
 
LVL 2

Assisted Solution

by:Ratje
Ratje earned 20 total points
ID: 17905929
Listing all inactive indexes...hmmm...maybe this'll work (from memory...works in interbase me thinks :) )

select * from rdb$Indices where rdb$index_inactive ='1'
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now