Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert record

Status
Not open for further replies.

gfrlaser

Programmer
May 24, 2007
67
US
I have a table containing 75000 records.
the field is a numeric field with values already populated.
What I want to do is...

go top
do while not eof()
skip 49
insert 0000000 && this value into the new record
enddo

I want to insert a new record at that point, every 49 records. I get errors relating to buffers.
What is the way to accomplish this?

Thanks.
 
Oh, not for this kind of longwinded problem-solving. I was not only patient with you, you were also patient with me. And anyone reading all this may shake their heads, it's not my day <g>.

You may use a sticker and put it on your monitor ;-).

look at the bottom of any of my posts here, and you'll see the options. The left one gives me a star, if you really like to.

I just tried with the INSERT BEFORE command and it takes about 45 times as long, not 765 times. Still it shows that it even pays to recreate the whole table if you need more inserts.

Code:
Create Cursor curNumbers2 (cNumber C(8))
For lnCount=1 TO lnNumberOfRows
  Insert Into curNumbers2 Values (Transform(lnCount+lnStart-1,"@R 99999999"))
Endfor

Go Top In curNumbers2
Skip 50
Do while !Eof()
  Insert Before Blank
  Skip 50
EndDo

Bye, Olaf.
 
In addition to Olaf's excellent code, and I am sure you are already aware of, I would make sure the table is indexed on the numbers, as insert will create the new record at the end of the table...
 

gfrlaser,

I just noticed your question posted on 13 Dec 08 15:56
a star for you.. how do you give stars?

Well, you press that link "Thank OlafDoschke for this valuable post!" - it is located on the bottom of every member's every post - except your own, of course. Than you have to confirm your wish to give him a star on the form that appears after that.

It's a good idea to do this - especially if you just needed to use this again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top