Well Dave the problem is not with db_write_blob: it works fine. The problem is I dont want to use this procedure as it locks the database handle till the blob data is fetched from the database, this slows the downloads.
Therefore The better solution is after getting the blob from the database, release the handle and then write to a file which can be displayed as an image. This will also work during slow connections. through ns_returnfile
How to do the above is a prob.