Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> ODP.NET and LONG RAW

ODP.NET and LONG RAW

From: Kevin Toepke <ktoepke_at_rlcarriers.com>
Date: Fri, 29 Aug 2003 06:31:23 -0800
Message-ID: <F001.005CDF90.20030829063123@fatcity.com>


Help!

I am having trouble loading a JPEG image into Oracle via ODP.NET. I am getting the ORA-00932: Inconsistent datatypes error message when attempting to load the image into a LONG RAW column.

If this wan't an Oracle Apps table, I would use a BLOB column instead of a LONG RAW, but my hands are tied.

I have enclosed the code I am using to attempt to load the image. I know its probably something stupid, but I just can't see it in the pre-long weekend fog.

TIA
Kevin

    Private Sub loadOracle(ByVal intPersonID As Integer, _

                           ByVal img As Image)
        Dim ms As New System.IO.MemoryStream()
        img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
        Dim b(ms.Length - 1) As Byte
        ms.Position = 0
        ms.Read(b, 0, ms.Length)

        Dim ob As New OracleBinary(b)

        Dim sp(2) As OracleParameter

        sp(0) = New OracleParameter("i_person_id", OracleDbType.Int64,
ParameterDirection.Input)
        sp(0).Value = intPersonID
        sp(1) = New OracleParameter("i_table_name", OracleDbType.Varchar2,
ParameterDirection.Input)
        sp(1).Value = "PER_IMAGES"
        sp(2) = New OracleParameter("i_img", ob)
        sp(2).DbType = DbType.Binary
        sp(2).Direction = ParameterDirection.Input
        sp(2).OracleDbType = OracleDbType.LongRaw
        sp(2).Size = ob.Length
        sp(2).Value = ob

        Dim sql As String
        sql = "INSERT INTO hr.per_images (" & _

" image_id" & _
" ,image" & _
" ,parent_id" & _
" ,table_name" & _
") VALUES (" & _
" hr.per_images_s.NEXTVAL" & _
" ,:i_img" & _
" ,:i_person_id" & _
" ,:i_table_name" & _
")" cOracle.runDML(sql, sp, Me.ToString)
    End Sub
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Kevin Toepke
  INET: ktoepke_at_rlcarriers.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Fri Aug 29 2003 - 09:31:23 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US