insert blob in oracle (CF_SQL_BLOB) not working

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default insert blob in oracle (CF_SQL_BLOB) not working

    I've the following code that is supposed to upload an image as a BLOB in the
    oracle 9i db (I am using cf mx 7) <cffile action='readbinary'
    file='C:\projects\java\insertblob\tiger.jpg' variable='aBinaryObj'> <cfif
    isBinary(aBinaryObj)> comes here <cfset base64 = toBase64(aBinaryObj)>
    <cfelse> <cfabort showerror='The file does not appear to be a binary file'>
    </cfif> <cfquery name='insertImage' username='pcqureshis' datasource='arkdv'
    password='yellow200'> INSERT INTO images (image) values (<cfqueryparam
    value='#base64#' cfsqltype='CF_SQL_BLOB'> ) </cfquery> When i run this code,
    i get the following error
    --------------------------------------------------------------------------------
    -- Error casting an object of type to an incompatible type. This usually
    indicates a programming error in Java, although it could also mean you have
    tried to use a foreign object in a different way than it was designed. The
    error occurred in C:\Program Files\Apache
    Group\Apache2\htdocs\Cableways\uploadImage.cfm: line 21 19 : 20 : <cfquery
    name='insertImage' username='pcqureshis' datasource='arkdv'
    password='yellow200'> 21 : INSERT INTO images (image) values (<cfqueryparam
    value='#base64#' cfsqltype='CF_SQL_BLOB'>) 22 : </cfquery> 23 :
    ------------------------------------------------------------------------------
    so, is this a bug in cfmx 7 or what else could it be? I really need help on
    this, very urgent thank you

    shahzad Guest

  2. Similar Questions and Discussions

    1. insert blob in MySQL (CF_SQL_BLOB) not working
      I've read the post about "insert blob in oracle (CF_SQL_BLOB) not working" and followed the solution. The only difference here is that I am dealing...
    2. How to INSERT XML data into Oracle database
      Hi, Working on a solution where we are using XML as a means to export and import various data. Are Using ADO to save to (export ) XML using...
    3. insert blob
      Hi everyone. i would like to insert a file in a column i juste created a test table : { TABLE "informix".a row size = 56 number of columns =...
    4. Problem reading a blob field in oracle (no, just converting it)
      Hi, I read a blob field from oracle using the recordser("FIELD").GetChunk....... I get the good value out of it. The problem is that this data...
    5. How to Insert documents to a BLOB field
      Hi, I have an Access Front-End application and an Oracle Back-End for my tables. I have a BLOB field in one of the tables. I use Access form to...
  3. #2

    Default Re: insert blob in oracle (CF_SQL_BLOB) not working

    Hi,
    I was wondering why you want to convert the binary image to Base64. So, here
    we will consider insertion of pure binary as well as base64 data. First, lets
    consider the insertion of pure binary data.

    Here, I assume that you are having an Oracle table with column type BLOB.

    /*
    Inserting binary file as BLOB
    */
    <cffile action="readbinary" file="C:\projects\java\insertblob\tiger.jpg"
    variable="aBinaryObj">

    <cfif NOT isBinary(aBinaryObj)>
    <cfabort showerror="The file does not appear to be a binary file">
    </cfif>

    <cfquery name="insertImage" username="pcqureshis" datasource="arkdv"
    password="yellow200">
    INSERT INTO images (image) values (<cfqueryparam value="#aBinaryObj#"
    cfsqltype="CF_SQL_BLOB"> )
    </cfquery>


    In case, you want to put Base64 value in DB, please make the following changes.
    1) Change the DB table column type to CLOB
    2) Make subsequent changes in code snippet as follows


    /*
    Inserting base64 data as CLOB
    */
    <cffile action="readbinary" file="C:\projects\java\insertblob\tiger.jpg"
    variable="aBinaryObj">

    <cfif isBinary(aBinaryObj)>
    <cfset base64 = toBase64(aBinaryObj)>
    <cfelse>
    <cfabort showerror="The file does not appear to be a binary file">
    </cfif>

    <cfquery name="insertImage" username="pcqureshis" datasource="arkdv"
    password="yellow200">
    INSERT INTO images (image) values (<cfqueryparam value="#base64#"
    cfsqltype="CF_SQL_CLOB"> )
    </cfquery>

    Hope this helps.



    Best Regards,
    Jacob

    JacobG Guest

  4. #3

    Default Re: insert blob in oracle (CF_SQL_BLOB) not working

    I am an idiot. I was actually copying the code from
    [url]http://www.macromedia.com/cfusion/webforums/forum/messageview.cfm?catid=6&amp;th[/url]
    readid=843872&amp;enterthread=y and didn't even think as to why he was
    converting the image to base64 and even the error msg didn't make sense to me.
    As soon as i left, it hit me but it was too late and then your reply confirmed
    it. thank you for ur help

    shahzad Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139