List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:July 20 2004 7:13pm
Subject:Re: empty_blob() equivalent
View as plain text  
In the last episode (Jul 20), Jeyabalan Murugesan Sankarasubramanian said:
> Actually i need to add a wavefile in byte[] format to the table with
> column name blob_col of type blob.  In Oracle empty_blob() is
> inserted into the table. While retrieving OracleResultSet supports
> getBLOB(). This returns oracle.sql.BLOB. From this i am able to
> insert the byte[] with the following code.
> 
> oracle.sql.BLOB myblob = ((OracleResultSet)rs).getBLOB("blob_col");
> OutputStream os = myblob.getBinaryOutputStream();
> os.write(byteArray);
> 
> This works in Oracle, which i m migrating to MySQL. For this i need
> equivalent thing so that i can insert byteArray in column blob_col.

MySQL doesn't have any special blob functions.  They are treated as
very large string fields, so you should be able to do a plain UPDATE or
INSERT.  If you're using a language that supports bind variables or
placeholders, something similar to this should work:

query("UPDATE mytable SET blob_col=%s WHERE id=%d", byteArray, rowid)

-- 
	Dan Nelson
	dnelson@stripped
Thread
empty_blob() equivalentJeyabalan Murugesan Sankarasubramanian20 Jul
  • Re: empty_blob() equivalentDan Nelson20 Jul
Re: empty_blob() equivalentJeyabalan Murugesan Sankarasubramanian20 Jul
  • Re: empty_blob() equivalentDan Nelson20 Jul