🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Faster way to just add a record

#3711
From: Ronald Loonstra
Date: Wed, 26 Jun 2002 08:07
62 lines
2725 bytes
Christian,

An addition: You could use the SELECT-statement to check if the record you
want to add already exists:

int NEW_ID = 99;
...
AdoDataSet->CommandText = "SELECT * FROM CUSTOMER WHERE CUST_ID = NEW_ID";
AdoDataSet->Open();
if (!AdoDataSet->Eof) {.....}

Just an idea.
--
HTH

Ronald Loonstra
CodeFit Applications
www.codefit.nl

"Georgi Cholakov" <georgi.cholakov@mail.bg> schreef in bericht
news:3d195aad_2@dnews...
> Hi, Christian
> I saw the recommended tricks, but in my modest opinion they are useless or
> difficult to use. I think the reason for delay is in your SELECT
statement,
> because you first select all the data from the table Customer and then
> insert a new record. If you optimize your select to return a small number
of
> records the delay will be minimized.
> Try this: "SELECT * FROM CUSTOMER WHERE CUST_ID = 0" for example, where
> CUST_ID is the name of the primary key. This statement will return no
> records and it will be fastest & simplest way for your case.
>
> Georgi Cholakov
>
> "Christian Schneider" <csname@hotmail.com> wrote in message
> news:3d16bf57$1_1@dnews...
> >
> > I just want to add a record to a table. I am now
> > using something like this:
> >
> > AdoDataSet->CommandText = "SELECT * FROM Customer";
> > AdoDataSet->Open();
> > AdoDataSet->Insert();
> > AdoDataSet->FieldByName(...) = ...
> > AdoDataSet->Post();
> > AdoDataSet->Close();
> >
> > The problem is, that Open() can take very long if the
> > table is large. It would be much faster to use an
> > "INSERT INTO"-Statement, but I can't use it because
> > my record contains BLOB-Fields.
> >
> > It there really no other way to just add
> > a record to a table without waiting several seconds?
> >
> >
> > Christian Schneider
>
>
>
>
Technical Details
Message-ID: <3d197525_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!supernews.com!news3.cnt.ru!srcc!newsfeed.gamma.ru!Gamma.RU!netnews.com!xfer02.netnews.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews
References: <3d16bf57$1_1@dnews> <3d195aad_2@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,245e9e27193aa62b
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2002-06-26 01:04:45 PST
From: "Ronald Loonstra" <r.loonstra@codefit.nl>
Newsgroups: borland.public.cppbuilder.database.ado
References: <3d16bf57$1_1@dnews> <3d195aad_2@dnews>
Subject: Re: Faster way to just add a record
Date: Wed, 26 Jun 2002 10:07:51 +0200
Lines: 64
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
NNTP-Posting-Host: 217.121.245.5
Message-ID: <3d197525_1@dnews>
X-Trace: dnews 1025078565 217.121.245.5 (26 Jun 2002 01:02:45 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!supernews.com!news3.cnt.ru!srcc!newsfeed.gamma.ru!Gamma.RU!netnews.com!xfer02.netnews.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews