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

  • From: remi.mevaere@xxxxxxx
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Sun, 22 Mar 2009 10:16:12 +0100 (CET)

----- Mail Original -----
De: "Delphi Inspiration" <delphi@xxxxxxxx>
À: yunqa@xxxxxxxxxxxxx
Envoyé: Vendredi 20 Mars 2009 14:16:15 GMT +01:00 Amsterdam / Berlin / Berne / 
Rome / Stockholm / Vienne
Objet: [yunqa.de] Re: How to replace a Blob ?

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

----------------

Okay but I need to test before if the blob exist and create two functions 
(Insert/Update). Could i use the insert or replace function ? But i don't know 
exactly how it works ?

Thanks a lot,
Rémi



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



Other related posts: