Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread insert
Sun, Jan 16 2011 9:25 AMPermanent Link

Paul Waegemans

IMS bvba

Avatar

Is it possible to insert a record before another record or is a new record always added at the end of the table?

(I'am working with version 4.29 Build 4)
Sun, Jan 16 2011 11:35 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Paul

>Is it possible to insert a record before another record or is a new record always added at the end of the table?

I'm guessing you're reasonably new to database work. If not and I'm insulting your level of knowledge - I'm sorry.

Physically records are always added at the end of the table. Think of the amount of data shuffling that would be needed for a large database otherwise.

How you control the sequence in which records are processed or shown is via indices. I moved over to ElevateDB a few years back and my version of DBISAM is 4.25 so DBSys may have changed since then. If it hasn't then what you need to do is open your table in DBSys and have a look at the indexes tab. This will tell you which indices have been defined for you table. My guess would be none.

If I'm right then you need to add some. Close the table and click Utilities - Alter Table and open your table. Click on the indexes tab and add in whatever indices you need.

EG if its a contacts table with forename and surname I would have an index ContactName which would be defined as Surname;Forename

Then if I added Fred Bloggs into the table it would come above Alf Zamenski and below Wednesday Adams

Roy Lambert [Team Elevate]
Thu, Jan 20 2011 10:24 AMPermanent Link

Paul Waegemans

IMS bvba

Avatar

Roy,

Not so new in databse work as it might seem from the question I asked.  Anyway you are not insulting me because of my level of knowledge because the are nut such things as stupid questions.  Stupid answers on the other hand they exist.

In fact I was just wondering why there is a difference between append and insert.

"Append" meant for me "adding" at the end of the table and "Insert" I hoped it would be insert between 2 existing rows.  My problem is that I cannot solve the ordering problem by making an index because the records will be sorted in alfabetical or numeric way.  Unless you have another solution?

Roy Lambert wrote:

Paul

>Is it possible to insert a record before another record or is a new record always added at the end of the table?

I'm guessing you're reasonably new to database work. If not and I'm insulting your level of knowledge - I'm sorry.

Physically records are always added at the end of the table. Think of the amount of data shuffling that would be needed for a large database otherwise.

How you control the sequence in which records are processed or shown is via indices. I moved over to ElevateDB a few years back and my version of DBISAM is 4.25 so DBSys may have changed since then. If it hasn't then what you need to do is open your table in DBSys and have a look at the indexes tab. This will tell you which indices have been defined for you table. My guess would be none.

If I'm right then you need to add some. Close the table and click Utilities - Alter Table and open your table. Click on the indexes tab and add in whatever indices you need.

EG if its a contacts table with forename and surname I would have an index ContactName which would be defined as Surname;Forename

Then if I added Fred Bloggs into the table it would come above Alf Zamenski and below Wednesday Adams

Roy Lambert [Team Elevate]
Thu, Jan 20 2011 11:14 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Paul

>In fact I was just wondering why there is a difference between append and insert.

I think there are two because of TDataSet. If you look at the OLH for TDataset.Append and TDataset.Insert there is a difference.

>"Append" meant for me "adding" at the end of the table and "Insert" I hoped it would be insert between 2 existing rows.

TDataset.Append
A newly appended record is posted to the database in one of three ways:
For indexed Paradox and dBASE tables, the record is inserted into the dataset in a position based on its index.
   For unindexed Paradox and dBASE tables, the record is added to the end of the dataset.
   For SQL databases, the physical location of the appended record is implementation-specific. For indexed tables, the index is updated with the new recordinformation.

TDataset.Insert
A newly inserted record is posted in one of three ways:
For Paradox tables with primary indexes, the record is inserted into the dataset in a position based on its index.
   For Paradox tables without primary indexes, the record is inserted into the dataset at the current position.
   For dBASE, FoxPro, and Access tables, the record is physically appended to the dataset at the end. If an index happens to be active, the new record may appear in a position relative to the index, but the record is still actually stored at the end of the table.
For SQL databases, the physical location of the insert is implementation-specific. For indexed tables, the index is updated with the new record information.

Which sort of reads as you would believe insert and append to mean but may not.

>My problem is that I cannot solve the ordering problem by making an index because the records will be sorted in alfabetical or numeric way. Unless you have another solution?

This baffles me. What's wrong with having two indices - one for the alpha and one for the numerical?

Can you post the table structures and explain a little more.

Roy Lambert [Team Elevate]

Wed, Feb 16 2011 12:38 PMPermanent Link

Robert Kaplan


"Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message
news:AC9FDFE1-CB45-4D80-A3FB-3462BD2A3902@news.elevatesoft.com...
> Paul
>
>>Is it possible to insert a record before another record or is a new record
>>always added at the end of the table?
>
> I'm guessing you're reasonably new to database work. If not and I'm
> insulting your level of knowledge - I'm sorry.
>
> Physically records are always added at the end of the table. Think of the
> amount of data shuffling that would be needed for a large database
> otherwise.
>

Not true. DBISAM reuses deleted records.

Robert

Thu, Feb 17 2011 3:53 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Robert


>Not true. DBISAM reuses deleted records.

Correct, I'd sort of ignored that as not really relevant.

Roy Lambert [Team Elevate]
Image