Ironically, the support forum pointed me here.  The thing that would really 
help me out the most here is letting me know if there is a more efficient 
way of adding large amounts of data to a BLOB.  It seems that the appending 
to itself is not the best way to do it.

"Jiri Cincura" <disk...@cincura.net> wrote in message 
news:d2fa8bfb0904221103vf774ceehdcd91c1e486fd...@mail.gmail.com...
> Hi, I think the firebird-support is better place to ask. I don't know
> the blob handling internals, but my guess is, that the concatenating
> is creating new blob pages for complete content. Hence your database
> is bigger than expected (anyway the previous pages will be free and
> used later for other data).
>
> On Fri, Apr 3, 2009 at 17:49, Justin Sommercorn <jus...@paraben.com> 
> wrote:
>> I need to add large amounts of data to a BLOB, larger than I can store in
>> memory at one time. =A0The code I am using does do this; however, it 
>> caus=
> es
>> the database to grow sometimes more than 10x the size of the data I'm
>> adding. =A0I am sure I am doing this wrong and would appreciate any help
>> people can offer. =A0Here is the code I am using.
>>
>> internal static void AddFile(string file)
>> {
>> FileInfo f =3D new FileInfo(file);
>> FbTransaction transaction =3D
>> aquireDb.BeginTransaction(FbTransactionOptions.NoAutoUndo);
>> FbCommand cmd =3D new FbCommand();
>> cmd.Connection =3D aquireDb;
>> cmd.Transaction =3D transaction;
>> cmd.CommandText =3D "INSERT INTO FILES
>> (PATH,MD5,LASTACCESSED,LASTMODIFIED,CREATED,MATCHEDHASH) VALUES ('" +
>> f.FullName + "','md5','" + f.LastAccessTime + "','" + f.LastWriteTime +
>> "','" + f.CreationTime + "',1)";
>> cmd.ExecuteNonQuery();
>> cmd.CommandText =3D "SELECT GEN_ID(FILES_ID,0) FROM RDB$DATABASE";
>> long id =3D (long)cmd.ExecuteScalar();
>> using (FileStream fs =3D new FileStream(f.FullName, FileMode.Open,
>> FileAccess.Read))
>> {
>> BinaryReader br =3D new BinaryReader(fs);
>> byte[] data =3D br.ReadBytes(10240);
>> cmd.CommandText =3D "UPDATE FILES SET DATA =3D @data WHERE ID =3D @id";
>> cmd.Parameters.Add(new FbParameter("@id", 1));
>> cmd.Parameters.Add(new FbParameter("@data", data));
>> cmd.ExecuteNonQuery();
>> cmd.CommandText =3D "UPDATE FILES SET DATA =3D DATA||@data WHERE ID =3D 
>> @=
> id";
>> while ((data =3D br.ReadBytes(data.Length)).Length > 0)
>> {
>> cmd.Parameters["@data"] =3D new FbParameter("@data", data);
>> cmd.ExecuteNonQuery();
>> }
>> transaction.Commit();
>> }
>>
>> As you can see I am trying to append the data to itself. =A0I couldn't 
>> fi=
> nd or
>> think of any other way to do this. =A0I did find that if I add the data 
>> t=
> o a
>> BLOB without assigning it to a record the file size of the database 
>> grows=
> by
>> the amount of data I'm adding. =A0I do not know how to assign a BLOB 
>> valu=
> e to
>> a certain record after the BLOB is already created though. =A0Any help is
>> appreciated, thank you in advance.
>>
>>
>>
>> -------------------------------------------------------------------------=
> -----
>> _______________________________________________
>> Firebird-net-provider mailing list
>> Firebird-net-provider@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
>>
>
>
>
> -- =
>
> Jiri {x2} Cincura (CTO x2develop.com)
> http://blog.vyvojar.cz/jirka/ | http://www.ID3renamer.com
>
> ---------------------------------------------------------------------------=
> ---
> Stay on top of everything new and different, both inside and =
>
> around Java (TM) technology - register by April 22, and save
> $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
> 300 plus technical and hands-on sessions. Register today. =
>
> Use priority code J9JMT32. http://p.sf.net/sfu/p
> _______________________________________________
> Firebird-net-provider mailing list
> Firebird-net-provider@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
> 



------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to