Blob Question.
hi all,
I want to display picture in forms,but first i want to create BLOB column in table then to save the picture in this columbn in the database ,can anybody help me in this how can i fill the columnwith picture ,
please somebody help me ???
Thanks in advance
Ahmed,
Its easy creating a table with column of type BLOB .
eg.
CREATE TABLE TEMP_BLOBS(
LOB_ID NUMBER(38, 0) NOT NULL,
DATA_STRING BLOB,
CONSTRAINT PK_TEMP_BLOBS PRIMARY KEY (LOB_ID)
Now you have to explain your question more in details that how do you want to load data into table? eg. using java program, using sql*plus front end or using pl/sql block etc.
Similar Messages
-
My problem is :
I've got a simple form with the fileupload utility running in web mode. Now, I have to insert the uploaded file into a table. So, I created a table with a BLOB field, and I based my block on this table and added
the field, who is appearing as an image Item.
But : I've got no idea of what to do after that. I saw many thread talking about blob, but I don't understand
what exactely am I supposed to do.
So : It would be great if someone could send me by mail a simple form, with a blob element in the block, and
with a procedure that insert a file in the blob (with the directory and the filename in parameter), and an
other procedure that read the blob, so that the file can appear in the form after the query.
Other question : is a word or excel document can appear in the blob field, as if it was a picture ?
Thanks a lot !
My mail : [email protected]
My cfg : form6i 6.0.20.1Thanks Kuassi,
Thats exactly what is happening. When I delete, it deletes the file that the Blob points to.
I was hoping that Oracle would be smart enough to know that if you delete a record that has a blob pointer which points to Blob data that is referenced by other records, it wouldn't delete the Blob data, but just the pointer.
Ill have a read of your blog too! -
To BFILE or to BLOB that is the question ?
G'day all,
I'm looking for some advice on PROs and CONS on using BFILE or BLOB. Currently I'm using BLOB to store images which is fine I guess on Oracle Std and Enterprise but when I deploy the application to customers on a laptop I'm going to use OracleXE.
All performance looks good for Oracle XE on laptop, but a question was raised that I should have considered myself (But sliped my mind) was about how Oracle XE has 4GB Tablespace limit and how that impacts us when our database gets fully populated with Images.
Bugger, that 4Gig will get chewed up fairly quickly :( So I'm now wondering if I should use BFILE, that should mean the Image disk usage on the Oracle Tablespace will nolonger apply as the image data is external to the database ? right ? ...
I was wondering if any one could confirm my thoughts, and if possible give me some PROs / CONs or Catch 22's if I do go down the BFILE path ? Obviously I'm aware of directory permissions and backup policy now mean the images need to be backed up externally. But anything else critical to BFILEs would be most appreciated.
Regards
MarkG'day All,
Just an update, I've sucessfully modified the APEX 3.0 DEMO application to use BFILE instead of BLOB for DEMO_IMAGES. I've now got a good set of PROCEDURES and FUCTIONS to work with BFILE especially an equivalent CUSTOM_IMAGE_DISPLAY for show BFILE images on web pages etc. A few lessons learnt, but one of the big ones that cause a small flap after all my hard work, was when I ran a test and uploaded 10 images of 6 mb each the APEX SYSAUX table space still increased by 65mb even though I had deleted the BLOB from the work flow table after storing the a as BFILE.
After doing some research I located this webiste (http://halisway.blogspot.com/2007/06/reclaiming-lob-space-in-oracle.html) which explains that even though we delete records with BLOBs the LOB space is not automatically reclaimed so as the SYS user ran the following command and then rechecked the SYSAUX tablespace and all was good.
NB: The bloody table that is used to store the uploaded files is located under FLOWS_FILES so make sure your attached to that schema else alter table complains thats it can not see table / view.
alter session set current_schema=FLOWS_FILES;
alter table wwv_flow_file_objects$ modify lob (blob_content) (shrink space);
So now Oracle XE shouldn't run out tablespace too quickly now, as long as I run the above maintenance commands to reclaim space.
One happy chappy.
Mark -
Hey Guys,
I want to know whats the best way to extract blob from a table. Right now we are using SELECT query and then open a InputStream and read the stream (just like any other input!)
Now I'm thinking of using Stored Procedure for this task i.e i would call a stored procedure from my java code and that stored procedure would extract the blob and then i would proceed. My question is do you guys think i would get some good performence using Stored Procedures or it would be same??
Thanks for your time to read this.
samSam,
IMO a stored proc is always better. As for the performance you'll have to check communication time versus finding the blob in the table and see if it worth it for you--but then you'll already have the stored proc so you might as well use it. A stored proc will almost always give you a boost over using a script, but because your using blobs (I don't know how large yours is), you may miss any benefit because of communication time between your servers and app. -
Dear experts;
Take for instance you saved a simple picture which is a jpeg containing the letter 'A' utilizing a blob in a table. Is there anyway, you can interpret and get the A itself as a text instead. I know some people who suggest using a client tool to do this but, that seems extremely difficult to do hence, can this be done without one..also other good ideas are welcomed...Justin Cave wrote:
user13328581 wrote:
Hey Justin, do you know of any good binary books to recommend....I'm not sure I understand the question. What is a "good binary book"?Here's the first page to one I'm fond of:
010101000001111010011010001001000100100100111111
010101000001111010011010001001000100100100111111
010101000001111010011010001001000100100100111111
010101000001111010011010001001000100100100111111
010101000001111010011010001001000100100100111111
010101000001111010011010001001000100100100111111
010101000001111010011010001001000100100100111111
010101000001111010011010001001000100100100111111
010101000001111010011010001001000100100100111111
010101000001111010011010001001000100100100111111
010101000001111010011010001001000100100100111111
010101000001111010011010001001000100100100111111
010101000001111010011010001001000100100100111111
010101000001111010011010001001000100100100111111
010101000001111010011010001001000100100100111111
010101000001111010011010001001000100100100111111
010101000001111010011010001001000100100100111111
010101000001111010011010001001000100100100111111
Paul...
JustinEdited by: Paulie on 27-Jun-2012 18:02 -
Suggestions on Encrypting the Secret Question in SPE Blob
Hi, I am implementing SPE at a client who has a requirement to encrypt the Secret Question in the blob. Is there a configuration to do this or do I have to create custom code. Any suggestions would be appreciated. I'm looking for a straight forward method.
Thanks,
MarkIt's not supposed to be sent to an alternate email; it will only be sent to a rescue email address, and may take a few hours to arrive or get caught in a spam filter. If the rescue email option doesn't work, you need to contact Apple. Click here, phone them, and ask for the Account Security team, or fill out and submit this form.
(91443) -
Questions regarding jsp file download from blob
Hi developers, i'm doing jsp file download from a blob column in DB2 using struts,
1) How do i design the jsp page such that the page will show perhaps a hyperlink for me to download the file?
2) What about struts-config.xml? Do i need to modify any mappings there?
It would be great if some kind developers were to provide some sample codes for me. Thanks alot. Your effort is kindly appreciated.http://kr.forums.oracle.com/forums/thread.jspa?threadID=1982213 - looks similar, you may need to change contentType as per use case
-
Beginner's Question on Inserting a BLOB with JDBC
What is the easiest way to accept a file from a user and insert it into a BLOB field in a database?
If it makes a difference - I'm using DB2 and DB2's JDBC driver
But I would like to know the simpliest solution (maybe even using the JDBC-ODBC bridge)
-MichaelHi Michael,
with DB2's JDBC driver it is pretty easy:
You use a prepared statement and the method setBinaryStream or setBytes:
PreparedStatement pstmt = con.prepareStatement("UPDATE myTable SET blobColumn = ? WHERE ID = ?");
FileInputStream in = new FileInputStream(...) ;
pstmt.setBinaryStream(1, in, in.available()) ;
pstmt.setInt(2, id) ;
pstmt.execute() ; Or you read the file first into an array of bytes and put it in the database with pstmt.setBytes(...)
Yannick -
Hello all,
We are storing some images in Oracle 9i as BLOB type. The actual size for most of them is about 150K (0.15MB). However, when the upload is complete the size of each file in db is approximately 3.5 MB. Is something is wrong with table definition/storage?
Thank you,
SonyaMark,
here are my answers:
What is the full Oracle version? 9i
What is the table definition?
IMAGE_NO NOT NULL NUMBER(12)
IMAGE_PAGE NOT NULL NUMBER(3)
IMAGE_NAME NOT NULL VARCHAR2(50)
IMAGE_DATA BLOB
What is the tablespace extent management method in use and parameters?
HEADER_FILE 12
HEADER_BLOCK 331939
BYTES 458752
BLOCKS 56
EXTENTS 7
INITIAL_EXTENT 65536
NEXT_EXTENT
MIN_EXTENTS 1
MAX_EXTENTS 2147483645
How are you measuring the size of the LOB after loading? used this function dbms_lob.getlength(image_data)
Edited by: sonya795 on Aug 25, 2008 4:18 PM -
Hi,
I have a requirement to store a word/excel/jpeg in a BLOB field. When i retreive the same from BLOB column, the file should open using respective programs like word doc should open using WINWORD, excel sheet should open using
EXCEL program etc.
If any one is having the code for this please share it.
Thanks & Regards,
Sunil.Hi,
I used the following code from ASKTOM.
create table demo
( id int primary key,
theBlob blob
create or replace directory my_files as 'c:\datafiles\';
declare
l_blob blob;
l_bfile bfile;
begin
insert into demo values ( 1, empty_blob() )
returning theBlob into l_blob;
l_bfile := bfilename( 'MY_FILES', 'file1.doc' );
dbms_lob.fileopen( l_bfile );
dbms_lob.loadfromfile( l_blob, l_bfile,
dbms_lob.getlength( l_bfile ) );
dbms_lob.fileclose( l_bfile );
end;
Now here is the package that can retrieve the pdf (or anything for that matter. Just keep adding procedures that are named after the file type like .doc, .pdf, .xls and so on. Some browsers really want the extension in the URL to be "correct")
create or replace package image_get
as
procedure gif( p_id in demo.id%type );
end;
create or replace package body image_get
as
procedure gif( p_id in demo.id%type )
is
l_lob blob;
l_amt number default 30;
l_off number default 1;
l_raw raw(4096);
begin
select theBlob into l_lob
from demo
where id = p_id;
-- make sure to change this for your type!
owa_util.mime_header( 'image/doc' );
begin
loop
dbms_lob.read( l_lob, l_amt, l_off, l_raw );
-- it is vital to use htp.PRN to avoid
-- spurious line feeds getting added to your
-- document
htp.prn( utl_raw.cast_to_varchar2( l_raw ) );
l_off := l_off+l_amt;
l_amt := 4096;
end loop;
exception
when no_data_found then
NULL;
end;
end;
end;
When i executed it from SQLPLUS it is executed successfully.
SQL> exec image_get.gif (1)
PLSQL procedure successfully completed.
But i want to see the document. How should i execute the above code. Please explain.
Regards,
Sunil. -
Question: releasing value of BLOB field
Hello, I'm using EclipseLink 2.0.
I have an entity with @BLOB field, which is lazy loaded. After I update or persist an instance of the entity, I don't need the BLOB field value, because I need the memory to be free.
Can I make the BLOB field uninitialized without entity's refresh (as if the object is just queried)? Or the only way is to refresh the entity?Refresh is the only public way.
There is an internal way, get the FetchGroup from the object and remove the blob attribute name from it (or set a new FetchGroup if null), then just null out the blob.
The class will be weaved to implement FetchGroupTracker, which provides the API to get and set the FetchGroup (or you can use the descriptor's FetchGroupManager).
James : http://www.eclipselink.org -
I have a question for you: Inserting Word document in BLOB column
Hey Experts,
I have found a good info and a sample on how to achieve this on
http://www.sys-con.com/java/source/5-6/code.cfm?Page=76.
declare
f_lob bfile;
b_lob blob;
begin
insert into sam_emp(empno,ename,resume)
values ( 9001, 'Samir',empty_blob() )
return risumi into b_lob;
f_lob := bfilename( 'MY_FILES', 'MyResume.doc' );
dbms_lob.fileopen(f_lob, dbms_lob.file_readonly);
dbms_lob.loadfromfile
( b_lob, f_lob, dbms_lob.getlength(f_lob) );
dbms_lob.fileclose(f_lob);
commit;
end;
I have a jsp project and the users ( on the client side)must be
able to create a word document and send it to the server with an
uplaod servlet. With another servlet or jsp i want to process
this word document in BLOB column using JAVA. The sample above
uses PL/SQL to achieve this. Is there a way i can do this in my
servlet/jsp to do the same thing?
Any hints are welcome!The option should be visible here: http://support.mozilla.com/en-US/kb/Printing%20a%20web%20page#w_print-window-settings
Print range section - Lets you specify which pages of the current web page are printed:
* Select '''All''' to print everything.
* Select '''Pages''' and enter the range of pages you want to print. For example, selecting "from 1 to 1" prints the first page only.
* Select '''Selection''' to print only the part the page you've highlighted.
Does it work for you? -
Please help : here a few questions about BLOBs
I'm using Forms6i patch11. I've got a web application with a block based on a table like this :
TMP_STORED_FILE(file_name varchar2(256),
file blob)
The application allow the user to select a picture on the hard disk, and to store it in the database.
I use the read_image_file to show the picture in an Image item (based on the file column of the table).
When the user perform a commit, I'm not sure that the file is correctly stored in the table... what do
you think ?
Now, I want to show in the image item the picture stored in the table when a record is queried. I saw many java sample code supposed to do that, but do I really have to use java ??
I saw that if I want to show the picture, I have first to re-create the file, and then to use read_image_file again. So : why should I store the pictures ? I mean : I wanted to store the pictures so that I can control
the access to them. I wanted to delete the files after they have been stored. But if I have to recreate them,
what about keep the files on the server and never store anything but the pathname and the filename ???
At least, I could control the security at the directory level, what do you think ?Yes, thanks. I tried to commit the pictures yesterday, and I thought it was ok, but in fact nothing was
inserted in my blob. I thought it was ok, because I found in the metalink the following :
fix: To read the image stored in BLOB column of some database table into an image item in forms block,
the item should have property 'Database Item'= No Image items can only be populated in two ways:
1. with read_image_file built-in In this case file needs to be read from a local filesystem (or from the middle- tier for webforms)
Or
2. directly from database table by fetching In this case the image item must be based on database column of BLOB or LONG RAW
datatype, and cannot be a control item. There is no interface how to manipulate value of an image item programmatically.
Possible solutions are:
1. get file from BLOB column in database into local file system as some temporary file, then use read_image_file.
<Note:66312.1> describes the steps for BFILEs, it needs to be modified for BLOB columns.
Or
2a) create temporary table with BLOB column, copy image from BLOB storage table into it using stored procedure with DBMS_LOB package.
<Note:61737.1> describes using DBMS_LOB package in detail. In forms create a separate block based on this temporary table,
only with image item visible, and display just copied image
Or
2b) have separate block based on BLOB storage table, only the image item visible, and always restrict where clause to select only the one
particular image. The second way is probably easier to implement.
Case 2a could be slower than the first one or 2b.
Maybe I didn't understand it correctly (my english is not so good after all).
Anyway, I finally succeed in inserting my pics.
Thanks again !! -
CreateXML from BLOB (encoding question)
Hi All,
I'd like to create an XMLType variable from a BLOB (in PL/SQL, Oracle 10g). However, the input XML might be in any encoding and my DB is in UTF8.
What is the proper way of converting input BLOB into XMLType and taking into account the encoding of the source (BLOB) and the target (DB) ?
Thanks for any help.
JuliusHi All,
I'd like to create an XMLType variable from a BLOB (in PL/SQL, Oracle 10g). However, the input XML might be in any encoding and my DB is in UTF8.
What is the proper way of converting input BLOB into XMLType and taking into account the encoding of the source (BLOB) and the target (DB) ?
Thanks for any help.
Julius -
Hello, I have a table in my database that stored shipping data. The label column stores a simple shipping label. For some reason each label takes 32k in space when it should only take at most 1k. I am looking into the application that stores them to see if this is the cause. Would there be anything from an Oracle perspective that may cause this?
Here is the table definition:
CREATE TABLE "ESELL"."SHIPPING"
( "ORDER_ID" VARCHAR2(30 BYTE) NOT NULL ENABLE,
"SHIPMENT_STATUS" VARCHAR2(20 BYTE) NOT NULL ENABLE,
"SHIPPING_STORE" VARCHAR2(20 BYTE) NOT NULL ENABLE,
"SHIPMENT_ID" VARCHAR2(20 BYTE),
"TRACKING_NUM" VARCHAR2(20 BYTE),
"LABEL" BLOB,
"REQUEST_ID" NUMBER(*,0),
CONSTRAINT "PK_SHIPPING" PRIMARY KEY ("ORDER_ID", "SHIPPING_STORE", "REQUEST_ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
STORAGE(INITIAL 524288 NEXT 262144 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "ES_BLOB" ENABLE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 524288 NEXT 262144 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "ES_BLOB"
LOB ("LABEL") STORE AS (
TABLESPACE "JKNUDSENDATA" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10
NOCACHE
STORAGE(INITIAL 524288 NEXT 524288 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)) ;Thank you,
DavidI created a similar environment with your feedbacks and used Tom Kyte's show_space package to see the difference but please can you also give example insert data and how you measure the amounts you mentioned;
-- http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5350053031470
set serveroutput ON SIZE UNLIMITED FORMAT WORD_WRAPPED
DECLARE
l_some_blob BLOB;
l_empty_blob BLOB;
BEGIN
-- initial table space status
dbms_output.put_line('');
dbms_output.put_line('=====');
dbms_output.put_line('initial table space status');
show_space('SHIPPING');
INSERT INTO shipping VALUES ('1', '1', '1', '1', '1', l_empty_blob, 1);
COMMIT;
-- after empty blob insert table space status
dbms_output.put_line('');
dbms_output.put_line('=====');
dbms_output.put_line('after empty blob insert table space status');
show_space('SHIPPING');
-- clear the table content before next insert
DELETE FROM shipping;
COMMIT;
-- Initialize to something and display length
l_some_blob := to_blob(utl_raw.cast_to_raw('1234567890123456789012345678901234567890'));
INSERT INTO shipping VALUES ('1', '1', '1', '1', '1', l_some_blob, 1);
COMMIT;
-- after some length blob insert table space status
dbms_output.put_line('');
dbms_output.put_line('=====');
dbms_output.put_line('after '|| dbms_lob.getlength(l_some_blob)||' length blob insert table space status');
show_space('SHIPPING');
END;
/
Maybe you are looking for
-
Web Photo Gallery - transparent
Would someone be so kind in helping me set the 'Photoshop Flash web glallery 3' to transparent? I have added the following line to the html code but with no luck on IE6 or any other browsers. " myFlashObject.addParam("wmode", "transparent"); " Do I n
-
Firefox wont load pages, other browsers do, firefox solutions did not work?
Hello! I have Windows 7, and run Firefox Beta 36.0. I have it set to update automatically, and it seems there was an update yesterday, and now Firefox will not load any pages. I have tried changing the proxy settings, configuring the firewall, and re
-
Is there a way to protect cells in Numbers so that they don't accidentally get overwritten?
-
ICal - I have all the events from the past decade listed for this week
My iCal calendar has every event from the last ten years listed in every day - each event is tagged 'repeat Every day' and 'end Never'. I have a non-corrupted version on my iPhone. I have tried restoring from Time machine and this works but then reve
-
Default VPN profile (multiple profiles)
Hi, We have 2 VPN profiles on AnyConnect 3.1 It seems that AnyConnect keep last used profile as default profile (after reboot for example) Is it possible to set a default VPN profile and keep it even if user connects to the other? (because the defau