Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Forms 6i - loading a binary file into a BLOB

961 views
Skip to first unread message

Macvl2000

unread,
Dec 28, 2001, 2:57:50 PM12/28/01
to
I am developing a Forms 6i client/server application in a Win2k environment.
Upon request by the user, the application must read a binary file
(say, a Word document or an Excel spreadsheet) stored in the filesystem of
the client PC and save it into a BLOB column of a database table.

I tried to use ORA_FFI for loading the file but I found no way to return
a buffer containing ASCII 0's into a PLSQL varchar2 variable, so this method
does not seem useful.

The question is: what is the best way to load a file into a BLOB using Forms
(d2kutil, user exit, ....)?

Eric Wright

unread,
Jan 9, 2002, 4:26:04 PM1/9/02
to
I've only been working with Blobs for a little while, but from what I've
seen, the dbms_lob package works well. However, this will only work on code
from the database server.

I'd suggest creating a package on the server, then calling a member function
of that package in your on-insert form trigger.

Here is a sample of how to handle the load...

create table blob_test (id number not null primary key,
blob_file blob);

create or replace directory my_files as 'C:\My Documents';

create or replace procedure blob_ins(p_id in number, p_filename in varchar2) as
l_bfile bfile;
l_blob blob;
begin
insert into blob_test(p_id, empty_blob())
returning blob_file into l_blob;

l_bfile := bfilename('MY_FILES', p_filename);
dbms_lob.fileopen(l_bfile);
dbms_lob.loadfromfile(l_blob, l_bfile, dbms_lob.getlength(l_bfile));
dbms_lob.fileclose(l_bfile);
commit;
return;
end blob_ins;
/

The directory you created (my_files) is a database pointer to a folder or
directory on the DB server that contains the file in question. When it
gets used in the bfilename call, it's been automatically upper-cased, like
other objects (tables, views, etc).

The returning clause essentially creates a referential link between the
local variable l_blob and the current record of the table blob_test.
Modifying the value in l_blob automatically updates the current record,
so no additional updates are necessary.

Good luck.
Eric

macv...@yahoo.it (Macvl2000) wrote in message news:<dfb206b6.01122...@posting.google.com>...

0 new messages