Subject Re: [firebird-support] Update on Blob
Author Helen Borrie
At 01:31 PM 15/12/2003 -0200, you wrote:
>Hello,
>
> I need to make a update on a blob field like this:
>
>update table1
>set BlobFiled = 'Begin Text ' || BlobField || ' End Text'
>where ....
>
> I've do that and get an error: Conversion Error from String "BLOB"
>
>update table1
>set BlobFiled = 'Begin Text ' || cast(BlobField as varchar(200)) || ' End
>Text'
>where ....
>
> The same error...
>
>How can I do this?

You can't concatenate strings to blobs or blobs to blobs.

There are external functions (see FreeUDFLib) that can convert a blob to a
string, that you could try out in a stored procedure. You would have to
recreate the blob inside the SP, since blobs are never updated, always
replaced with a completely new blob and new blob_id.

The trap here is that varchars have a length limit of 32765 bytes, whereas
blobs have no length limit.

The safest thing to do is update the blob in the client, stream the updated
text back to a blob stream there, and pass the whole updated object back in
your SQL as a parameter of the appropriate blob subtype.

/heLen