Re: Length of a Smart Blob
Posted in 2008
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Snorri wrote:
> Basically, if you use lotofile(blob, "/some/path", "client") and you
> do an
> $ ls -l /some/path/> ls will give you the "length" of the file (blob in this case).
>
> That is the length I mean.
As far as I can tell, there is no SQL function that can determine the
length of a BLOB column. (I could be wrong, though.) Depending on what
your goal is, you could do it server-side in a C UDR or client-side in
ESQL/C or something like Python.
As a shameless plug, here's an untested sketch of how to do it in Python
with the InformixDB module:
import informixdb
conn = informixdb.connect("somedatabase")
cur = conn.cursor()
cur.execute("select blobcol from sometable where whatever")
for row in cur:
print row[0].stat()['size']
Hope this helps,
--
Carsten Haese
http://informixdb.sourceforge.net
There is a datablade "sblob_info.1.5" that has a function sblobstatsize that
return the length of the smart blob field.
select sblobstatsize(smartblob_field) from table;
Alternatively you can cast the field:
select length(smartblobobject::lvarchar::clob) from table;
Guillermo Gómez Valcárcel
GRAFIA S.A.
Madrid, Spain
-----Mensaje original-----
De: informix-list-bounces@iiug.org [mailto:informix-list-bounces@iiug.org]
En nombre de Carsten Haese
Enviado el: viernes, 31 de octubre de 2008 19:34
Para: informix-list@iiug.org
Asunto: Re: Length of a Smart Blob
Snorri wrote:
> Basically, if you use lotofile(blob, "/some/path", "client") and you
> do an
> $ ls -l /some/path/> ls will give you the "length" of the file (blob in this case).
>
> That is the length I mean.
As far as I can tell, there is no SQL function that can determine the
length of a BLOB column. (I could be wrong, though.) Depending on what
your goal is, you could do it server-side in a C UDR or client-side in
ESQL/C or something like Python.
As a shameless plug, here's an untested sketch of how to do it in Python
with the InformixDB module:
import informixdb
conn = informixdb.connect("somedatabase")
cur = conn.cursor()
cur.execute("select blobcol from sometable where whatever")
for row in cur:
print row[0].stat()['size']
Hope this helps,
--
Carsten Haese
http://informixdb.sourceforge.net
_______________________________________________
Informix-list mailing list
Informix-list@iiug.org
http://www.iiug.org/mailman/listinfo/informix-list
__________ Informacisn de NOD32, revisisn 3573 (20081031) __________
Este mensaje ha sido analizado con NOD32 antivirus system
http://www.nod32.com