Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Raja.

Asked: June 29, 2006 - 12:02 am UTC

Last updated: October 30, 2006 - 9:18 am UTC

Version: 9.2.0.7

Viewed 1000+ times

You Asked

Hi Tom,

First of all I would like to thank you, for your invaluable answers.

Most of our applications are either Client/Server based or n-tier, typical Windows based application, and all of these applications uses Oracle database (in Solaris server). I would like to store photographs and pdf documents in Oracle database. I read many articles about how to store images in database including your answers. I can use BLOB, BFILE or ORDSYS.OrdImage datatypes to store the images.

But if I use BFILE or ORDSYS.OrdImage to store the image, the image have to be copied into the database server (Solaris). This is my understanding. Am I correct? And, if this is the case..., is there any other way where I do not have to store the physical image (file) in the operating system, but store the image in the database?

Thanks in advance,
Raja


and Tom said...

ordsys.ordimage stores data IN the database, not the file system.

If you use a BFILE, that is the type that uses the operating systems file system, you are just pointing to an existing file.


So, just don't use BFILE's, a blob or ordsys.ordimage would be correct and appropriate and the data would be stored in the database, not in the file system.

Rating

  (4 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Raja, June 29, 2006 - 8:48 pm UTC

Tom,

Thanks for your reply.

I am planning to use ORDSYS.ORDDoc and ORDSYS.ORDImage datatypes. As they both are strict datatypes compare to BLOB.

I have another question. I wonder how to get the pdfs and images across from the client to the database server. As a BLOB from the client and convert it into ORDSYS.ORDDoc or ORDImage at the database end...!!!??? I think this question is more for an application developer, and should not be posted here. If so, I am sorry. Please give me an idea on how I do this.

Thanks and regards
Raja


Tom Kyte
June 30, 2006 - 7:13 am UTC

those types are blobs under the covers. You would just use "their" blob.

Populating an Image Table from an HTTP Data Source

Aaron, October 30, 2006 - 7:34 am UTC

Hi Tom -

Just following up on the questions above, because it is related to something I'm not quite understanding yet. I've been looking at the "Populating an Image Table from an HTTP Data Source" documentation from </code> http://download-west.oracle.com/docs/cd/B14117_01/appdev.101/b10840/mm_uses.htm <code>

but getting stuck on the insert portion of the example :

TABLE:
create table imgtable (id number,Image ordsys.ordImage);

1) if I run the insert from the example given in the documentation:
insert into imgtable (id, Image) values (7, ORDSYS.ORDImage.init('http','your.web.site.com/intermedia','image1.gif'));

it's no problem because I have manually assigned the value of "7" to the "id" column. But, I'm confused about how I can find out what the "id" value is/will be if it is getting generated by a sequence or a sys_guid()? If I were to run the following example to import the image file from the HTTP source (as in the example, using "7" for "id" column):

DECLARE
obj ORDSYS.ORDIMAGE;
ctx RAW(64) := NULL;
BEGIN
-- This imports the image file image1.gif from the HTTP source URL
-- (srcType=HTTP), and automatically sets the properties.

select Image into obj from imgtable where id = 7 for update;
obj.import(ctx);

update imgtable set image = obj where id = 7;
commit;


it's again no problem because I know the value is "7", and also using "where id= 7" in the update statement works easily because I know it's "7"; but I'm seriously not getting how I can automate this when using a sequence, like:

insert into imgtable (id, Image) values (sequence.next_val, ORDSYS.ORDImage.init('http','your.web.site.com/intermedia','image1.gif'));

-- say for the example the next_val = 4321

DECLARE
obj ORDSYS.ORDIMAGE;
ctx RAW(64) := NULL;
BEGIN
select Image into obj from imgtable where id = (<how do I get_"4321"_to_be_put_here_?>) for update;
obj.import(ctx);
update imgtable set image = obj where id = (<how do I get_"4321"_to_be_put_here_?>);
commit;


I just can't figure out how to automate the act of telling the update statement to use the value "4321" because the value was assigned by the sequence (instead of me manually).

Probably one of those things that I've been racking my brain over so much I can't think straight about it anymore. More than likely it's my lack of expereince in development.

Thanks in advance for any help or follow up on this.


Tom Kyte
October 30, 2006 - 9:18 am UTC

you have sequence.CURR_VAL available to you.

you have the RETURNING clause from the insert as well - if you do the insert, you can use "returning id into your_variable"



Loading content into ORDDoc from HTTP source

aps_reine@yahoo.comAps, November 22, 2006 - 10:29 am UTC

Hello - 

I also am looking into transferring content into data type ORDSYS.ORDDoc (not ORDImage), but cannot get the import() or srcType() to recognize a URL as the soruce to load from.

I have tried:

declare
obj ordsys.orddoc;
ctx raw(4) := null;
begin
insert into mydocs(1, ordsys.orddoc.init())
returning doc into obj;
obj.srcType('HTTP', 'www.images.com', 'photo.jpg');
obj.import(ctx);
obj.setProperties(ctx);
update mydocs set doc = obj where id=1;
commit;
end;
/

but receive this error:


SQL> show error

LINE/COL ERROR -----------------------------------------------------------------
PLS-00306: wrong number or types of arguments in call to 'IMPORT'

PLS-00306: wrong number or types of arguments in call to 'SETPROPERTIES'

Any idea what I'm doing wrong here?  Thanks in advance for your help.

Regards,

Aps 

found answer for last post

A reader, November 30, 2006 - 1:34 pm UTC

in case anyone is interested, the problem in the last post was this:

obj.import(ctx);
obj.setProperties(ctx);

should be either

obj.import(ctx,TRUE);
obj.setProperties(ctx,TRUE);

_OR_

obj.import(ctx,FALSE);
obj.setProperties(ctx,FALSE);

hope it can be of help to someone

aps

More to Explore

CLOB/BLOB/etc

Complete documentation on Securefiles and Large Objects here