Jason Bennett's Developer Corner

 






Click to see the XML version of this web page.

>


View David Jason Bennett's profile on LinkedIn

 

 

A Little About Jason Bennett ...

I've had an interest in publishing technical articles and HELPFUL code for a few years.  I am (by trade and hobby) a developer who specializes in Oracle technologies and web based architectures.  I have been an employee of both TUSC and Oracle Corporation.  My intent here is to share my ideas and coding experiences with the developer community as a whole.  As with all developers some of my ideas are great and some of them are ....  well you know.  Anyway, I hope you find something here that will aid in your endeavor, or spark a new idea. 

I am more than happy to assist with technical issues and will even write a little code if need be. If you find something on the site that is really useful and you'd like to make a contribution (absolutely up to you and absolutely not required), just click the "Make a Donation" button on the left!

Good luck and good coding !




  Saturday, July 08, 2006


Pulling Down BLOBs and CLOBs with a PL/SQL Function

(Revised)

The functions below will allow the user to reach out to any website or web server and grab any binary or text file.  The cool thing is that it is executed straight from the database.  The functions can be used to populated BLOB  or CLOB columns in a table (great for grabbing images and storing them ... mugshots .. personel photos etc.).  Here are the function:

CREATE OR REPLACE FUNCTION getWebBLOB(p_url VARCHAR2 := NULL) RETURN BLOB
IS

   v_data       UTL_HTTP.html_pieces;
   v_chunk      VARCHAR2(32000) := NULL;
   v_blob BLOB;

BEGIN

   v_data := utl_http.request_pieces(p_url);

   DBMS_LOB.createTemporary(v_blob,FALSE,DBMS_LOB.CALL);

   FOR piece_cnt IN 1 .. v_data.count LOOP

      v_chunk := v_data(piece_cnt);

      DBMS_LOB.writeappend(v_blob,length(v_chunk),utl_raw.cast_to_raw(v_chunk));

   END LOOP;

   RETURN v_blob;

END;
/

CREATE OR REPLACE FUNCTION getWebCLOB(p_url VARCHAR2 := NULL) RETURN CLOB
IS

   v_data       UTL_HTTP.html_pieces;
   v_chunk      VARCHAR2(32000) := NULL;
   v_clob       CLOB;

BEGIN

   v_data := utl_http.request_pieces(p_url);

   DBMS_LOB.createTemporary(v_clob,FALSE,DBMS_LOB.CALL);

   FOR piece_cnt IN 1 .. v_data.count LOOP

      v_chunk := v_data(piece_cnt);

      DBMS_LOB.writeappend(v_clob,length(v_chunk),v_chunk);

   END LOOP;

   RETURN v_clob;

END;
/

If you have any questions, shoot me an email.


7:15:45 PM    

Click here to visit the Radio UserLand website. © Copyright 2008Jason Bennett.
Last update: 8/28/2008; 9:47:35 PM.

July 2006
Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Jan   Oct