Home » SQL & PL/SQL » SQL & PL/SQL » Upload .PDF to a BLOB field
Upload .PDF to a BLOB field [message #231360] Mon, 16 April 2007 13:27 Go to next message
Ronald Beck
Messages: 121
Registered: February 2003
Senior Member
Hello all,
I've been browsing through many pages that explain how to load a FILE to a blob, but not how to make a web page that does so. I have a pl/sql procedure that creates a form...

   procedure show_blob_form is
   begin
  
     --htp.p('<form>');
     htp.p('<FORM METHOD="POST" ACTION="itcreator.test_loadblob.load_blob_info" ENCTYPE="multipart/form-data">');
     htp.p('Sequence: <input type="text" name="f_seq"><br>');
     htp.p('File: <input type="file" name="f_filepath"><br>');
     htp.p('<input type="submit">');
     htp.p('</form>');
  
   end show_blob_form;
   --------------------------------------
   --------------------------------------


Pretty simple. It lets you enter a sequence number and a file pathname from your PC. Now, what I want to do is send the buffered info to a BLOB field in my table.

I have a similar routine that runs as a cgi script, originally written in perl, that will write the buffered info into a file on the local server, but I don't know how to tell a pl/sql procedure to load the info to the table. Any hints, suggestions or references?

Thanks,
Ron
Re: Upload .PDF to a BLOB field [message #231361 is a reply to message #231360] Mon, 16 April 2007 13:34 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
How hard did you search?
http://www.orafaq.com/forum/t/80112/74940/
Re: Upload .PDF to a BLOB field [message #231373 is a reply to message #231361] Mon, 16 April 2007 17:18 Go to previous messageGo to next message
Ronald Beck
Messages: 121
Registered: February 2003
Senior Member
Well, oddly enough, I did read the information you cited. And, if you'll note, 1) I'm not using .NET, C#, or VB, 2) I'm not attempting to use ODP.NET.

I am attempting to use pl/sql in an Oracle Portal environment and I have a pl/sql stored procedure that presents the form that will allow the user to specify a file. It needs to call another pl/sql stored procedure to load the data from the file the user specified.

And, yes, of the 50 or so hits I reviewed today, the closest I found was at

http://www.idevelopment.info/data/Oracle/DBA_tips/LOBs/LOBS_10.shtml

which is pretty close. However, I don't see where the data is actually loaded into the table. I can see where the NAME of the uploaded file is loaded into the table, just not the data.

So, once again, if anyone has an example of how to take binary data submitted through a web form and place it into a blob field, I would appreciate it.

Ron
Re: Upload .PDF to a BLOB field [message #231374 is a reply to message #231360] Mon, 16 April 2007 17:27 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
From: http://www.orafaq.com/forum/t/59966/74940/

USEFUL SITES (bookmark them!)

The Online Documentation: your primary source for Oracle information
Oracle Technology Network: Oracle's technical website. Very useful for code samples, software downloads, forums...
The 2 sites above require a free (no spam!) otn account. Subscribe now, it's well worth it.

MetaLink: Oracle's official support website. Only accessible for users with a valid support identifier. But the place to be for patches, bugs, ORA-600 info,...
AskTom: a tremendous amount of SQL and PL/SQL related questions gathered on an easy website and answered by the master himself.

from AskTom
Mass Loading BLOBs into a database 66 24 Jun 2004 03:13PM 6.8 years ago
Retrieving Data from BLOB into a file. 57 31 Jan 2007 01:38PM 4.4 years ago
CLOB and BLOB datatypes ! 57 12 Oct 2006 08:12AM 6.4 years ago
Inserting a CLOB data 57 7 Aug 2006 09:37PM 6.1 years ago
Re: Upload .PDF to a BLOB field [message #231436 is a reply to message #231373] Tue, 17 April 2007 01:45 Go to previous message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
Ronald Beck wrote on Tue, 17 April 2007 00:18
I don't see where the data is actually loaded into the table. I can see where the NAME of the uploaded file is loaded into the table, just not the data.
Ron, the page you cited has everything you need. Let's have a look at the "load_blob_from_file_image" procedure:

EXAMPLE_LOB_DIR is an Oracle Directory, pointing at the OS directory '/u01/app/oracle/lobs' on the database server. This is where the file should reside.

Step 1:
        INSERT INTO test_blob (id, file_name, image, timestamp)
        VALUES (1001, 'oracle9i_logo.gif', empty_blob(), sysdate)
        RETURNING image INTO dest_loc;

Here we insert a record in the destination table. Note that it is an empty blob we're inserting. The returning clause returns a LOB pointer. This means that we can still access the BLOB the pointer is referring to. The DBMS_LOB procedures are explained in the documentation.

Anacedent has given you some great pointers. Here's a direct link from Tom Kyte.

MHE
Previous Topic: mutating trigger (merged)
Next Topic: hi, why it is giving error when inserting row on a table which had triggers on it
Goto Forum:
  


Current Time: Sat Dec 10 20:08:30 CST 2016

Total time taken to generate the page: 0.07486 seconds