Length of Blob Column
Posted in 2010
Topics: General Discussion
Is there a function to get the length of a blob column? We have been doing "SELECT LENGTH(b_byte_col) FROM table" in application code, but are moving to smart blobs (converting the bytes to blobs) and need a way to get the length. Thanks.
Hi, I'm far from being a specialist when it comes down to BLOBs, but I did some quick search and the findings are: - legth() does not support smart large objects. That's not new and you find out the hard way - I found one customer with the same problem, and apparently the solution for this lives in IBM own pages: http://www.ibm.com/developerworks/data/zones/informix/library/techarticle/db_sbl ob.html This is a freely available datablade or bladelet. You must understand it's not officially supported. You need to get the code, compile it, test it and hopefully use it. I'd say you can even create your own length(blob) function, to overcome the fact that the blade function has other name (would require query re-writing which can be easy or a big pain in your application). But this could have implications in case the function gets implemented in the future (which would make sense from where I'm standing). I didn't test the code, but I plan to do it. I checked and the author is still at IBM in the Information Management Unit. It would be possible to *try* to get her help if needed. If anybody else has other solution, please say. Currently I don't. On Thu, Feb 25, 2010 at 9:04 PM, MARY ANNA SINGER <maryanna@maryanna.net>wrote: > Is there a function to get the length of a blob column? > > We have been doing "SELECT LENGTH(b_byte_col) FROM table" in application > code, > but are moving to smart blobs (converting the bytes to blobs) and need a > way > to get the length. > > Thanks. > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > -- Fernando Nunes Portugal http://informix-technology.blogspot.com My email works... but I don't check it frequently... --0016e6dab059c9253c048074c62c
Well, I did test it.
The makefile has to be changed for it to compile in new (and not so new)
versions of IDS. The steps I took (Unix):
1- Uncompress the tar.Z file
2- ls $INFORMIXDIR/incl/dbdk
You should see a file like makeinc.linux
the suffix will depend on your platform
3- Edit the sblob_infoU.mak file and change the following line from:
then $(INFORMIXDIR)/bin/filtersym.sh link.errs ; \\\\
into:
then $(INFORMIXDIR)/bin/filtersym.sh <link.errs ; \\\\
(note the redirection. Did is due to a change in the filtersym.sh script. As
it is, the make would hang forever waiting on stdin).
4- make -f sblob_infoU.mak
If all goes well you'll have a new directory like "linux-intel". It will
depend on your platform. For SparcSolaris the blade is already compiled, but
I would recommend a new compilation. Inside the new directory is a file
*.bld. That is the newly created datablade.
Now you have to install it and register it against your database. Check the
README file and follow the instructions.
The test case included worked perfectly.
Finally, you can create your own length procedure like:
create procedure length(b blob) returning int8;
return ( SblobStatSize(b));
end procedure;
This would avoid changing your application code. But in the future IDS may
include a length function that accepts a blob parameter...
Regards and I hope this helps.
On Thu, Feb 25, 2010 at 11:02 PM, Fernando Nunes <domusonline@gmail.com>wrote:
> Hi,
> I'm far from being a specialist when it comes down to BLOBs, but I did some
> quick search and the findings are:
>
> - legth() does not support smart large objects. That's not new and you find
> out the hard way
> - I found one customer with the same problem, and apparently the solution
> for this lives in IBM own pages:
>
>
>
>
http://www.ibm.com/developerworks/data/zones/informix/library/techarticle/db_sbl
ob.html
>
> This is a freely available datablade or bladelet. You must understand it's
> not officially supported. You need to get the code, compile it, test it and
> hopefully use it.
> I'd say you can even create your own length(blob) function, to overcome the
> fact that the blade function has other name (would require query re-writing
> which can be easy or a big pain in your application). But this could have
> implications in case the function gets implemented in the future (which
> would make sense from where I'm standing).
>
> I didn't test the code, but I plan to do it. I checked and the author is
> still at IBM in the Information Management Unit. It would be possible to
> *try* to get her help if needed.
>
> If anybody else has other solution, please say. Currently I don't.
>
> On Thu, Feb 25, 2010 at 9:04 PM, MARY ANNA SINGER
> <maryanna@maryanna.net>wrote:
>
> > Is there a function to get the length of a blob column?
> >
> > We have been doing "SELECT LENGTH(b_byte_col) FROM table" in application
> > code,
> > but are moving to smart blobs (converting the bytes to blobs) and need a
> > way
> > to get the length.
> >
> > Thanks.
> >
> >
> >
> >
>
>
*******************************************************************************
> > Forum Note: Use "Reply" to post a response in the discussion forum.
> >
> >
>
> --
> Fernando Nunes
> Portugal
>
> http://informix-technology.blogspot.com
> My email works... but I don't check it frequently...
>
> --0016e6dab059c9253c048074c62c
>
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
>
--
Fernando Nunes
Portugal
http://informix-technology.blogspot.com
My email works... but I don't check it frequently...
--0016e65a08601576d10480819268