Sometimes we must save photo, any type of multimedia system file or perhaps text data file in Oracle database by client. In web software client must upload the file in web hardware or any other machine. But web storage space can get that directory where the documents are uploaded. To complete the operation we can use Oracle Blob data type, Oracle index and having a procedure.
Suppose we certainly have a table name ImageTable. The desk should be like this. CREATE STAND ImageTable
FILENAME VARCHAR2(3000 BYTE),
LIMITATION ImageTable_ID_PK MAJOR KEY (ID)
Right here filename is exclusive. Also we now have a sequence for the table name " imagetable_seqвЂќ. Imagine the data files are published in " C: \picsвЂќ directory in web machine. If the world wide web server and database machine in the same machine then there is no difficulty for the database storage space to access that files to work. At first we ought to create a directory site where the record are uploaded or kept like we trapped in " C: \picsвЂќ in server equipment. So our script should be like this: make or change directory Image_FILES as вЂC: /pics';
Remember that here Oracle use forwards slash. We create a index in program server or database storage space. In our case both are same machine. Therefore there is no difficulty to access file for the Oracle Database server. After that we have to create a oracle procedure term " saveImageвЂќ which software should be similar to this:
create or perhaps replace process saveImage(p_filename varchar2, seq_Id away number) because
erase from ImageTable where filename = p_filename;
put in into ImageTable (ID, fileName, data) beliefs (imagebytes_seq. NEXTVAL, p_filename, empty_blob()) returning info into l_clob; l_bfile: = bfilename( вЂImage_FILES', p_filename );
dbms_lob. fileopen( l_bfile, DBMS_LOB. LOB_READONLY );
dbms_lob. loadfromfile( l_clob, l_bfile, dbms_lob. getlength( l_bfile ) ); select imagebytes_seq. CurrVal into seq_Id from dual;
update imagebytes set info =l_clob exactly where fileName sama dengan...