From: Dan Nelson Date: July 20 2004 7:13pm Subject: Re: empty_blob() equivalent List-Archive: http://lists.mysql.com/mysql/169378 Message-Id: <20040720191355.GD61013@dan.emsphone.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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