Using dbms_lob to load image into table

I am trying to load a set of images from my DB drive into a table. This works fine when I try to load only 1 record. If I try to load more than 1 record, first gets created but I get this error, and it doesn't load the images for the rest of them.
ORA-22297:     warning: Open LOBs exist at transaction commit time
Cause:     An attempt was made to commit a transaction with open LOBs at transaction commit time.
Action:     This is just a warning. The transaction was commited successfully, but any domain or functional indexes on the open LOBs were not updated. You may want to rebuild those indexes.
Am I missing something in the code that's needed?
in_file UTL_FILE.FILE_TYPE;
bf bfile;
b blob;
src_offset integer := 1;
dest_offset integer := 1;
CURSOR get_pics is select id from emp;
BEGIN
FOR x in get_pics LOOP
BEGIN
insert into stu_pic(id,student_picture)
values(x.id,empty_blob()) returning student_picture into b;
l_picture_uploaded := 'Y';
bf := bfilename('INTERFACES',x.student_id || '.' || p_image_type);
dbms_lob.fileopen(bf,dbms_lob.file_readonly);
dbms_lob.open(b,dbms_lob.lob_readwrite);
dbms_lob.loadBlobFromFile(b,bf,dbms_lob.lobmaxsize,dest_offset,src_offset);
dbms_lob.close(b);
dbms_lob.fileclose(bf);
EXCEPTION when dup_val_on_index then null;
END;
END LOOP;
END;

There are two methods you can use.
1. Create an external table with those images(BLOB column) and then use that external table to insert into another table.
Demo as follows:
This is my pdf files
C:\Saubhik\Assembly\Books\Algorithm>dir *.pdf
Volume in drive C has no label.
Volume Serial Number is 6806-ABBD
Directory of C:\Saubhik\Assembly\Books\Algorithm
08/16/2009  02:11 PM         1,208,247 algorithms.pdf
08/17/2009  01:05 PM        13,119,033 fci4all.com.Introduction_to_the
d_Analysis_of_Algorithms.pdf
09/04/2009  06:58 PM        30,375,002 sedgewick-algorithms.pdf
               3 File(s)     44,702,282 bytes
               0 Dir(s)   7,474,593,792 bytes free
C:\Saubhik\Assembly\Books\Algorithm>This is my file with which I'll load the pdf files as BLOB
C:\Saubhik\Assembly\Books\Algorithm>type mypdfs.txt
Algorithms.pdf,algorithms.pdf
Sedgewick-Algorithms.pdf,sedgewick-algorithms.pdf
C:\Saubhik\Assembly\Books\Algorithm>Now the actual code
SQL> /* This is my directory object */
SQL> CREATE or REPLACE DIRECTORY saubhik AS 'C:\Saubhik\Assembly\Books\Algorithm';
Directory created.
SQL> /* Now my external table */
SQL> /* This table contains two columns. 1.pdfname contains the name of the file
DOC>   and 2.pdfFile is a BLOB column contains the actual pdf*/ 
SQL> CREATE TABLE mypdf_external (pdfname VARCHAR2(50),pdfFile BLOB)
  2         ORGANIZATION EXTERNAL (
  3           TYPE ORACLE_LOADER
  4            DEFAULT DIRECTORY saubhik
  5            ACCESS PARAMETERS (
  6              RECORDS DELIMITED BY NEWLINE
  7              BADFILE saubhik:'lob_tab_%a_%p.bad'
  8              LOGFILE saubhik:'lob_tab_%a_%p.log'
  9              FIELDS TERMINATED BY ','
10              MISSING FIELD VALUES ARE NULL
11               (pdfname char(100),blob_file_name CHAR(100))
12              COLUMN TRANSFORMS (pdfFile FROM lobfile(blob_file_name) FROM (saubhik) BLOB)
13            )
14            LOCATION('mypdfs.txt')
15         )
16         REJECT LIMIT UNLIMITED;
Table created.
SQL> SELECT pdfname,DBMS_LOB.getlength(pdfFile) pdfFileLength
  2  FROM   mypdf_external;
PDFNAME                                            PDFFILELENGTH
Algorithms.pdf                                           1208247
Sedgewick-Algorithms.pdf                                30375002
SQL> Now, you can use this table for any operation very easily. Even for your loading into another table!.
2. Use of DBMS_LOB like this
/* Loading a image Winter.jpg in the BLOB column as BLOB!*/
DECLARE
  v_src_blob_locator BFILE := BFILENAME('SAUBHIK', 'Winter.jpg');
  v_amount_to_load   INTEGER := 4000;
  dest_lob_loc BLOB;
