How to insert a JPG file from file system to Oracle 10g?

I have developed a schema to store photos as BLOB which store the text description as CLOB original filename, file size.
I also use ctxsys.context to index TEXT_DESCRIPTION in order to perform Oracle Text Search and it works.
I would like to insert some JPG file from say C:\MYPHOTO\Photo1.jpg as a new record. How can I do this in SQL PLus and/or Loader?
How can I retrieve the PHOTO_IMAGE back to the file system using SQL Plus and/or command line in DOS?
See the following script:
create user myphoto identified by myphoto;
grant connect, resource, ctxapp to myphoto;
connect myphoto/myphoto@orcl;
PROMPT Creating Table PHOTOS
CREATE TABLE PHOTOS
(PHOTO_ID VARCHAR2(15) NOT NULL,
PHOTO_IMAGE BLOB,
TEXT_DESCRIPTION CLOB,
FILENAME VARCHAR2(50),
FILE_SIZE NUMBER NOT NULL,
CONSTRAINT PK_PHOTOS PRIMARY KEY (PHOTO_ID)
create index idx_photos_text_desc on
PHOTOS(TEXT_DESCRIPTION) indextype is ctxsys.context;
INSERT INTO PHOTOS VALUES
('P00000000000001', empty_blob(), empty_clob(),
'SCGP1.JPG',100);
INSERT INTO PHOTOS VALUES
('P00000000000002', empty_blob(), 'Cold Play with me at the concert in Melbourne 2005',
'COLDPLAY1.JPG',200);
INSERT INTO PHOTOS VALUES
('P00000000000003', empty_blob(), 'My parents in Melbourne 2001',
'COLDPLAY1.JPG',200);
EXEC CTX_DDL.SYNC_INDEX('idx_photos_text_desc');
SELECT PHOTO_ID ,TEXT_DESCRIPTION
FROM PHOTOS;
SELECT score(1),PHOTO_ID ,TEXT_DESCRIPTION
FROM PHOTOS
WHERE CONTAINS(TEXT_DESCRIPTION,'parents',1)> 0
ORDER BY score(1) DESC;
SELECT score(1),PHOTO_ID ,TEXT_DESCRIPTION
FROM PHOTOS
WHERE CONTAINS(TEXT_DESCRIPTION,'cold play',1)> 0
ORDER BY score(1) DESC;
SELECT score(1),score(2), PHOTO_ID ,TEXT_DESCRIPTION
FROM photos
WHERE CONTAINS(TEXT_DESCRIPTION,'Melbourne',1)> 0
AND CONTAINS(TEXT_DESCRIPTION,'2005',2)> 0
ORDER BY score(1) DESC;

Hi
You can use the following to insert an image:
create table imagetab(id number primary key,imagfile blob, fcol varchar2(10));
create or replace directory imagefiles as 'c:\'
declare
    v_bfile BFILE;
    v_blob  BLOB;
  begin
    insert into imagetab (id,imagfile,fcol)
    values (3,empty_blob(),'BINARY')
    return imagfile into v_blob;
    v_bfile := BFILENAME ('IMAGEFILES', 'MyImage.JPG');
    Dbms_Lob.fileopen (v_bfile, Dbms_Lob.File_Readonly);
    Dbms_Lob.Loadfromfile (v_blob, v_bfile, Dbms_Lob.Getlength(v_bfile));
    Dbms_Lob.Fileclose(v_bfile);
    commit;
  end;
/

Similar Messages

  • How to insert contract line item from file using any bapi

    Hi gurus,
    Just wanted to ask how can I insert new line item which were created from a file
    when updating/changing contract details.
    The requirement was to create new line item from a file and use those details in updating the contracts.
    What BAPI can I use to address this requirement?
    Thanks!

    Hi Rajvansh Ravi,
    This is for Service Contracts. Sorry for missing this detail.
    Hi Tarangini Katta,
    I have already used BAPI_CONTRACT_CHANGE, and it was good in updating existing line items,
    but it doesn't update the contract when a new line item is created in the file.
    To make a clearer view of the flow (requirement)
    First scenario:
          From the tcode (ME32K or ME33K), we can download contract details into an excel file for a particular service contract.
    Next scenario:
          That same excel file (downloaded) can be enhanced per line item (can also insert new line) and be saved locally.
    Next scenario:
          This same excel file can also be uploaded. And the changes done to the file have to overwrite or rather have to changed the details of the same contract and then will appear/reflect in the tcode.
    With this, if we had a new line item created (inserted) on the file (not change), we can not see the changes when we view the same contract in the tcode. (ME33K)
    Do you have any idea how the insertion from the file can be reflected on the tcode using an existing bapi?
    Hope this was clear enough...
    Thanks and hope to hear something from you soon.

  • How to enable/disable archive mode from the pfile in oracle 10g?

    hi
    I am using oracle 10g.
    Is there any mechanism to / parameter to enable or disable archive log mode?
    can I enable arching directly from pfile without touching the startup process??
    pls help.
    thnx in advance..

    Please is not in pfile that you enable/disable archive log mode.
    For ENABLE Archivelog mode:
    shutdown immediate
    startup mount
    alter database archivelog;
    alter database open;
    For DISABLE Archivelog mode:
    shutdown immediate
    startup mount
    alter database noarchivelog;
    alter database open;

  • How to insert and retrive data from Discussion forum in Oracle Server 10g

    Hi,
    I have successfully deployed discussion forum, in Oracle app server 10g, and its working fine. Now, i have to implement a Moderator in this. but i am not getting an idea, where is the queries and specifications about the tables are given.
    Please help me to to understand the work flow, as well to know, the place where queries are written.
    Thanks in advance,
    Dhananjay

    Hi,
    I have successfully deployed discussion forum, in Oracle app server 10g, and its working fine. Now, i have to implement a Moderator in this. but i am not getting an idea, where is the queries and specifications about the tables are given.
    Please help me to to understand the work flow, as well to know, the place where queries are written.
    Thanks in advance,
    Dhananjay

  • SQL Loader-How to insert -ve & date values from flat text file into coloumn

    Question: How to insert -ve & date values from flat text file into coloumns in a table.
    Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
    How to load such values in columns of database using SQL Loader?
    Please guide.

    Question: How to insert -ve & date values from flat text file into coloumns in a table.
    Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
    How to load such values in columns of database using SQL Loader?
    Please guide. Try something like
    someDate    DATE 'DDMMYYYY'
    someNumber1      "TO_NUMBER ('s99999999.00')"
    someNumber2      "TO_NUMBER ('99999999.00s')"Good luck,
    Eric Kamradt

  • How to insert Page Break in SPOOL file

    How to insert Page Break in SPOOL file.

    How to insert Page Break in SPOOL file.
    SET NEWP[AGE] {1|n|NONE}
    SET NEWPAGE is not supported in iSQL*Plus
    Sets the number of blank lines to be printed from the top of each page to the top
    title. A value of zero places a formfeed at the beginning of each page (including
    the first page) and clears the screen on most terminals. If you set NEWPAGE to
    NONE, SQL*Plus does not print a blank line or formfeed between the report pages.
    http://www.lc.leidenuniv.nl/awcourse/oracle/server.920/a90842/ch13.htm
    SQL> SET PAGESIZE 5
    SQL> SET NEWPAGE 0 --a form feed between your pages
    SQL> SPOOL C:\output.doc
    SQL> SELECT * FROM emp;
         EMPNO ENAME      JOB             MGR HIREDATE         SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-80        800          0         20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
         EMPNO ENAME      JOB             MGR HIREDATE         SAL       COMM     DEPTNO
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850          0         30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450          0         10
         EMPNO ENAME      JOB             MGR HIREDATE         SAL       COMM     DEPTNO
          7788 SCOTT      ANALYST         7566 09-DEC-82       3000          0         20
          7839 KING       PRESIDENT            17-NOV-81       5000          0         10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
         EMPNO ENAME      JOB             MGR HIREDATE         SAL       COMM     DEPTNO
          7876 ADAMS      CLERK           7788 12-JAN-83       1100          0         20
          7900 JAMES      CLERK           7698 03-DEC-81        950          0         30
          7902 FORD       ANALYST         7566 03-DEC-81       3000          0         20
         EMPNO ENAME      JOB             MGR HIREDATE         SAL       COMM     DEPTNO
          7934 MILLER     CLERK           7782 23-JAN-82       1300          0         10
    13 rows selected.
    SQL> SPOOL OFFKhurram

  • How to loop through xml records from file without ROW , /ROW tags?

    I am using dbms_XMLSave.insertXML procedure to insert xml formated record from file. MY xmlformated records does not have open and close ROW tags. I have multiple records in the file.How can I loop through without <ROW>,</ROW> tags?

    I am using dbms_XMLSave.insertXML procedure to insert xml formated record from file. MY xmlformated records does not have open and close ROW tags. I have multiple records in the file.How can I loop through without <ROW>,</ROW> tags?

  • How to backup only users' relevant files from File History on Windows 8.1?

    Hi,
    I would like to find out how to backup certain user's files from File History on Windows 8.1?
    I'm planning to store the backup files on our server, over a shared network, so that client can retrieve them whenever they need.
    I manage to do one by excluding all the folders from c:\, but it occurs quite silly to me to go select one by one files to exclude them.
    Please advise if there is a better way?

    Hi,
    This IT Professional forum is for general questions, feedback, or anything else related to Office 2010, since your question is more related to Windows client, I'd recommend you post a new question in the following forum for further assistance:
    https://social.technet.microsoft.com/Forums/windows/en-US/home?category=w7itpro%2Cw8itpro%2Cwindowsvistaitpro%2Cwindowsxpitpro%2Cwindowsintune
    The reason why we recommend posting appropriately is you will get the most
    qualified pool
    of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
    Steve Fan
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • How to extract  DB  FILE  FROM NONSAP  SYSTEM  IN BI-7

    how to extract  DB  FILE  FROM NONSAP  SYSTEM  IN BI-7

    hi,
    chk the links for extraction using DB
    Extraction using DB connect
    http://help.sap.com/saphelp_nw70/helpdata/EN/58/54f9c1562d104c9465dabd816f3f24/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c6/0ffb40af87ee6fe10000000a1550b0/frameset.htm
    Extract data from oracle DB to SAP BI 7.0
    Ramesh

  • How to use utl_ftp package to transfer files from one system to another

    Hi all,
    How to use utl_ftp package to transfer files from one system to another using plsql procedure .
    I failed to find the appropriate document ,kindly help me .
    Thanks,
    P Prakash

    prakash wrote:
    I am sorry tell you, this blog is not enough to for me.It's not a blog, it's Chris' website where you download the package from. Once you download the package and unrar it, then the package spec gives instructions (and I think there's instructions on how to install it too).
    Kindly let me know if there is any oracle documentation for this .It's not an Oracle created package, it was created by Chris. It's based around the UTL_TCP package if you really want to get into the nitty gritty of how it works, but I don't think you do.

  • How to move files from  one  system  to another in plsql

    Hi all,
    I want to move file from one system to another using plsql procedure .
    Kindly let me know what package i have to use for doing this .
    Thanks,
    P Prakash
    Edited by: prakash on Jul 27, 2011 2:20 AM
    Edited by: prakash on Jul 27, 2011 2:59 AM

    BluShadow wrote:
    That's ok if you want to diet. ;)Ooh look, the strange punctuation is back. Can it be true that the forum software has caught up with the '80s?
    I almost feel like connecting to the internet using a 9600 baud modem to celebrate.
    http://upload.wikimedia.org/wikipedia/commons/5/5d/TeleGuide-terminal.jpg
    Colon dash right bracket.
    (Old habits die hard)

  • How to delete file from other system(LAN)

    Hello folks,
    Cud u plz help me out in finding code for deleting a file from other system i.e in LAN,assuming that the connection is already established to that system.

    > Cud u plz
    sigh
    Please make the extra effort to write out words such as "could", "you", and "please". The extra keystrokes won't cost much in the way of time, and the enhanced clarity will be appreciated by those communicating on a forum with international readership. Also, it will give the appearance that you take your question seriously, which will in turn make your question look more interesting to answer.
    Thanks!
    ~

  • Store \ Retrieve files from file system

    Hi to all!
    I would like to implement a solution for storing files uploaded via apex user interface to servers file system. As well I would like this files to be retrievable by apex users. I designed the following solution:
    For upload:
    1. Through file browse item user chooses file to be uploaded
    2. File goes to custom table (as BLOB)
    -- so far i would use apex Upload\Download files tutorial
    3. File(BLOB) would then have to be written to file system to some directory and file id would have to be written to some db table which holds pointers to files on file system
    4. delete file(blob) from custom table (from step 2)
    For download:
    1. user chooses link from some report region(based on table giving file pointers to files residing on file system)
    2. file identified with chosen file pointer is then inserted into blob column of some custom table in db
    3. from custom table with download procedure fie is finally presented to user
    4. delete file(blob) from custom table (from step 2)
    Using apex tutorial for Upload\Download files it is straitforward to get the files from db table or into db table using blobs. But i have not seen any example of using BFILE or migrating files from db to file system and vice versa.
    So some Q arise:
    a) How can I implement step 3 under For upload section above
    b) How can I implement step 2 under For download section above
    c) Is there any way to directly upload file to file system via apex user interface or to directly download file from file system via some report region link column?
    Please help!!!
    Regards Marinero
    Message was edited by:
    marinero

    marinero,
    Here is a procedure that will copy an uploaded file to the file system:
      Procedure BLOB_TO_FILE(p_file_name In Varchar2) Is
        l_out_file    UTL_FILE.file_type;
        l_buffer      Raw(32767);
        l_amount      Binary_Integer := 32767;
        l_pos         Integer := 1;
        l_blob_len    Integer;
        p_data        Blob;
        file_name  Varchar2(256);
      Begin
        For rec In (Select ID
                              From HTMLDB_APPLICATION_FILES
                             Where Name = p_file_name)
        Loop
            Select BLOB_CONTENT, filename Into p_data, file_name From HTMLDB_APPLICATION_FILES Where ID = rec.ID;
            l_blob_len := DBMS_LOB.getlength(p_data);
            l_out_file := UTL_FILE.fopen('UPDOWNFILES_DIR', file_name, 'wb', 32767);
            While l_pos < l_blob_len
            Loop
              DBMS_LOB.Read(p_data, l_amount, l_pos, l_buffer);
              If l_buffer Is Not Null Then
                UTL_FILE.put_raw(l_out_file, l_buffer, True);
              End If;
              l_pos := l_pos + l_amount;
            End Loop;
            UTL_FILE.fclose(l_out_file);
        End Loop;         
      Exception
        When Others Then
          If UTL_FILE.is_open(l_out_file) Then
            UTL_FILE.fclose(l_out_file);
          End If;
      end; And here is a procedure that will download a file directly from the file system:
      Procedure download_my_file(p_file In Number) As
        v_length    Number;
        v_file_name Varchar2(2000);
        Lob_loc     Bfile;
      Begin
        Select file_name
          Into v_file_name
          From UpDownFiles F
         Where File_id = p_file;
        Lob_loc  := bfilename('UPDOWNFILES_DIR', v_file_name);
        v_length := dbms_lob.getlength(Lob_loc);
        owa_util.mime_header('application/octet', False);
        htp.p('Content-length: ' || v_length);
        htp.p('Content-Disposition: attachment; filename="' || SUBSTR(v_file_name, INSTR(v_file_name, '/') + 1) || '"');
        owa_util.http_header_close;
        wpg_docload.download_file(Lob_loc);
      End download_my_file;I could put a sample application on apex.oracle.com, but it wouldn't be able to access the file system on that server.

  • Delete a .csv file from desktop system

    Hi All,
    My requirement is to read the .csv file from the desktop system having the shared folder and delete the file after read successfully.
    Here I can read the .csv file from the location using the function RFC_REMOTE_FILE and updated the content into internal table.
    But I cant delete the file from the presentation server ( Desktop system).
    Can anyone tell me how to delete the .csv file from the desktop system on different location.
    Note:
    I followed this link to read file:
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/9831750a-0801-0010-1d9e-f8c64efb2bd2&overridelayout=true

    Hi Rob,
    Thanks. I solved this problem myself.
    The solution to delete the file from remote system is
    concatenate 'DEL' i_filename i_dirname into v_bkfile separated by space .
    call function 'RFC_REMOTE_EXEC'
      destination  c_dest
      exporting
        command               = v_bkfile
      exceptions
        system_failure        = 1  MESSAGE v_ermsg
        communication_failure = 2  MESSAGE v_ermsg.

  • To extract duplicate files from a system

    sir, i m working on project to find duplicate files from a system . can any one give me some idea how should I start ?

    I have written one in Java and in Python.
    My approach was to take the SHA1 hash of each file and use this as the key in a map with the file name being the value.
    I traverse the file system building the hash mapping as I go along. When I find a SHA1 hash that is already in the map I add the pair of associated file names to a list of possible duplicate files.
    After I have traversed the set of files I check all the potential duplicates for equality.

  • Import file from file .jar

    hello... can anybody give me slolution on how to import the file from file.jar. and how to create the new project in java..

    I for one have no idea what you're asking.
    You can use classes in jars just the same as if they weren't in jar. The only difference is how you set up the classpath.
    Java has no idea of a "project". That's more of an IDE thing.

