[yunqa.de] Re: How to replace a Blob ?

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Fri, 20 Mar 2009 14:16:15 +0100

remi.mevaere@xxxxxxx wrote:

>I don't know if it possible, and i don't know how i could replace a blob by 
>another ?
>
>I have a database, with a table named "INICONF" with one column named 
>"fichier" (which is a blob), i just want to store one and only one blob.. 
>Actually i do this :
>
>------------------------------------
>
>sqlite3_prepare_v2(BDD, 'DELETE FROM INIConf', -1, @Stmt, nil);
>....
>...
>..
>sqlite3_prepare_v2(BDD, 'INSERT INTO INIConf (fichier) VALUES (?)', -1, @Stmt, 
>nil);
>... 
>Inserting the blob with delphi
>...
>
>------------------------------------
>
>Is there a better way to do this (replace a blob) ? 

SQL UPDATE works with blobs just as with other datatypes. I suggest you add an 
integer primary key ID to your table and update your record like in this plain 
SQL example:

  drop table if exists INICONF;
  create table INICONF (ID integer primary key, FICHIER blob);
  insert into INICONF values (1, X'01020A0B');
  select * from INICONF;

  update INICONF set FICHIER = X'03040C0D' where ID = 1;
  select * from INICONF 

Note: X'01020A0B' is a blob literal notation. It is available in DISQLite3 Pro. 
You can replace it with parameters and bind the blob to your statement like you 
already do in your example code.

These demo projects cover BLOB handling and might be of general interst:

  DISQLite3_Blob_and_Streams.dpr
  DISQLite3_Incremental_Blob.dpr

Ralf 

_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: