RE: How Do I Update a Blob Column?
Posted in 1998
---------- Tim Owens (towens@bsat.com) asked, perfectly reasonably: >Here's a very simple question: >How do I update a blob column in an existing row (through SQL)? >I can insert a new row with blob data just fine by using the LOAD command. >However, I can't seem to find the right syntax for updating a blob column in >an existing row? Succinctly, you don't. There are no blob literals in Informix's dialect of SQL, which is in many ways a grievous failing. In particular, it means that you cannot write an SQL statement which contains a blob on the RHS of the SET clause of an UPDATE statement (unless the blob exists in another table, when you can select that blob with a sub-SELECT statement, but that begs the question - how did you get the blob into the other table). There's a program in the IIUG archives called updblob - written by Yours Truly, so this isn't an unbiassed recommendation - which can be used to UPDATE a blob value from a file. It isn't very complex code, and it does the job, but it still doesn't use true blob literals because there aren't any. The blob file will be inserted verbatim into the database; it is not encoded like the blob in a LOAD statement. Yours, Jonathan Leffler (jleffler@visa.com) #include <bother.ms-exchange.h> PS: Sample usage for updblob: updblob -d somedbase -t blobtable -k col1="abcd" -k col2="1998-05-18" \\ -c blobcolumn -f blob.file The combination of col1 and col2 should be a candidate key (unique identifier) for the table; the rest is reasonably self-explanatory. It only handles a single blob file at a time.