1

i'm trying to insert 1000 images located on my "E" partition on my hard drive the images named as (img1.jpg, img2.jpg,.....)
colud this be done using insert statement in a loop with counter changing the img(counter).jpg


     begin
        for i in 1 .. 1000 loop

 "insert Statement"

        end loop;
        commit;
    end; 

1 Answers1

0

As suggested by @thatjeffsmith A much easier option would be to use sqlldr. And you can create a .ctl file as below

options (bindsize 10000)
load data
BADFILE 'E:\IMAGES\sqlldrbad1.bad'  
DISCARDFILE 'E:\IMAGES\sqlldrdiscard1.DIS' 
append
into table IMAGES
(
  image,
  table_name constant "IMAGES",
)

And then to load the data

for %F in (E:\IMAGES\*.jpg) do sqlldr username/password@db control=contr.ctl data=%F

You can also check the post here

Else you can use UTL_FILE like the example cited here

Paul
  • 448
  • 1
  • 6
  • 14
  • I can't fully understand you in my case, I have images located in "E:\clone" named (img1.jpg , img2.jpg , .... ) ,i want to insert it to a blob column named "photo" in a table named "jpg" . – abdallah refay Oct 26 '19 at 01:23
  • can you offer more explanation or sources, please – abdallah refay Oct 26 '19 at 01:28
  • I suggested that instead of writing an insert statement like the one you have been trying to, if you can load the data/images into the table using sqlldr as was even suggested by others. I just posted a sqlldr .ctl file snippet. And how to use the .ctl file to load all your image files from your local drive to the database. – Paul Oct 26 '19 at 01:38
  • Also if you can check the links I provided in my answer it would give you a better picture how to use the sqlldr or UTL_FILE – Paul Oct 26 '19 at 01:40
  • thanks a lot for your effort I'll try it and give you a feedback – abdallah refay Oct 26 '19 at 22:50