Subject Re: Problem in Bulk Insertion in Firebird - Please Help
Author Manish Lal Joshi
Dear Svein Erling Tysvaer,

Okai i searched for a while and found out that prepared statements and
also bulkwise transaction committing can reduce this time taken.
And i implemented it too.
Guess what,the performance increased.
Previously 1 mins 21 secs was required for a particular task.
But now it only requires 16 secs.
No as you have suggested for using EXTERNAL TABLES.
I was exploring that too but i got stuck.
For test i did it like this:

in C#
TextWriter twriter = new StreamWriter(@"c:\EXTERNALTABLES\ext1");
for (int i = 0; i < 10; i++)
twriter.WriteLine(i);
twriter.Close();

After that i tried to assign this ext1 file as EXTERNAL TABLE like this
command.CommandText = @"CREATE TABLE TEMP1 EXTERNAL FILE
'c:\EXTERNALTABLES\ext1'(ID INTEGER);";
command.ExecuteNonQuery();

It exexuted well but
when i tried to query table TEMP1 then i returned result but
not as expected.
It gave me garbage result
I did it like this:
command.CommandText = @"SELECT ID FROM TEMP1";
FbDataReader reader= command.ExecuteReader();
while (reader.Read())
{
int iii=reader.GetInt32(0);
}

The outputs were:
822742320
221383181
168637194
889851188
..
..

I think i am missing something..
Like the structure of file that i have to define.. but how..?
Please help me if you know..?

I want to compare all the results and then implement the method..

Thanks





--- In firebird-support@yahoogroups.com, Svein Erling Tysvaer
<svein.erling.tysvaer@...> wrote:
>
> Hi Manish!
>
> Firebird doesn't have any 'bulk insert' option, and I doubt EXECUTE
> BLOCK is the answer you are looking for, maybe you were thinking of
> EXECUTE STATEMENT (though I doubt that is any good answer for your
problem)?
>
> Why do you want bulk insert? Normal inserts can, if done properly and
> not too wide records, insert about 10000 records per second. Storing
the
> data into a flat file, declare this file as an EXTERNAL TABLE and then
> do an insert where you select from the external table is another option
> that is supposed to be even faster.
>
> Set
>
> Manish Lal Joshi wrote:
> > Hi,
> > I have just joined this group.
> > I am in real trouble.
> > I have been developing application in C# and MsSQL 2005.
> > As an embedded RDBMS was required so i swtiched to FB 2.
> > I have ported tables and Stored procedures successfully oin FB 2.
> > I have been using Firebrid (embedded version) 2.0.XXXXX and .net Data
> > Provider 2.0.1.0.
> > Till now every thing was working fine. But i am having problem with
> > insertion.
> > Previously i was using mssql's bulkcopy property to do bulk inserts
> > but now i dont know how to do bulk inserts in FB.
> > Can some body provide me the SP doing BULK insertions ?
> > I have tried using EXECUTE BLOCK inside SP but it says TOKEN UNKNOWN
> > 'BLOCK'.
> >
> > I have dont like this or i want something like this:
> >
> > from C# application i will be creating multiple insert statements like
> >
> > string statements=" INSERT INTO TABLE1 VALUES(1,1);
> > INSERT INTO TABLE1 VALUES(2,2);
> > INSERT INTO TABLE1 VALUES(3,3);

> > INSERT INTO TABLE1 VALUES(4,4);

> > INSERT INTO TABLE1 VALUES(5,5);
> > INSERT INTO TABLE1 VALUES(6,6); "
> >
> > And i will be calling stored procedure BULKUPDATE defined as
> >
> > SET TERM !! ;
> > CREATE PROCEDURE DUMPVALUE(datainput VARCHAR(250))
> > AS
> > BEGIN
> > EXECUTE BLOCK AS BEGIN
> > :datainput;
> > END
> > END
> > !!
> > SET TERM ; !!
> >
> >
> > I have been using FB from last 4 days.
> > Please help me with this and i will be very much grateful to you all..
>