• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 408
  • Last Modified:

Update Partial Blob

Good afternoon,
Ok this is a strange one, and before anyone states it I know it isnt realy best practise to store files in databases, but it makes life soo much easier for this issue, belive me.

Is it possible to copy a record with a blob filed, and then update part of the second blob.

The idea is to hold a file in the database, copy that file, and instead of transfering the entire files again, only update the parts of the file that has changed. So once the transaction has completed the second file can be downlaoded in it entirity and the file will be complete.

I hope Ive explained it ok, I know its a very weird question, but I need to solve this problem, and this is the best idea I have soo far.

Thank you
insert into files(`myblob`) VALUES (Select `myBlob` from `myTable` where `blobID`=27);

update `myTable` SET `mybob` = mid(`myBlob`,27,5,'myNEWDATA') where `blobID`=27;

So 27 is the start of the blob that needs updating, 5 is the length of the update, and myNEWDATA is the newData from the new file.

Open in new window

1 Solution
tonelm54Author Commented:
Ive found a solution, so just for reference the SQL code is:-
update `myTable` set `myBlobField` = REPLACE(`myBlobField`, 'oldData', 'newDat');

Open in new window


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now