BEGIN
  --Insert a empty row with id 1
  INSERT INTO test_my_blob_clob VALUES(1,EMPTY_BLOB(),EMPTY_CLOB())
   RETURNING BLOB_COL INTO dest_lob_loc;
  DBMS_LOB.open(v_src_blob_locator, DBMS_LOB.lob_readonly);
  v_amount_to_load := DBMS_LOB.getlength(v_src_blob_locator);
  DBMS_LOB.loadfromfile(dest_lob_loc, v_src_blob_locator, v_amount_to_load);
  DBMS_LOB.close(v_src_blob_locator);
  COMMIT;
--id=1 is created with Winter.jpg populated in BLOB_COL and CLOB_COL is empty.  
END;Now user this code to create a procedure with parameter and use that in loop.

Similar Messages

  • Loading Images into LONG RAW column using SQL or PL/SQL

    Hi!
    I am trying to load images into a LONG RAW column. Can anybody tell me how to do this using SQL or PL/SQL. I do not want to use Forms to do this. And, I have a limitation using BLOBs.
    Thanks in Advance,
    Kotesh.

    You wrote that you cannot use a java class to insert a picture. We are working on a school project and HAVE to use java as a client and Oracle 7 as a server.
    Can you tell us how this is to be done?
    Thank you in advance,
    Bart van der Heijden

  • Inserting image into table

    hi,
    i m create table, then create procedure, procedure is successfully compile, but when i m trying to insert image into table it error out.
    for inserting image i go with
    EXECUTE insert_image_file(1,'C:\sunset.jpg');
    sunset.jpg is image which i want to insert in table, and which is present on 'c drive'.
    when execute the following error are shown
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "SYS.DBMS_LOB", line 635
    ORA-06512: at "SCOTT.INSERT_IMAGE_FILE", line 26
    ORA-06512: at line 1
    how to solve it.
    regards
    prashant

    Prashant wrote:
    CREATE OR REPLACE PROCEDURE insert_image_file (p_id NUMBER, p_image_name IN VARCHAR2)
    ...snipped...Not very nice code... why create an empty image row, then lock it (it is already locked by the uncommitted insert statement), and then update it again? Not very efficient or sensible.
    image is on local machine.When a row is created on the server from user input on some PC, who supplied that input? Who read the user's keyboard input on that PC to obtain the values for the columns for the row to create?
    Did PL/SQL read the keyboard of that remote PC? Of course not. The client program on that PC read the keyboard input. It then made a client call to the Oracle server. It supplied the data entered via the keyboard by the user to the Oracle server (using a PL/SQL call or using a SQL statement call to Oracle).
    Now why would a local image data on that PC be treated any differently than the keyboard data on that PC? How can you expect PL/SQL code running on the Oracle server, to read that image data from the remote PC when the same PL/SQL code is incapable of reading keyboard input from that very same PC?
    You need to review your understanding of client-server and how it pertains to using Oracle within client-server architecture.

  • Load image into Photo Album

    I'm new to Oracle.
    Can I load image into database by using Photo Album by no writing any code?
    And how?
    If not,how to load image into database?

    Yes you can. You can load media into the database into the photo album tables.
    Is this what you want to do? What exactly are you trying to accomplish.
    You can also use PL/SQL to put images into the database into your own schema (as with other database information)
    http://www.oracle.com/technology/sample_code/products/intermedia/htdocs/bulkload.html
    Larry

  • Inserting blob image into table

    ora.gif, image001.jpeg are the image names .these are stored in the location D:\oracle\Bfiles
    create directory BFILE_FILES as ‘D:\oracle\Bfiles';
    i want to insert the 2 images into table using blob
    how to create the table and how to insert and how to test that image is inserted or not

    Tom Kyte has it all Here

  • How to load image into picturebox

    Hi! Does anyone know how to load image into picturebox by using J2ME? And how to crete the picturebox in the forst place?
    Thanks!
    Regards,
    Jaceline

    You want java.awt.Toolkit.getImage() and java.awt.Graphics.drawImage().
    Ted.

  • Load image into holderMC

    Hi,
    I'm working on an application which places instances from my
    library onto the stage. Every instance has a movieclip inside it
    which is called holderMC. What I want to do is to load external
    images into holderMC except I can't seem to get it working. How
    does one load images into a pre-defined movieclip?

    Oh, sorry, wasn't looking properly. You cannot load images
    into MovieClips like in AS2, you have to use a Loader or the
    UILoader component.
    If you want to be able to position the loader visually, then
    you can give an instance of the UILoader component and instance
    name within the THEPhoto MC, and use the following code:
    MovieClip(photo).holder.load(photoRequest); //where holder is
    the instance name of the loader.
    OR
    Within the ThePhoto class you could create a new Loader:
    public var imgLoader:Loader = new Loader();
    public function ThePhoto () {
    imgLoader.x = 0;
    imgLoader.y = 0;
    addChild(imgLoader);
    and then use:
    MovieClip(photo).imgLoader.load(photoRequest);

  • Loading images into memory

    I have an applet that I need to load images into memory. For instance, lets say I am in the first section of the applet. While that section is being showed, I want to load the background image of the second section into memory.
    To load the initial image into momory, I am just using a Mediatracker. No problem there. But I don't want to load all 20 backgrounds into memory at the same time as they take a lot of time. My understanding is that if I create a new MediaTracker while the first chapter is running, it will potentially cause some chaos, as that will stop my thread from running while I have an image loading.
    Somebody told me perhaps I could create a new thread and have that thread load the backgroudn into momory? Perhaps something like this?
    public class TestClass extends JApplet {
         private TestClass thisClass;
         public void init() {
              thisClass = this;
              Runnable r = new Runnable() {
                   public void run() {
                        MediaTracker tracker = new MediaTracker(thisClass);
                        Image nextImage = getImage( getDocumentBase(), getImagePath() +"img1.jpg");
                        tracker.addImage(nextImage,0);
                        try {
                             tracker.waitForID(0);
                        } catch (InterruptedException ie) {
                             System.out.println(ie.toString());
              Thread t = new Thread(r);
              t.setDaemon(false);
              t.start();
              while(t.isAlive()) {
                   int i = 1;     
              t.stop();
              t.destroy();
    }No idea if I am on the right track or not? Another friend told me something about swing helpers but couldn't tell me much more?
    Thanks in advance!

    I use media tracker when I need information about how percent the image is loaded. you can use JLabel to load the images since it has own image observer in it.
    hope you just want to deal with it. easiest way I can offer :)

  • How to dynamically load images into Flash

    I have a movie clip on the stage that I want to dynamically
    load images into (that constantly change), how would I go about
    doing this? Thanks.

    Use the Loader class to load in images.
    Then use addChild to add the Loader class into your MovieClip
    on the stage.
    As far as "constantly change" what
    do you mean by that? You could use setInterval, ther enterFrame
    event, or any other means to trigger a new image to be loaded into
    the Loader instance.
    Finally, you can use the Tween class to create some nice
    effects for the images (fade it, blur in, photo blend, masks,
    etc)

  • Problem loading image into texture memory

    Hi there, I am currently porting our new casual PC game over to the iPad using the pfi, the game was written in Flash so the porting process isn't that hard thankfully, it's mainly just optimizing the graphics.
    So far things are going smoothly, I was initially worried about graphical performance, but since we put everything into the GPU that's no longer a concern- it runs super smooth at 60fps at 1024x768, we can have a hundred large bitmaps rotating and alphaing at once with no slowdown.
    However there is one weird problem which is really worrying me at this point- it seems that the speed at which images are loaded into video memory as textures is vastly different depending on what else is being run on the iPad, for example:
    * If I run my game with nothing else in memory, it will run fine at 60fps, and load up large images into texture memory very fast.
    * If I run another App, in this case a Virtual piano app for a while, then close that App via the Home button (so the piano app is still in memory but suspended due to the multitasking), then when I run my game, it will run ok initially, but when I try to load a large (1024x512) image into texture memory it pauses the whole game for several seconds.
    * To make matters worse, if I repeat the same test using the RAGE app from ID software (which is very graphically intense), my game actually slows down to 1 fps and runs extremely slowly as soon as I run it and the frame rate never returns to normal. If I then double-click the home button, shut down RAGE, then go back to my game, it will run fine.
    I have read that sometimes when you load images into texture memory it will have to reclaim that memory from other apps, but that doesnt exaplain why it slows down every time I want to load something, or why the game would slow right down to a crawl.
    So then it seems that having other Apps in memory is slowing down my game, or stopping it from working altogether. Obviously this is not ideal and would stop us from releasing, so is there any way I can stop this, has anyone come across the problem? Please help!
    PS. this problem also happens on an iPhone 4, as I have performed the same tests.

    Hi _mz84
    First thing I noticed, is that you did not close your
    <embed> tag
    <embed src="gallery1.swf" bgcolor="#421628" width="385"
    height="611" wmode="transparent" />
    If that doesn't solve your troubles, try the following
    container.
    <object type="application/x-shockwave-flash" height="611"
    width="385" align="middle" data="gallery1.swf">
    <param name="allowScriptAccess" value="never" />
    <param name="allowNetworking" value="internal" />
    <param name="movie" value="gallery1.swf" />
    <param name="quality" value="high" />
    <param name="scale" value="noscale" />
    <param name="wmode" value="transparent" />
    <param name="bgcolor" value="#421628" />
    </object>
    hope this helps out.

  • Making a loaded swf-file loading images into the movie..

    Trying to convert my problem from norwegian into english
    isn't always that easy... :)
    Anyway..
    I've created som cool buttons that I want to be loaded into a
    movie (let's call i MainMovie.swf) and from there I want the
    buttons to be able to load images into a movieclip (ImageContainer)
    inside the MainMovie.swf.
    Is it possible to make the MainMovie.swf communicate with the
    the loaded buttons (each button is a swf-file containing the
    actionscript, objects, etc.) so when the buttons are clicked they
    load different images into the ImageContainer?
    My idea here is to include an as.file into the MainMovie.swf
    as well containing the url's to the images that I want to be loaded
    into ImageContainer.
    I've tried to create a button on a layer above the buttons
    that's loaded into the MainMovie.swf but I end up with the loaded
    buttons not working properlu because of the button that I've
    created and placed above them.
    Now, I don't want the url's inside the buttons thats loaded
    into the MainMovie.swf as I want the ability to be able to replace
    those buttons-files without having to use too much time writing the
    url's in each button.
    Thanks folks.

    are all your swfs using as3 or as2? if as3, you won't be
    loading into a movieclip: you'll use a loader instance and you can
    reference (or communictae with) the loaded as3 objects using the
    content property of your loader once you cast it as a
    movieclip.

  • FDMEE Import error "No periods were identified for loading data into table 'AIF_EBS_GL_BALANCES_STG'

    Hi,
    We are having trouble while importing one ledger 'GERMANY EUR GGAAP'. It works for Dec 2014 but while trying to import data for 2015 it gives an error.
    Import error shows " RuntimeError: No periods were identified for loading data into table 'AIF_EBS_GL_BALANCES_STG'."
    I tried all Knowledge docs from Oracle support but no luck. Please help us resolving this issue as its occurring in our Production system.
    I also checked all period settings under Data Management> Setup> Integration Setup > Global Mapping and Source Mapping and they all look correct.
    Also its only happening to one ledger rest all ledgers are working fine without any issues.
    Thanks

    Hi,
    there are some Support documents related to this issue.
    I would suggest you have a look to them.
    Regards

  • How can I load data into table with SQL*LOADER

    how can I load data into table with SQL*LOADER
    when column data length more than 255 bytes?
    when column exceed 255 ,data can not be insert into table by SQL*LOADER
    CREATE TABLE A (
    A VARCHAR2 ( 10 ) ,
    B VARCHAR2 ( 10 ) ,
    C VARCHAR2 ( 10 ) ,
    E VARCHAR2 ( 2000 ) );
    control file:
    load data
    append into table A
    fields terminated by X'09'
    (A , B , C , E )
    SQL*LOADER command:
    sqlldr test/test control=A_ctl.txt data=A.xls log=b.log
    datafile:
    column E is more than 255bytes
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)

    Check this out.
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch06.htm#1006961

  • Photoshop CC 2014 - Stack Mode Disabled - Load Image Into Stack Has No "Convert To Smart Object" Option

    Hi,
    I have just installed Photoshop CC 2014.1 and I have "Stack Mode" command disabled.
    Also, I have no option to convert layers into smart object  when I run "Load Image Into Stack" command.
    Can you please tell me how to enable these features?
    Thank you very much.
    Luca

    The 512 MB are a minimum requirement, not some optional thing. Without it, 3D will never work.
    Mylenium

  • No dataload.err: Using ODI to load data into Essbase

    Hi,
    I am using ODI to load data into Essbase. In the load data KM options, I select the rule file and mention that errors be logged.
    After executing the data load through ODI, I get a log file and an error file. But the error file does not have the bad record like the "dataload.err" has when I load data through EAS and use the same data and rules file.
    Am I missing some option? Is there some option to log the bad data to the error file or some option to generate a dataload.err file while using ODI?
    Thanks.

    Hi John,
    I have set LOG_ERRORS to Yes and given a file name. A file is generated everytime the interface is executed, but the file is blank.
    I have also set the Log_enabled to Yes. The log file is generated and has the error in it. The error line in the Log file ( not the error file) looks like this -
    2009-04-16 10:45:38,457 INFO [DwgCmdExecutionThread]: ODI Hyperion Essbase Adapter Version 9.3.1.1
    2009-04-16 10:45:38,457 INFO [DwgCmdExecutionThread]: Connecting to Essbase application [XXXXXX] on [XXXXXX]:[1423] using username [admin].
    2009-04-16 10:45:39,315 INFO [DwgCmdExecutionThread]: Successfully connected to the Essbase application.
    2009-04-16 10:45:39,315 INFO [DwgCmdExecutionThread]: Essbase Load IKM option RULES_FILE = d_PL
    2009-04-16 10:45:39,315 INFO [DwgCmdExecutionThread]: Essbase Load IKM option RULE_SEPARATOR = ,
    2009-04-16 10:45:39,315 INFO [DwgCmdExecutionThread]: Essbase Load IKM option PRE_LOAD_MAXL_SCRIPT =
    2009-04-16 10:45:39,315 INFO [DwgCmdExecutionThread]: Essbase Load IKM option POST_LOAD_MAXL_SCRIPT =
    2009-04-16 10:45:39,315 INFO [DwgCmdExecutionThread]: Essbase Load IKM option ABORT_ON_PRE_MAXL_ERROR = true
    2009-04-16 10:45:39,315 INFO [DwgCmdExecutionThread]: Essbase Load IKM option CLEAR_DATABASE = None
    2009-04-16 10:45:39,315 INFO [DwgCmdExecutionThread]: Essbase Load IKM option COMMIT_INTERVAL = 1000
    2009-04-16 10:45:39,315 INFO [DwgCmdExecutionThread]: Essbase Load IKM option CALCULATION_SCRIPT = null
    2009-04-16 10:45:39,315 INFO [DwgCmdExecutionThread]: Essbase Load IKM option RUN_CALC_SCRIPT_ONLY = false
    2009-04-16 10:45:39,346 DEBUG [DwgCmdExecutionThread]: LoadData Begins
    2009-04-16 10:45:39,549 DEBUG [DwgCmdExecutionThread]: Error occured in sending record chunk...Cannot end dataload. Analytic Server Error(1003014): Unknown Member [DPT_DFDFDF] in Data Load, [2] Records Completed
    2009-04-16 10:45:39,549 DEBUG [DwgCmdExecutionThread]: Sending data record by record to essbase
    2009-04-16 10:45:40,968 INFO [DwgCmdExecutionThread]: Logging out and disconnecting from the essbase application.
    There is nothing in the error file. There should have been a record for the unknown member, DPT_DFDFDF.
    I am using ODI version 10.1.3.5.
    and John, thanks for the ODI blog. It has helped me a lot in the past couple of months.
    Thank you.

Maybe you are looking for

  • Web Photo Gallery in PS CS4

    They are recomending that you use Bridge for web galleries, but I have always liked the way PS did them. There is a plug in called "Web Photo Gallery" included with the programme that allows you to use the old method, which I have put it in the plug

  • 15" studio display backlight inverter

    Does anyone know where I can get a backlight inverter for my 15" studio display? I can only find parts for the 17". Please help. Thanks, Dean G4 + 15" display (M2454)   Mac OS X (10.3.9)  

  • Using HipServ app to enable 3GS access of Mediashare pro acct

    Not sure on the solution.  Mediashare support acknowledged that this is the correct app to use but nothing else.  I didn't have the iPhone when I setup the acct in Sept.  My subscription doesn't expire until 9/2/2012 so I know that's not an issue pre

  • User-command and pf-status

    Hi can anybody please give tell me what is the user-command and what is pf-status. please provide me a sample code how to create these step by step. and how to copy standard pf-status to user defined one. thanks in advance kp

  • Photo Shop Elements 12 from quick view to expert setting

    I set my PSE 12 to expert and customize to my liking and every time I close PS and reopen I lose my setting. Is there something I can do to make them my default?