Home » SQL & PL/SQL » SQL & PL/SQL » how to load default picture in blob field (ORacle 10g,XP)
how to load default picture in blob field [message #405071] Tue, 26 May 2009 04:27 Go to next message
rakeshramm
Messages: 175
Registered: September 2006
Location: Oracle4u.com
Senior Member

How to load default picture in blob field

Thanks in Advance
Re: how to load default picture in blob field [message #405090 is a reply to message #405071] Tue, 26 May 2009 05:51 Go to previous messageGo to next message
Michel Cadot
Messages: 64131
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Using INSERT or DBMS_LOB.

Regards
Michel
Re: how to load default picture in blob field [message #405096 is a reply to message #405090] Tue, 26 May 2009 06:02 Go to previous messageGo to next message
rakeshramm
Messages: 175
Registered: September 2006
Location: Oracle4u.com
Senior Member

CREATE TABLE EVENT
(
  N_EVENTID    NUMBER(10),
  B_IMAGE      BLOB                              ,
  N_EMPID      NUMBER(10),
  D_SYSDAT     DATE                             DEFAULT sysdate,
  C_ACTIVE     CHAR(1 CHAR)                     DEFAULT 'Y'
)


HERE IN B_IMAGE FIELD I WANT TO SPECIFY A DEFAULT IMAGE FILE AS I DONE FOR FIELD D_SYSDAT .HOW TO DO THIS
Re: how to load default picture in blob field [message #405099 is a reply to message #405096] Tue, 26 May 2009 06:06 Go to previous messageGo to next message
Michel Cadot
Messages: 64131
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Don't post in UPPER case.

You can't. You have to do it within a trigger.

Regards
Michel
Re: how to load default picture in blob field [message #405100 is a reply to message #405099] Tue, 26 May 2009 06:08 Go to previous messageGo to next message
rakeshramm
Messages: 175
Registered: September 2006
Location: Oracle4u.com
Senior Member

Sir will u post a sample trigger for this .

Thanks
Re: how to load default picture in blob field [message #405101 is a reply to message #405100] Tue, 26 May 2009 06:14 Go to previous messageGo to next message
ThomasG
Messages: 3189
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
I don't know if that "u" guy is posting something. I have never a user with that name here.

That would be a pretty horrible design anyway. If you have 5000 rows with the same default image, you store the image 5000 times in the database.

And when you want to change the image someday you have to update all those rows.

Better leave the BLOB null, and return a defined default image in the frontend when the BLOB is null.
Re: how to load default picture in blob field [message #405103 is a reply to message #405100] Tue, 26 May 2009 06:28 Go to previous messageGo to next message
Michel Cadot
Messages: 64131
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
I concur with ThomasG, you can store the default image in a table that you can load at display time if the current one is null.

Regards
Michel
Re: how to load default picture in blob field [message #405106 is a reply to message #405103] Tue, 26 May 2009 06:45 Go to previous messageGo to next message
rakeshramm
Messages: 175
Registered: September 2006
Location: Oracle4u.com
Senior Member

Thanks for this valuable information
Re: how to load default picture in blob field [message #405153 is a reply to message #405101] Tue, 26 May 2009 10:57 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
ThomasG wrote on Tue, 26 May 2009 13:14
I don't know if that "u" guy is posting something. I have never a user with that name here.

That would be a pretty horrible design anyway. If you have 5000 rows with the same default image, you store the image 5000 times in the database.

And when you want to change the image someday you have to update all those rows.

Better leave the BLOB null, and return a defined default image in the frontend when the BLOB is null.

I thought of answering the same, but then I asked myself what the (principal) difference is between having a default BLOB or a default VARCHAR2
Nobody thinks it's odd to have some default value for string columns, so why is a BLOB functionally and principally so different?
Oh, and storage is cheap nowadays, so let's for a moment skip that argument..
Re: how to load default picture in blob field [message #405156 is a reply to message #405153] Tue, 26 May 2009 11:27 Go to previous message
ThomasG
Messages: 3189
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
Quote:
Oh, and storage is cheap nowadays


What? Why hasn't anyone told us that before we spent ~$150.000 on a new storage cluster in February? Razz

While the same amount of storage with cheap big ATA or SATA disks might have been under $1000, fast, redundant storage, mirrored in multiple locations in the building isn't really THAT cheap.

It just feels wrong to have a lot of multiple identical BLOBS stored in the DB. Especially a "default" blob, which is probably going to be identical for a lot of rows.

Some things that come to mind:

A default varchar value is updated faster and easier with plain SQL than a BLOB.
A default varchar value his unlikely to be very long, and more likely to be used in indexes.
And, for example, a default varchar value on a comment field that just says "Please enter your comment here" would also make not much sense.

Also, accessing a log of blobs from different rows will probably use up the buffer cache more quickly and use more disk IO than using the same defined default blob over and over, which is probably already inside RAM.

No matter how fast and big the storage gets, the users are still complaining that the system is too slow every now and then, so there is no point in wasting resources just because they are there.
Previous Topic: select the last value from FETCH statement
Next Topic: Max File length with utl_file
Goto Forum:
  


Current Time: Wed Dec 07 14:36:25 CST 2016

Total time taken to generate the page: 0.09447 seconds