🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #190

Fastest Way to Insert a Number of Records via SQL

#190
From: Dan
Date: Mon, 04 Jun 2007 18:32
43 lines
2538 bytes
Hi Folks,

I need some help. I have some tables that I want to move to Access.  But 
moving the data from one format to the other seems to take FOREVER with 
my code.

For simplicity, the source is basically two tables, a source table which 
contains header information and forms the basis of a link to the 12 
records in a subtable.  The sub table is basically a memo field 
containing table-link information that, each of which has 3 fields, 
containing 520 records.  The new target format I am moving to basically 
breaks out that memo into 520 unique records in each of three tables.

As you could see, to import one complete record from the source, I would 
have to add the following number of records to the target:

1 Header Record
And then 12x representing each expanded subtable:
   520 (1st field) records
   520 (2nd field) records
   520 (3rd field) records

This is ends up being 6240+6240+6240+1 = 18,721 records!

Oh, why the new format?? why???  Seriously though, there are reasons for 
it!  For starters, the 1st and 2nd fields are the same in each 12 
sub-tables, so I can get away with only adding them once.  Then, there 
are a number of mathematical operations I would like to easily perform 
on the data, that can be performed via SQL, that it is another bonus; 
there are more.

So, performing 19K Insert statements, like I said, TAKES FOREVER.
What is the best way to do this besides the following pseudo:
   TADOQuery *Query;
   Query->SQL->Text = "INSERT ONE RECORD SQL STATEMENT"
   Quey->ExecSQL();

and then looping thru 19k more times?


Thanks in advance!

Dan
Technical Details
Message-ID: <46645ac3@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!news2.euro.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,d0a6c05550b4cac9,start
X-Google-Attributes: gid10698b,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Mon, 04 Jun 2007 13:32:35 -0500
From: Dan <Dan@do.not.spam>
User-Agent: Thunderbird 1.5.0.10 (Windows/20070221)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.database.ado
Subject: Fastest Way to Insert a Number of Records via SQL
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 216.174.165.174
Message-ID: <46645ac3@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1180981955 216.174.165.174 (4 Jun 2007 11:32:35 -0700)
Lines: 43
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!news2.euro.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail