Re: SQL insert/update text BLOB?
Posted in 1998
On 11 Jun 1998, Jim Kistler wrote:
> Okay, I can't find documentation on how to "insert" or "update"
> a text BLOB with an SQL statement.
There isn't a great deal of such documentation, partly because there isn't
much of a way to do it. It can only be done via ESQL/C -- there are no
text blob or byte blob literals in Informix's SQL.
> The error message says:
>
> 617: A blob data type must be supplied within this context.>
> Checking error message 617, I see that "BYTE and TEXT values must be
> assigned as whole units to columns of the same type".
>
> What does "assigned as whole units" mean?
Well, I don't find the message very helpful either. What it really means
is that you can do things like copy a blob from TableA to TableB, but for
introducing new values into a blob field, you have to provide an ESQL/C
locator structure with the correct info in it. This is painful.
However, I did send out a while ago a program called UPDBLOB which is now
in the IIUG archives which does update a blob from a data file. It
requires ESQL/C or c-code I4GL to compile it.
> I find no helpful information in any documentation that I have.
>
> I can enter the data with a form, so all is not lost, but shouldn't
> I be able to do this with SQL?
Yes, but you can't because there are no blob literals in the Informix
dialect of SQL. There was a feature request survey sent out at Partner's
Forum last week which included 'blob literals' as one of the features which
might be added. This would largely address your problem (if it is done
right).
It would also be nice to be able to do something like:
UPDATE BlobTable
SET BlobColumn = BlobFromFile("/my/file/name/here")
WHERE PK_Column = "PKValue";
I suspect you can do this, more or less, in IUS with smart blobs (BLOB and
CLOB data types).
Yours,
Jonathan Leffler (jleffler@informix.com) #include <witticism.h>
Guardian of DBD::Informix -- see http://www.perl.com/CPAN