Solved

how to retrieve blob field in sql select statement

Posted on 2011-09-23
6
1,621 Views
Last Modified: 2012-05-12
I have a field that "hugeblob" type, database is Oracle 10g.  How do I retrieve the value in the field in my sql select statement, i.e. Select answer from dual  (answer is a blob field).
0
Comment
Question by:Mike Johnson
6 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 84 total points
ID: 36587540
You cannot.  You can convert it into hex piece by piece but that is it.

You will likely need to write code to retrieve the binary object and work with it.
0
 
LVL 15

Assisted Solution

by:Devinder Singh Virdi
Devinder Singh Virdi earned 83 total points
ID: 36587665
You can limit your result to few character by using substring function dbms_lob package as

Please read the following link.
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm
0
 
LVL 15

Assisted Solution

by:x77
x77 earned 83 total points
ID: 36588195
Note that you can cast a Blob Data to a Stream:

         Dim Datos = Rdr.GetOracleBlob(2)
         Using BR As New BinaryReader(DirectCast(Datos, Stream))

Note. I am using Oracle.DataAccess
Try
            Dim Rdr = cmd.ExecuteReader
            If Rdr.Read Then
                'Dim Datos = cmd.ExecuteScalar
                Dim Estado = Rdr.GetValue(0)
                Dim activo = Rdr.GetValue(1)
                Dim Datos = Rdr.GetOracleBlob(2)
                Using BR As New BinReader(DirectCast(Datos, Stream))
                    Prj = New Proyecto(BR, False)
                    Prj.Estado = CByte(Estado)
                    Prj.Activo = "1".Equals(activo)
                    Prj.ProyectoPublico = True
                End Using
            End If

        Catch ex As Exception
            MessageBox.Show(ex.Message, "Cargando Proyecto Desde Base de datos")
        End Try

Open in new window

0
 
LVL 69

Expert Comment

by:Qlemo
ID: 37242425
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question