Subject Re: Lot's of posts about Kursak's Problem
Author Artur Anjos

To all that replied to Kursak's problem. I'm sending this to this list but
Lester answer this in ib-support.

I'm answering this because I send Kursak's a small example on doing that
import, and I'm posting here the code he is using, because that's what's

Really, I don't think Kursak's problem belongs in either of this two lists.
He doesn't know how to code something, he just knows how to use visual
components. If a visual component does not do the job for him, he's stacked.

(Lester: I'm with you in that Perl argument. I'm really new to Delphi, but I
have lots of years of C, and not a minute in PERL. Redirecting a new user to
PERL is something that I critic too.)

Now, back to Kursak's Problem. Everyone here saw lot's of posts from Kursak
seeking some help. Everybody tried to help, but it's now getting there. Why?
Because this lists are not for 'Real Begginers'. I decided 6 months ago to
build a project using FB / Delphi / IBO, and forget about my big experience
in C, because I thougth that was the perfect combination for this project.
I'm almost finish with it, and I'm shure I took the correct way. I really
now the problems that a begginer could have here, because as I said, I'm one
of them. Now, let's resume what we all told Kursak:

- Use external files and a stored procedure in the server. That's the most
obvious thing to do. Kursak's file it's very simple, only 3 fields. He was
not abble to put it working because the table does not have fixed length
- Use a temporary file that he could query, pump the data into that file.
That's the way he tooks. But without coding this is an hard job to do....
So, he tooks a very nice approach: use the BDE to read the file (remember
that he's talking about using excel files?)

So, he had a problem here: how to pump the data inside that external file?
Lot's of posts in this list again...

One day he posts me directly. I tried to help here. I send him the 'begginer
way to do it': read the external file, parse each line, use a component to
post the data. I have send him a very simple code and now he's got something
that works. The final code is something like this:

// This will answer your questions about why he is using a IB_Script....


while not eof(FFile) do

// Notice the parsing example I give him was nice to follow up what the code
does in debug time
// Kursak's, of course, don't care about it and use it the same way. He want
a solution, not to understand the
// way it does it...
// I use lot's of 'Aux'iliary variables to make it easier for him to
understand... He use them all.
// This is one obvious reason why the procedure is slow.
// Also, he needs to parse the initial date field to a different format

// And now he is using an TIBOQuery, I think. More time wasted. But
TIBOQueries was
// the component that he was familiar with.


The end. This is an example of how to do it with the tools that he is used
to. Now he has a code that works, that it's easy for him to understand and
to fix if he needs to.
Now Kursak's had another problem: it's slow. It takes 7 minutes to insert
130,000 rows, thats an average of 300 records/second. I really think it's a
good average using AutoCommit for each line...

My suggestion to him was to do just a little optimizing: Replace the
TIBOQuery for a IB_Cursor, for example. Of course we can have a better way
here with IB_DSQL. But I'm just helping point out ways, not doing the job.
I'm trying also do show the differences between IBO components, bla bla bla.
Stupid things, you know, bad habits from an old teacher. I know that the
first step in every development is 'Read the Manual', study the components,
bla bla bla, and I try do implement this stupid idea in everyone.

And what about transactions? Do you see any in my example? Oh yeah, he is
using the default transaction.

And looking at this code, I think we can all stop the discussion about '100%
CPU usage', don't we?

Long story with Kursak... First we have lot's of continous posts about a
simple problem to all of us (pumping a database), and lot's of other stories
the list didn't see nothing: how about the problem of 'the database will not
shrink after I delete the records from that table, and I need that 10Mb
back - I have a small hard disk space!'.

I really think that Kursak's has just one problem: he needs to do the job,
don't care how.

So, I finish this so lonnnnnnnnnnnnnnng story with two suggestions.

One for the list:
- I will take care of Kursak's problem. I started giving him a small piece
of code, and I will finish it! I will lose some time with it, and I will do
Kursak's job. (When I'm finished, Kursak's will have a high opmitized Data
Pump routine that we will not understand nothing about it - just the way he
wants it).

- One for Kursak:
Finished it the way you start it. You have a problem with something that I
send you, feed back to me, not to this list. Wait for my answering - I'm not
24 hours / day here (Thank's God!). I'm not an expert in Delphi/IBO, I'm
just a beginner like you (with a few more background, but a begginer). If
you have some other problem READ THE MANUAL before you post it into this
list. When you post something here, explain your problem in detail.


That's all, folks.

Artur Anjos