Subject Re: Adding blobs in SP
Author sdbeames
--- In ib-support@y..., Helen Borrie <helebor@t...> wrote:
> At 12:32 AM 14-09-02 +0000, you wrote:
> >How can I add two blobs in an SP?
> >This is where I'm up to...
> >
> >alter PROCEDURE INSERT_SUPPLIER (~snip~, Note BLOB, ~snip~)
> >AS
> >~snip~
> > if (f_BlobSize(Note) > 0) then
> > update SUPPLIERS set NOTE = String2Blob(f_BlobAsPChar(NOTE)
||
> >f_BlobAsPChar(:Note)) where SUPLRNO=:id;
> >
> >END !!
> >
> >This just clears the blob field!
> >Do I have to convert the CSTRING returned by f_BlobAsPChar() to a
> >VARCHAR somehow first?
> >
> >Using FB1/XP/FreeUDFLib
>
> A blob isn't a string so you can't concatenate two blobs and make
another
> blob out of them. When a blob is "updated" it is actually
replaced, i.e.
> the old BlobID is made null and a new BlobID set to point to the
new blob.
>
> Did you know that in Firebird you can actually pass a string type
directly
> to a blob?
>
> alter PROCEDURE INSERT_SUPPLIER (~snip~, Note varchar(100), ~snip~)
> AS
> ~snip~
> if (f_StringLength(:NOTE) > 0) then
> update SUPPLIERS set NOTE = f_BlobAsPChar(NOTE)||:NOTE
> where SUPLRNO=:id;
>
> heLen

Thanks Helen,
I was trying to convert my 2 blobs to strings, concatenate them,
then replace the stored blob. I think my problem is with the
concatenation of the CSTRINGs returned by the UDF functions. Is this
approach possible in an SP, or would I have to do it all at the
client?

Cheers,
Steve