Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

torturedmind (Programmer) (OP)
13 Mar 02 0:00
Why is it that when i try to insert a record in between
records, the inserted blank record is added to the end
of file? I tried issuing the "INSERT BEFORE BLANK" while
my record pointer is at record 15 (20 records total in
the table). I assumed that the inserted record will be the
new record 15 and the rest will be adjusted but instead,
the inserted record is placed at the end. It's like
issuing "APPEND BLANK"! Can anyone help me with this?

By the way, am using VFP6. Thanx guys.

fluteplr (Programmer)
13 Mar 02 0:12
Doctor, it hurts when I do that.
Don't DO THAT.

Seriously the insert command to physically insert a record in the middle of a dbf has been obsolete since Foxbase.

It is horribly slow and locks the entire table while attempting to move all the records around.

Use append blank or a sql insert.

If you need to return records in a particular order, that what indexes and select statements are for.

Just in case people think I am on my soapbox again, here is the VFP Hacker's Guide entry for Insert.  (Boy its crowded on top of this soap box.)

Insert

INSERT adds records to the current table at the current record pointer position. INSERT is almost always a bad idea. This command is part of FoxPro's Xbase legacy and generally leads to bad code. In all our experience, we've only found one situation where using INSERT was a good idea—more on that below.

Don't confuse this INSERT command with the SQL INSERT command, which is very useful.

Usage INSERT [ BLANK ] [ BEFORE ]
 
Used by itself, INSERT is much like APPEND by itself, but requires exclusive access. It adds a record and brings up an EDIT-type window to fill in the fields. The fly in the ointment is that the new record is physically inserted immediately following the current record. This means that every record following that position has to be physically moved to make room. On a large table, INSERT is a spectacularly bad choice.

Adding the BLANK keyword is like using the BLANK keyword of APPEND. The new record is added behind the scenes and there's no interaction.

The BEFORE keyword indicates that the new record should precede rather than follow the current record.

If the table has any open indexes (even if order is set to 0), the new record is added at the end, whether or not you specify BEFORE. This actually makes it a better command than it is otherwise, but also makes it obsolete since you can do the same thing with APPEND.

INSERT can't be used with most of the cool stuff in Visual FoxPro. You can't INSERT in a buffered table, or in one that has rules, triggers, primary keys or candidate keys.

INSERT respects SET CARRY, bringing forward values from specified fields when CARRY is ON.

So, what about the one time we've found INSERT useful? The situation was a very small table (never more than a couple of hundred records), which was to be copied out to an SDF file, from which it would be sent to the printer. The record order was essential to the reporting process. Because the result might be more than one page, we needed to insert a record containing a page feed character after every 54 records. INSERT was just the ticket. The moral, though, is the situation has to be pretty unusual before it's worth using INSERT.

See Also Append, Insert-SQL, Set Carry
 
Copyright © 1998 by Tamar E. Granor and Ted Roche. All Rights Reserved.
torturedmind (Programmer) (OP)
13 Mar 02 1:17
Yes i got your point. But based on what you said, this is
one of those unusual situations that needs the use of the
INSERT command. Am only inserting 1 step at a time to a
table as small as 100 records (max). Actually, this table
is a storage of processes that need to be followed, revised
and reviewed every now and then. So a user may insert a
record in between records if the situation calls for it.

Anyways, if it cannot be done anymore then I guess i have
no other choice but to use SQL instead. Thanks for a very
informative fact Flute. I think i still have a lot to learn
about VFP6.
ChrisRChamberlain (Programmer)
13 Mar 02 2:00
torturedmind

Anyways, if it cannot be done anymore

It still works, if you want to implement it.

You are APPENDING because your table is indexed.

Make sure the table in not indexed, GOTO the record that you want to preceed with the new blank record, and then :-

INSERT BLANK BEFORE
GATHER MEMVAR

or

REPL field WITH ... etc


HTH

Chris

torturedmind (Programmer) (OP)
13 Mar 02 18:58
Thnx Chris. You've been a big help.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close