Accessing IMAGE Columns in SQL Server

I'm trying to use the TG4MSSQL to access tables in a SS2k database. All is well, except for 1 table that has an IMAGE column in it. I must say that I'm a little surprised and disappointed that the 10gR2 gateway for MSSQL apparently translates these things into LONG RAW columns, which are known to be antiquated and minimally supported. However, I still need access to the data, and ultimately, I need it in a BLOB. Doing simple queries (in TOAD) such as:
select * from image@tg4ss where image_id = 1;
returns the row, and I can use TOAD to determine that all the data is there. However, apparently, you cannot use PL/SQL to bind more than 32K of this data into a variable, so I haven't had much success there.
The only way I know of converting a long raw to a blob is to use the to_lob function, but that's only good in the select list of a subquery of an insert statement. Thing is, that doesn't seem to work with the gateway. I tried something like:
insert into my_blob_table( id, image )
select id, to_lob(image) as image from image@tg4ss where id = 1;
That gets me a ORA-00997: illegal use of LONG datatype.
In fact, I can't even do this:
insert into my_long_raw_table( id, image )
select id, image from image@tg4ss where id = 1;
I get the same error on that command.
Now, I can do this, but I only get the first 32k of the image:
begin
for I in (select id, image from IMAGE@tg4ss)
loop
insert into my_long_raw_table( id, image )
values (I.id, I.image);
end loop;
end;
So, does anyone know how you can get image data out of an SQL Server database into a blob value? If so, I'd appreciate a reply. Thanks.
-Rich.

Hello Rich,
I found your article after running into the same problem. I imagine you've dealt with this one way or another already but just in case...
The reason the LONG RAW gets truncated is explained in:
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/datatypes.htm#i43252
Basically, LONG RAW variables are limited to 32760 bytes inside PL/SQL. The ORA-00997 error is explained a little in:
http://www.dbaxchange.com/3_4_longdatatypes.htm
The only solution I found to work was to create a Java utility that read in each LONG RAW value (one at a time) and then update a record in a table's BLOB column. This was even a bit tricky. I found the gateway would lock up if I tried to do too much at a time. I kept it simple my reading all column IDs into an array and then looping through the array while executing a simple select statement that retrieved the LONG RAW value. I concatenated the id to the end of the select statement because prepared statements seemed to be one of the reasons the gateway locked up. I used a ByteArrayInputStream object to populate the BLOB in an update prepared statement for each LONG RAW value processed in the loop.
- Aaron

