Simple dear
----------you can read images one by one and insert into the database-----------------
:CONTROL.file_path := get_file_name('C:\MY_PIC', NULL,
'JPEG Image (*.JPG,*.JPEG,*.JPE,*.JFIF)|*.JPG|Bitmap Image (*.bmp)|*.bmp|GIF Image (*.GIF)|*.GIF|TIFF Files (*.tif)|*.tif|All Files (*.*)|*.*|', NULL);
DECLARE
image_path VARCHAR2(200);
image_extension VARCHAR2(3);
BEGIN
image_path := :CONTROL.file_path;
image_extension := SUBSTR(:CONTROL.file_path, -3);
READ_IMAGE_FILE(:CONTROL.file_path, image_extension, 'MAIN.IMG');
END;
----------------------------------------------------------------------------
OR if you wanted saved complete directory in same time then follow this
CREATE OR REPLACE DIRECTORY images AS 'C:\MY_PIC';
Next we create a table to hold the BLOB.
CREATE TABLE tab1 (
id NUMBER,
blob_data BLOB
);
We import the file into a BLOB datatype and insert it into the table.
DECLARE
l_bfile BFILE;
l_blob BLOB;
BEGIN
INSERT INTO tab1 (id, clob_data)
VALUES (1, empty_blob())
RETURN clob_data INTO l_blob;
l_bfile := BFILENAME('IMAGES', 'mughals.gif');
DBMS_LOB.fileopen(l_bfile, Dbms_Lob.File_Readonly);
DBMS_LOB.loadfromfile(l_blob, l_bfile, DBMS_LOB.getlength(l_bfile));
DBMS_LOB.fileclose(l_bfile);
COMMIT;
END;
Mughal
[Updated on: Sat, 16 March 2013 07:33]
Report message to a moderator