Maybe you are looking for

  • E-Recruiting : Role Authorization in e-recruiting standalone scenario

    Hello Friends, We have EREC on a standalone system (ERD 100). HR ECC is another system (ECD 300), Enterprise portal in another system (EPD 100). we are on EHP 5, EREC 605, Support Pack 7. We have activated the single sign on mechanism. I have followi

  • Create a Pdf with a job...

    Hi! A very simple question! I have to create 9.000 pdf every month, with data present on db. I don't want to press a button to create every pdf. Especially, I can't keep busy the Client for all the execution. I need to schedule this work, in every wa

  • Upgrade from ECC 5.0 to ECC 6.0

    Hello All, I am preparing a pre-upgrade assessment for upgrade from ECC 5.0(SCP) to ECC 6.0.. I am suggesting the strategy Combined Upgrade and Unicode Conversion. I need a template on how to prepare the pre-upgrade assessment for this upgrade..The t

  • HotSync Loop Even After Hard Reset

    My Treo755p decidedly to randomly go into a HotSync loop (even though I never set-up the HotSync to my laptop).  I did a hard-restart, lost all the data, and restarted and it still does the HotSync Loop....Am I just screwed...Of course, I just landed

  • Can I add a network without joining it?

    Can I add a network without joining it? I want to add my closed home networking setting to my iPhone from work. Do I need to be in range of the network to add the network and its settings? Thanks