Similar Messages

  • How to export an image column from SQL server to an excel

    Hi team,
    Would like to know how can i get an Image column storeed in SQL Server database to get copied in Excel (Hard Drive).
    Requirement : Need to get Username, User email address and User photo in to an excel sheet from SQL server database.
    Fix: I can get Username and Useremail adress however could not find a way to export /Copy user Image.
    Please suggest
    Thanks,
    venkatesh

    This is an Oracle forum. Your question relates to SQL Server and Excel, neither of which are Oracle related.

  • How can I export image column from SQL Server 2000

    Hi everybody,could someone tell me how can I export an entire column( pictures type) to a folder on disk?I've tried the textcopy.exe under the SQL installation's binn folder,it can only export one picture a time,I'm trying to find an automated way to export
    the whole colum's images to a folder,I'm using SQL Server 2000.

    Vishal,thanks for the replay,I've tried the BCP method but it seems does not work on my Sql Server 2000,also the SSIS package method is demonstrated with Sql Server 2008 R2 and my machine does not have the visual application to try it.In the BCP method,I
    got prompt  indicating me that I wrote something wrong in the grammer,and I'm pretty sure that maybe I made something wrong in the below part,the grammer makes me confused
    INSERT
    INTO @sqlStatements
    SELECT 'BCP "SELECT Photograph_Data FROM [ALBSCH_Trial].[dbo].[Photograph] WHERE Photograph_ID = '''
    + CAST(Photograph_ID AS VARCHAR(500)) + '''" queryout ' + @OutputFilePath
    + CAST(Photograph_ID AS VARCHAR(500)) + '.jpg -S localhost\SQLEXPRESS2008 -T -f C:\SQLTest\Images.fmt'
    FROM dbo.Photograph

  • Can you store an Image in MS SQL Server 2005

    Hello,
    How possible is it to store customer uploaded images to MS SQL Server 2005.
    Any examples and is there a down turn to retrieving the data from the DB?

    How possible is it to store customer uploaded images to MS
    SQL Server 2005.
    Yes, you can store binary data in a BLOB (varbinary) column. Google turns up tons of hits on "storing images in sql server 2005". For example
    http://www.databasejournal.com/features/mssql/article.php/3719221/Storing-Images-and-BLOB- files-in-SQL-Server.htm
    Any examples
    http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Images_05.html
    is there a down turn to retrieving the data from the DB?
    It requires more database storage. So it can bloat your database. Plus there is the resources involved in retrieving the images from the database. Usually, it is better to just store the file path and save the actual image files on the file system.

  • Desc doesn't show datetime columns from SQl Server

    Hi Everyone,
    I have working db link to sql server using hsodbc:
    Oracle 10.2 on AIX using freetds odbc driver version 0.82.
    I can access tables on sql server but oracle sees only varchars and numerics columns in a table.
    Is there a way to select datetime columns from sql server using hsodbc?

    when hsodbc does not show a certain data type it is commonly related to the fact that HSODBC doesn't support the related ODBC data type.
    In general you have a data type in your SQL Server which is mapped to an ODBC data type by the ODBC driver. HSODBC then maps the ODBC data type to an Oracle equivalent and when the ODBC data type isn't supported by HSODBC it just drops it from the select list.
    So for a root cause analysis an ODBC trace is required to determine the mapping of the FreeTDS ODBC driver.
    With this info we can then compare the mapping documented in the HSODBC manual and if the ODBC data type isn't listed as a supported data type you then need to cast the data type on the source side to a different data type (for example varchar/char).
    So please post the ODBC trace and I'll have a look.
    - Klaus
    Edited by: kgronau on Apr 2, 2013 12:50 PM
    BTW, here the link to the HSODBC docu:
    http://docs.oracle.com/cd/B19306_01/server.102/b14232.pdf
    Oracle® Database
    Heterogeneous Connectivity Administrator's Guide
    10g Release 2 (10.2)
    B14232-01
    B.1 Mapping ANSI Data Types to Oracle Data Types Through an ODBC
    Interface

  • How to add byte[] array based Image to the SQL Server without using parameter

    how to add byte[] array based Image to the SQL Server without using parameter.I have a column in table with the type image in sql and i want to add image array to the sql image column like below:
    I want to add image (RESIM) to the procedur like shown above but sql accepts byte[] RESIMI like System.Drowing. I whant that  sql accepts byte [] array like sql  image type
    not using cmd.ParametersAdd() method
    here is Isle() method content

    SQL Server binary constants use a hexadecimal format:
    https://msdn.microsoft.com/en-us/library/ms179899.aspx
    You'll have to build that string from a byte array yourself:
    byte[] bytes = ...
    StringBuilder builder = new StringBuilder("0x", 2 + bytes.Length * 2);
    foreach (var b in bytes)
    builder.Append(b.ToString("X2"));
    string binhex = builder.ToString();
    That said, what you're trying to do - not using parameters - is the wrong thing to do. Not only it is insecure due to the risk of SQL injection but in the case of binary data is also inefficient since these hex strings are larger than the original byte[]
    data.

  • I am trying to have access tables of the Sql Server through the Oracle

    I am trying to have access tables of the Sql Server through the Oracle and this being occurred the error:
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message: [Generic Connectivity using ODBC][H006] The init parameter <HS_FDS_CONNECT_INFO> is not set.
    Please set it in init <orasid>.ora file.
    ORA-02063: preceding 2 lines from HSMSQL
    I created the ODBC with name HSMSQL.
    I made all the configurations in the archives
    tnsnames.ora:
    HSMSQL=
    (DESCRIPTION=
    (ADDRESS= (PROTOCOL = tcp)(HOST = wsus)(PORT = 1521))
    (CONNECT_DATA =
    (SID = HSMSQL)
    (HS = OK)
    listener.ora:
    (SID_DESC = (SID_NAME=HSMSQL)
    (ORACLE_HOME= C:\oracle\ora92)
    (PROGRAM =hsodbc)
    initHS_SID.ora:
    HS_FDS_CONNECT_INFO = HSMSQL
    HS_FDS_TRACE_LEVEL = OFF
    -- Create database link
    create database link HSMSQL.US.ORACLE.COM
    connect to TESTE identified by TESTE2
    using 'HSMSQL';
    But when I execute query the error occurs:
    Select * from TabTeste@HSMSQL
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message: [Generic Connectivity using ODBC][H006] The init parameter <HS_FDS_CONNECT_INFO> is not set.
    Please set it in init <orasid>.ora file.
    ORA-02063: preceding 2 lines from HSMSQL
    Please they help me, thanks, Paulo.

    Hi,
    It seems that your configuration is Ok. By the way, the workaround for this error is:
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    [Transparent gateway for ODBC][H001] The environment variable <HS_FDS_CONNECT_INFO> is not set.
    * Set HS_FDS_CONNECT_INFO in the hs{sid}init.ora file to the data source name.
    Example: HS_FDS_CONNECT_INFO = <ODBC DataSource Name>
    * Make sure the hs{sid}init.ora file exists in the ORACLE_HOME/hs/admin directory and has the same name as the SID in the LISTENER.ORA.
    Example: If SID=hsodbc in the listener.ora file, then the hs{sid}init.ora file would be named ORACLE_HOME/hs/admin/inithsodbc.ora
    For more information see if this [url http://forums.oracle.com/forums/thread.jspa?forumID=61&threadID=576975]thread can help you.
    Cheers

  • Import MS Access 2013 tables into SQL Server 2012

    Hi there,
    Is there a step by step example somewhere showing how to import an MS Access 2013 table into SQL Server 2012?
    I have read the existing posts and don't see a definitive answer.
    I have installed MS Access 2010 engine, first 32 bit then 64 bit.
    I have installed the MS Access 2013 runtime on my server.
    I use the Office 2015 Access Database Engine OLE DB Provider.
    I get the error:
    Error 0xc0202009: Source - APEntries [1]: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E37.
    Error 0xc02020e8: Source - APEntries [1]: Opening a rowset for "`TableName`" failed. Check that the object exists in the database.
    The post regarding the above errors doesn't resolve the issue.
    I have full administrative permissions on the server.
    What is the trick to making this work?
    Thanks,
    Ric
    Ric Miller

    Hi there,
    I tried the exact same operation on a third machine.
    This machine has Windows 8.1 64 bit, SQL Server 2012 64 bit, MS Office 2013 Plus 32 bit.
    I am the administrator on this machine.
    I installed this:
    Microsoft Access Database Engine 2010 Redistributable 32 bit (because I have MS Office 2013 plus 32 bit installed.)
    From here:
    http://www.microsoft.com/en-us/download/details.aspx?id=13255
    It won't let me install the 64 bit version without uninstalling MS Office 32 bit.
    I created an MS Access database on this machine using MS Access 2013 and created a table with 3 records.
    I used the "Import and Export Data (32 bit)" from the start menu.
    After I installed the "Database Engine 2010 32 bit" driver above, I now have the option of "Office 2015 Access Database Engine OLE DB Provider" as Data Source which I did not have prior to doing this installation.
    I selected the driver and added the Properties of the Data Source Name file location of the MS Access file. I am using a blank password.
    I go thru the same sequence of selecting a table to import and after running the result is the same:
    Error 0xc0202009: Source - APEntries [1]: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E37.
    "Error 0xc02020e8: Source - APEntries [1]: Opening a rowset for "`TableName`" failed. Check that the object exists in the database."
    This seems to be consistent across three machines with three operating systems with the same files and the same result.
    I understand that some people have gotten this to work.
    I would appreciate it if anyone can report an error in the above procedure to me.
    Thanks,
    Ric
    Ric Miller

  • JAVA, sqlserver - Need to load an image from the sql server database

    hi,
    I need to load an image from the sql server database using java. I have connected to the database and getting all other records except the records for a photo (datatype = LONGVARBINARY) and Remarks (datatype = LONGVARCHAR).
    I am using java and sql server db. The photo and remarks are stored in the db. and i need to show the image and the remarks fetching them from there.
    I get the error :
    Thread-9 org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
    How can I achieve this?
    Thanks,
    Gargi

    Exactly. And are you using MySQL?
    No. You are using Microsoft SQL server if I have to believe your initial post. A quick google tells me that the dialect class to use is:
    org.hibernate.dialect.SQLServerDialect

  • Problems displaying images stored in SQL Server as Datatype "image"

    I am trying to display an Image stored in SQL Server as
    datatype
    'image' and it only shows a portion of the image.
    It seems to be tied to the size (kb) of the image since the
    larger the
    image the less of it is shown before it cuts off(sometimes it
    cuts off
    mid line so it's about the file size and not fitting the
    image on the
    screen).
    Here is the code I am using that deals with the image.
    [Bindable]
    public var theImage:ByteArray = new ByteArray;
    private function getScans_result(event:ResultEvent):void{
    var imageByteArray:ByteArray = event.result[0].Image;
    theImage = imageByteArray
    <mx:Image id="theIMG" width="160" height="220"
    source="{theImage}"/>
    Any Thoughts??

    I do that sort of thing using PHP and mySQL the binary part
    of the image is stored in a BLOB field (Binary Large OBject) along
    the rest of the information necessary for the http headers (e.g.
    mime type, file name, file size) being staored in their own fields.
    That info is then used to build the file using PHP. The PHP
    file contains a mySQL query whos result is echoed with the
    appropriate headers. The URL points at the PHP file rather than at
    any saved image.
    Here's the php:
    <?
    # display_imagebank_file.php
    # Note: the ID is passed through the url e.g.
    # this_files_name.php?id=1
    # connect to mysql database
    mysql_connect('HOST', 'USERNAME', 'PASSWORD');
    mysql_select_db('DATABASE');
    # run a query to get the file information
    $query = mysql_query("SELECT FileName, MimeType, FileSize,
    FileContents FROM blobTable WHERE ID='$id'");
    # perform an error check
    if(mysql_num_rows($query)==1){
    $fileName = mysql_result($query,0,0);
    $fileType = mysql_result($query,0,1);
    $fileSize = mysql_result($query,0,2);
    $fileContents = mysql_result($query,0,3);
    header("Content-type: $fileType");
    header("Content-length: $fileSize");
    header("Content-Disposition: inline; filename=$fileName");
    header("Content-Description: from imagebank");
    header("Connection: close");
    echo $fileContents;
    }else{
    $numRows = mysql_num_rows($query);
    echo "File not found <br>";
    echo $numRows;
    echo " is the number of rows returned for id = ";
    echo $ID;
    ?>
    Hope that helps
    Phil

  • Displaying images stored in SQL Server

    Is there someway of displaying images stored within SQL
    Server. Is FDS required? Prefer a method to display images without
    using FDS; Web Service would be okay if that can work

    I do that sort of thing using PHP and mySQL the binary part
    of the image is stored in a BLOB field (Binary Large OBject) along
    the rest of the information necessary for the http headers (e.g.
    mime type, file name, file size) being staored in their own fields.
    That info is then used to build the file using PHP. The PHP
    file contains a mySQL query whos result is echoed with the
    appropriate headers. The URL points at the PHP file rather than at
    any saved image.
    Here's the php:
    <?
    # display_imagebank_file.php
    # Note: the ID is passed through the url e.g.
    # this_files_name.php?id=1
    # connect to mysql database
    mysql_connect('HOST', 'USERNAME', 'PASSWORD');
    mysql_select_db('DATABASE');
    # run a query to get the file information
    $query = mysql_query("SELECT FileName, MimeType, FileSize,
    FileContents FROM blobTable WHERE ID='$id'");
    # perform an error check
    if(mysql_num_rows($query)==1){
    $fileName = mysql_result($query,0,0);
    $fileType = mysql_result($query,0,1);
    $fileSize = mysql_result($query,0,2);
    $fileContents = mysql_result($query,0,3);
    header("Content-type: $fileType");
    header("Content-length: $fileSize");
    header("Content-Disposition: inline; filename=$fileName");
    header("Content-Description: from imagebank");
    header("Connection: close");
    echo $fileContents;
    }else{
    $numRows = mysql_num_rows($query);
    echo "File not found <br>";
    echo $numRows;
    echo " is the number of rows returned for id = ";
    echo $ID;
    ?>
    Hope that helps
    Phil

  • Import IMAGE type from SQL Server to BLOB in Oracle

    Hello,
    Is there a way to import a IMAGE type from SQL Server to BLOB type in Oracle from one table to another through a database link?
    I'm waiting for an answer as soon as possible.
    Best regards,
    Florin
    Edited by: Florin Manole on Sep 10, 2008 11:53 AM

    Have you already configured a Heterogeneous Services and Generic Connectivity to create a database link from Oracle to SQL Server? I haven't tried copying IMAGE data from SQL Server via Heterogeous Services myself, but from the [data type map|http://download.oracle.com/docs/cd/B19306_01/server.102/b14232/apb.htm#sthref509] in the documentation, I would expect that it would work so long as the SQL Server ODBC driver maps the IMAGE data type to SQL_LONGVARBINARY
    Justin

  • What is Oracle's alternative to IDENTITY Column in SQL Server/ DB2

    What is Oracle's alternative to IDENTITY Column(Auto Increment Column) in SQL Server/ DB2 ? Is Sequence and Trigger the only way out for this?
    Why is Oracle not creating anything like an Identitiy column in SQL Server?

    What is Oracle's alternative to IDENTITY Column(Auto
    Increment Column) in SQL Server/ DB2 ? Is Sequence
    and Trigger the only way out for this?Of course not, you can use in your inserts sequences as well:
    insert into blahh values (my_seq.nextval, ...) and use returniong clause to get the value back if necessary
    You can use them in insert with subselects
    insert into blah
    select my_seq.nextval, ...
    from ....
    >
    Why is Oracle not creating anything like an Identitiy
    column in SQL Server?Because they are different companies with different people and thoughts and existing mechanism is sufficient i.e. one can even argue that it is even more flexible than identity btw ;)
    Gints Plivna
    http://www.gplivna.eu

  • How to access Oracle 8g from SQL Server 2005 SP3 EE 64 Bits ?

    Dear All,
    How to access Oralce 8g from SQL Server 2005 SP3 EE 64 Bits (liked server).
    Best regards,
    Miguel Gavinhos

    Hi!
    For the Oracle version is 8.1.6. what should I install, to access Oracle trought a linked server.
    Best regards
    Miguel Gavinhos

  • How to save image files into SQL Server?

    Hello, All:
    Does anyone know how to save image files into SQL Server? Does the file type have to be changed first?? Please help me! Thank you!

    You need a BLOB field (usually)... Then you can check this tutorial out:
    http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/exercises/BLOBPut/
    There are other exercises on that site, including one on reading the images back.

Maybe you are looking for

  • Registering Repsvr8 control in oracle 8i Lite

    hi, I'm developing an application wherein I've to connect to Oracle 8i Lite database for Windows CE. I'm using Windows CE toolkit for Visual C++ version 2.0 on Windows CE based palm device. I'm in confusion of how to connect to 8i Lite Database. Are

  • Trigger and compare waveforms then write to file

    I am trying to make a coincidence between two channels without using a SCA.  I have a Tek DPO 7104 scope where I have two PMT's connected.  PMT1 is on channel 1 and PMT2 is connected to channel 2.  I have my current vi setup to trigger on channel 1. 

  • Problems with opening Project Bin

    I'm a new user of Photoshop Elements 6 for Mac.   I do not use it with the organizer but keep my photos in iPhoto or elsewhere on the hard drive of my MacBook Pro.  When I open two images to to work on them at the same time the project bin does not o

  • Spinning Ball and cannot see my harddrive

    I'm having a problem seeing my hardrive when I log into the main user account. All of the other accounts work fine,"I see the harddrive in the other accounts". When I'm in the main account I don't see the hardrive or the Finder windows. I do see the

  • Comments section not loading on nypost website

    Today the comments section on nypost.com would not load I now there were recent updated my computer automatically did but I do not know how to get this working again I have followed the troubleshooting info and deleted cookies and cash but this has n