- inserting of existing files into the database e.g. the file logo2.gif
in the directory /oracle/oracle8owner/data
DECLARE
filevar BFILE;
blobvar BLOB;
result INTEGER;
amount INTEGER;
filename CHAR(20);
dir_alias CHAR(100);
BEGIN
--first create a Oracle directory
create directory FILEDIRGEOGA as '/oracle/oracle8owner/data';
filevar := BFILENAME('FILEDIRGEO','logo2.gif');
- does the file exist ?
result := DBMS_LOB.FILEEXISTS(filevar);
IF (result != 1)
THEN
DBMS_OUTPUT.PUT_LINE('***Error occured while opening data file !***');
ELSE
DBMS_OUTPUT.PUT_LINE('*** Data file opened successfull !***');
END IF;
- open the file and initialize the locators
insert into blobtable(name,b) values('EMPTYLOB',EMPTY_BLOB());
DBMS_LOB.FILEOPEN(filevar);
DBMS_LOB.FILEGETNAME(filevar,dir_alias,filename);
amount := DBMS_LOB.GETLENGTH(filevar);
BEGIN
SELECT blobtable.b into blobvar FROM blobtable WHERE
blobtable.name='EMPTYLOB';
DBMS_LOB.LOADFROMFILE(blobvar,filevar,amount);
END;
- insert into the blobtable
UPDATE blobtable SET name=filename,b=blobvar;
DBMS_LOB.FILECLOSE(filevar);
COMMIT;
END;
/
--
Carsten Busch
Geographisches Institut FSU Jena
email: ncb_at_geogr.uni-jena.de
!!!!!New Phone and Fax Number !!!!!!
Tel:03641-9-48866 Fax:03641-9-48852
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Received on Mon Mar 09 1998 - 00:00:00 CST