首先建立DIRECTORY ,命令如下:
CREATE OR REPLACE DIRECTORY IMAGES As 'F:\';
procedure代碼如下
CREATE OR REPLACE PROCEDURE IMG_INSERT (FILENAME VARCHAR2) AS
F_LOB BFILE;
B_LOB BLOB;
Begin
INSERT INTO T_FILE_URL (FILENR1) VALUES (EMPTY_BLOB ()) RETURN FILENR1 INTO B_LOB;
F_LOB:= BFILENAME ('IMAGES', FILENAME);
DBMS_LOB.FILEOPEN (F_LOB, DBMS_LOB.FILE_READONLY);
DBMS_LOB.LOADFROMFILE (B_LOB, F_LOB,DBMS_LOB.GETLENGTH (F_LOB));
DBMS_LOB.FILECLOSE (F_LOB);
COMMIT;
END;