Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > Oracle
|
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 4th, 2005, 07:10 AM
Registered User
 
Join Date: Jul 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ahali
Default how can i store image in oracle database

hi everybody
please i require help on this topic that is i am designing my final year project on banking system part of E-Banking system on VB.net i hae learned about how to store the data but there is one problem that is i want to store am image in the database but it is just not working out for me can anyone help me on this please
thankyou
ALLY HASSAN ALI
[email protected]

 
Old July 5th, 2005, 01:44 AM
_AP _AP is offline
Authorized User
 
Join Date: Jun 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to _AP
Default

what is just not working?
concretize.



 
Old July 5th, 2005, 08:47 PM
_AP _AP is offline
Authorized User
 
Join Date: Jun 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to _AP
Default

I understand in VB nothing :)
and took code from http://www.sql.ru/forum/actualthread.aspx?tid=197574

<SKIP....>
         ls_str$ = "select IMAGE from WH_REPORT_IMAGES ...."
         With lrec
            Set .ActiveConnection = g_OraConn
            .Source = ls_str$
            .LockType = adLockOptimistic
            .CursorType = adOpenKeyset
            .CursorLocation = adUseClient
            .Open
            If .EOF = .BOF And .EOF = True Then
                <SKIP....>
               CheckReportFile = False
               Exit Function
            End If
         End With

         Set mStream = New ADODB.Stream
         With mStream

            .Type = adTypeBinary ' Set it to a binary file type
            .Open ' Open it

            ' This writes the image from the blob field to the buffer
            .Write lrec.Fields("Image").Value

            ' This saves the stream to a file on disk
            .SaveToFile ls_filePath$
            .Close

         End With
         Set mStream = Nothing
         lrec.Close
         Set lrec = Nothing
     End If


 
Old July 6th, 2005, 02:43 AM
Registered User
 
Join Date: Jul 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ahali
Default

AP
thanx for the reply but basically i am using oracle blob command but i cannot get to the correct syntax about how to store the image in the database, thanx for the link but please xcuse me cause i am not good at russian but if you can help me out with the SQL commands for storing
image in oracle database.
thank you
ALLY HASSAN ALI

 
Old July 6th, 2005, 04:04 AM
_AP _AP is offline
Authorized User
 
Join Date: Jun 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to _AP
Default

You have to read "Oracle® Database Application Developer's Guide - Large Objects".
http://mordor.tengry.com/db/oracle/d...b10796/toc.htm

This code from manual with some change:
-------------------------------0------------------------------------------
first of all create directory(don't forget about right of user) and table:
-- Create directory
create or replace directory UTL_DBMS_LOB
  as 'c:\oracle\product\10.1.0\admin\orcl\utl_dbms_lob' ;

-- Create table
create table DOCUMENT
(
  ID NUMBER not null,
  CREATIONDATE DATE not null,
  PUBLISHDATE DATE not null,
  AUTHOR VARCHAR2(50) not null,
  DOC BLOB not null
);
-- Create/Recreate primary, unique and foreign key constraints
alter table DOCUMENT
  add constraint PK_DOCUMENT primary key (ID);
--------------------------------1---------------------------------------------
CREATE OR REPLACE PROCEDURE loadBLOB_proc (dst_loc IN OUT BLOB, blobfilename IN VARCHAR2) IS
  src_loc BFILE := bfilename('UTL_DBMS_LOB', blobfilename) ;
  src_offset NUMBER := 1;
  dst_offset NUMBER := 1;
  src_osin NUMBER;
  dst_osin NUMBER;
  bytes_rd NUMBER;
  bytes_wt NUMBER;
BEGIN
  DBMS_OUTPUT.PUT_LINE('------------ LOB LOADBLOBFORMFILE EXAMPLE------------');
  /* Opening the source BFILE is mandatory */
  dbms_lob.fileopen(src_loc, dbms_lob.file_readonly);

  /* Opening the LOB is optional */
  dbms_lob.OPEN(dst_loc, dbms_lob.lob_readwrite);
  /* Save the input source/destination offsets */
  src_osin := src_offset;
  dst_osin := dst_offset;
  /* Use LOBMAXSIZE to indicate loading the entire BFILE */
  dbms_lob.LOADBLOBFROMFILE(dst_loc,src_loc,dbms_lob .lobmaxsize,src_offset,dst_offset) ;

  /* Closing the LOB is mandatory if you have opened it */
  dbms_lob.close(dst_loc);
  dbms_lob.filecloseall();

  /* Use the src_offset returned to calculate the actual amount read from the
BFILE */
  bytes_rd := src_offset - src_osin;
  dbms_output.put_line(' Number of bytes read from the BFILE ' || bytes_rd ) ;
  /* Use the dst_offset returned to calculate the actual amount written to the
BLOB */
  bytes_wt := dst_offset - dst_osin;
  dbms_output.put_line(' Number of bytes written to the BLOB ' || bytes_wt ) ;
  /* If there is no exception the number of bytes read should equal to the
number of bytes written */
end ;
------------------------------2----------------------------------------------
now you can call loadBLOB_proc using this code:
declare
id integer;
dst_loc BLOB; --locator
blobfilename varchar2(50);
begin
  id:=1;
  blobfilename := 'file.jpg';
  insert into document(id,creationdate,publishdate,author,doc)
  values (id,sysdate,sysdate,'_AP',empty_BLOB())
  returning doc into dst_loc;
 loadBLOB_proc (dst_loc, blobfilename ) ;
end ;






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to store image in oracle database gargi_12300 Oracle 1 July 4th, 2008 04:28 AM
How to store image in sql server database Debmit_das ASP.NET 2.0 Basics 5 March 21st, 2008 05:31 AM
Store image in database from swings using location kiran_p2p Java Databases 0 January 4th, 2007 04:22 AM
Store Image in ms access ! Help ? hunghung Classic ASP Databases 1 September 21st, 2005 10:36 PM
How to store image in oracle database and retrieve y.suresh JSP Basics 1 February 28th, 2005 07:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.