I am trying to use an Oracle 9.2 database to distribute some DLL file types among multiple workstations. The problem that I'm having is that after uploading the DLL into the database, it exports as a larger file than I uploaded. The exported file is also no longer recognized as a DLL file. What am I missing?


This is my import code:
DECLARE
v_bfile BFILE;
v_blob BLOB;
BEGIN
INSERT INTO fpi_versions
VALUES ('&version', empty_blob())
RETURN fpi_dll INTO v_blob;

v_bfile := BFILENAME('FPI_DIR', 'fpi32p.dll');
Dbms_Lob.Fileopen(v_bfile, Dbms_Lob.File_Readonly);
Dbms_Lob.Loadfromfile(v_blob, v_bfile, Dbms_Lob.Getlength(v_bfile));
Dbms_Lob.Fileclose(v_bfile);

COMMIT;
END;


This is my export code:
DECLARE
v_file UTL_FILE.FILE_TYPE;
v_buffer RAW(32767);
v_amount BINARY_INTEGER := 32767;
v_pos INTEGER := 1;
v_blob BLOB;
v_blob_len INTEGER;
BEGIN
-- Get LOB locator
SELECT fpi_dll
INTO v_blob
FROM fpi_versions
WHERE version = '&version';

v_blob_len := DBMS_LOB.GETLENGTH(v_blob);

-- Open the destination file.
v_file := UTL_FILE.FOPEN('DBDIR','fpi32p.dll','w', 32767);

-- Read chunks of the BLOB and write them to the file
-- until complete.
WHILE v_pos < v_blob_len LOOP
DBMS_LOB.READ (v_blob, v_amount, v_pos, v_buffer);
UTL_FILE.PUT_RAW(v_file, v_buffer, TRUE);
v_pos := v_pos + v_amount;
END LOOP;

-- Close the file.
UTL_FILE.FCLOSE(v_file);

EXCEPTION
WHEN OTHERS THEN
-- Close the file if something goes wrong.
IF UTL_FILE.IS_OPEN(v_file) THEN
UTL_FILE.FCLOSE(v_file);
END IF;
RAISE;
END;