Académique Documents
Professionnel Documents
Culture Documents
Administration Tips
...with a sequence and trigger to generate a unique number for each photo to be loaded:
CREATE SEQUENCE PHOTONUM; CREATE OR REPLACE TRIGGER IDPHOTO BEFORE INSERT ON ALBUM FOR EACH ROW BEGIN SELECT PHOTONUM.NEXTVAL INTO END;
:NEW.PHOTOID
FROM DUAL;
10 So how best to load all 10000+ photos into the album table? First, get a listing of all the files, and store it in a text file which we'll call photos.lst. Easy enough: just type DIR /B /S D:\PHOTOALBUM\*.* > PHOTOS.LST in a DOS window. Second, create a SQL Loader control file, which we'll call loadalbum.ctl, containing the following lines: LOAD DATA INFILE PHOTOS.LST INTO TABLE ALBUM (EXT_FNAME FILLER CHAR(200), PHOTO LOBFILE(EXT_FNAME) TERMINATED BY EOF) Finally, run SQL Loader by typing the following command:
SQLLDR USERID=USERNAME/PASSWOIRD@TNSNAMES_ALIAS CONTROL=LOADALBUM.CTL
10/18/2001
Page 1 of 2
Administration Tips
You should find the thing now proceeds apace, and at the end of it, you should check the SQL Loader log file for any errors that might have been encountered. That will be located in a file called (in this case) loadalbum.log, located in the directory from which you launched SQL Loader in the first place. The principle lesson to be learned here is that SQL Loader is a fine tool for mass-loading blobs into Oracle -a fact which I'd forgotten, and of which Anurag kindly reminded me.
10/18/2001
Page 2 of 2