Re: Blob

From: Vladimir M. Zakharychev <bob_at_dpsp-yes.com>
Date: Mon, 15 Apr 2002 22:45:09 +0400
Message-ID: <a9f70n$c66$1_at_babylon.agtel.net>


...and if you want to upload it from your web browser, you need to read the OWA Toolkit documentation - section on File Upload and Download has complete example, including DAD (Database Access Descriptor) configuration. It's a bit long to quote here.

--
Vladimir Zakharychev (bob_at_dpsp-yes.com)                http://www.dpsp-yes.com
Dynamic PSP(tm) - the first true RAD toolkit for Oracle-based internet applications.
All opinions are mine and do not necessarily go in line with those of my employer.


"Daniel Morgan" <damorgan_at_exesolutions.com> wrote in message
news:3CBAEFF5.ABD0ACDF_at_exesolutions.com...

> Yes. You can do it easily with PL/SQL using the DBMS_LOB package.
>
> Here is some sample code that does it ... the only precursor is creating the
> directory within Oracle and granting read on it. For example:
>
> CREATE OR REPLACE DIRECTORY ctemp AS 'c:\temp\';
>
> Then grant permissions to the schema:
>
> GRANT READ ON DIRECTORY ctemp TO schema_name;
>
> Here's a simple procedure that reads a file in the c:\temp directory and loads
> it into a BLOB field.
>
> CREATE OR REPLACE PROCEDURE load_cad (drawname VARCHAR2) IS
>
> src_file BFILE;
> dst_file BLOB;
> lgh_file BINARY_INTEGER;
>
> BEGIN
> src_file := bfilename('CTEMP', drawname);
>
> -- insert a record with a NULL BLOB to lock
> INSERT INTO cadtest
> (cadfile, caddraw)
> VALUES
> (drawname, EMPTY_BLOB())
> RETURNING caddraw INTO dst_file;
>
> -- lock record
> SELECT caddraw
> INTO dst_file
> FROM cadtest
> WHERE cadfile = drawname
> FOR UPDATE;
>
> -- open the file
> dbms_lob.fileopen(src_file, dbms_lob.file_readonly);
>
> -- determine length
> lgh_file := dbms_lob.getlength(src_file);
>
> -- read the file
> dbms_lob.loadfromfile(dst_file, src_file, lgh_file);
>
> -- update the blob field
> UPDATE cadtest
> SET caddraw = dst_file
> WHERE cadfile = drawname;
>
> -- close file
> dbms_lob.fileclose(src_file);
>
> END load_cad;
> /
>
> I hope this helps.
>
> Daniel Morgan
>
>
>
> Carmine wrote:
>
> > hi friends!!
> >
> > I would, please, like to know how can i upload a binary file in my
> > database!...
> > for example if I have a file named "image.gif"in this URL" c:\images"and i
> > want to insert it in my DB.
> > i thank you for your help.
>
Received on Mon Apr 15 2002 - 20:45:09 CEST

Original text of this message