Discussions
Categories
- 197K All Categories
- 2.5K Data
- 546 Big Data Appliance
- 1.9K Data Science
- 450.8K Databases
- 221.9K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 552 MySQL Community Space
- 479 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.1K ORDS, SODA & JSON in the Database
- 556 SQLcl
- 4K SQL Developer Data Modeler
- 187.2K SQL & PL/SQL
- 21.4K SQL Developer
- 296.4K Development
- 17 Developer Projects
- 139 Programming Languages
- 293.1K Development Tools
- 110 DevOps
- 3.1K QA/Testing
- 646.1K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 161 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.2K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 19 Java Essentials
- 162 Java 8 Questions
- 86K Java Programming
- 81 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 205 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 475 LiveLabs
- 39 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 175 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 233 Portuguese
CSS background-image: BLOB

e://
Member Posts: 45
good day people
I wanted to know how to display a blob field as a background image of a div.
How can an image (jpg) file saved as a blob be output/displayed in a Web page using PL/SQL procedure. The hpt.prn does not work.
In a region type PL / SQL (anonymous block) I have:
<pre>
declare
cursor cr_cursor is
select ID
, BACKGROUND
, FILENAME
, MIMETYPE
, LAST_UPDATE_DATE
from CFG_BACKGROUND;
v_style VARCHAR(4000);
begin
v_style := '<style>';
FOR v_cursor IN cr_cursor LOOP
v_style := v_style||'.slide_'||v_cursor.ID||'{background:url('||v_cursor.FONDO )||') no-repeat 0 0;}';
END LOOP;
v_style := v_style || '</style>';
htp.print(v_style);
end;
</pre>
the result I want is this:
*<style>*
*.slide_1 { background-image:url(image.jpg) no-repeat 0 0;}*
*.slide_2 { background-image:url(photo.jpg) no-repeat 0 0;}*
*.slide_3 { background-image:url(image_one.jpg) no-repeat 0 0;}*
*.slide_4 { background-image:url(image_dog.jpg) no-repeat 0 0;}*
*</style>*
Edited by: e:// on 24/09/2010 13:46
Edited by: e:// on 24/09/2010 13:46
I wanted to know how to display a blob field as a background image of a div.
How can an image (jpg) file saved as a blob be output/displayed in a Web page using PL/SQL procedure. The hpt.prn does not work.
In a region type PL / SQL (anonymous block) I have:
<pre>
declare
cursor cr_cursor is
select ID
, BACKGROUND
, FILENAME
, MIMETYPE
, LAST_UPDATE_DATE
from CFG_BACKGROUND;
v_style VARCHAR(4000);
begin
v_style := '<style>';
FOR v_cursor IN cr_cursor LOOP
v_style := v_style||'.slide_'||v_cursor.ID||'{background:url('||v_cursor.FONDO )||') no-repeat 0 0;}';
END LOOP;
v_style := v_style || '</style>';
htp.print(v_style);
end;
</pre>
the result I want is this:
*<style>*
*.slide_1 { background-image:url(image.jpg) no-repeat 0 0;}*
*.slide_2 { background-image:url(photo.jpg) no-repeat 0 0;}*
*.slide_3 { background-image:url(image_one.jpg) no-repeat 0 0;}*
*.slide_4 { background-image:url(image_dog.jpg) no-repeat 0 0;}*
*</style>*
Edited by: e:// on 24/09/2010 13:46
Edited by: e:// on 24/09/2010 13:46
Best Answer
-
First of all, the CSS syntax isn't quite right. The <tt>background-image</tt> property only specifies the URL of the background image. To specify the <tt>background-position</tt> and <tt>background-repeat</tt> as well, use the <tt>background</tt> shorthand property.
Secondly, there are syntax errors in the PL/SQL region code:v_style := v_style||'.slide_'||v_cursor.ID||'{background:url('||v_cursor.FONDO )||') no-repeat 0 0;}';
There's no <tt>FONDO</tt> member in the cursor record, and it's followed by a misplaced ')'...
Thirdly (and probably most important), the URL needs to point to a resource that will actually download the image to the browser. An On-Demand Process can be used for this:
1. Create application item <tt>ODP_CFG_BACKGROUND_ID</tt> to use as an image ID parameter for the ODP.
2. Create the <tt>ODP_CFG_BACKGROUND</tt> on-demand application process:declare l_background cfg_background.background%type; l_mimetype cfg_background.mimetype%type; l_filename cfg_background.filename%type; begin select bg.background , bg.mimetype , bg.filename into l_background , l_mimetype , l_filename from cfg_background bg where bg.id = :odp_cfg_background_id; owa_util.mime_header(l_mimetype, false); htp.p('Content-Length: ' || dbms_lob.getlength(l_background)); htp.p('Content-Disposition: filename="' || l_filename || '"'); owa_util.http_header_close(); wpg_docload.download_file(l_background); end;
3. Rewrite the PL/SQL region code to generate URLs to the ODP:begin htp.p('<style type="text/css">'); for bg in (select to_char(id, 'tm9') id from cfg_background) loop htp.p( '.slide_' || bg.id || ' { background: url(f?p=&APP_ID.:&APP_PAGE_ID.:&APP_SESSION.:APPLICATION_PROCESS=odp_cfg_background:N::odp_cfg_background_id:' || bg.id || ') 0 0 no-repeat; }'); end loop; htp.p('</style>'); end;
Note also that <tt>style</tt> is only valid within the page <tt>head</tt> element, so unless the page template contains a suitably placed region position a PL/SQL region may not be the best way to deliver the style sheet...
Answers
-
First of all, the CSS syntax isn't quite right. The <tt>background-image</tt> property only specifies the URL of the background image. To specify the <tt>background-position</tt> and <tt>background-repeat</tt> as well, use the <tt>background</tt> shorthand property.
Secondly, there are syntax errors in the PL/SQL region code:v_style := v_style||'.slide_'||v_cursor.ID||'{background:url('||v_cursor.FONDO )||') no-repeat 0 0;}';
There's no <tt>FONDO</tt> member in the cursor record, and it's followed by a misplaced ')'...
Thirdly (and probably most important), the URL needs to point to a resource that will actually download the image to the browser. An On-Demand Process can be used for this:
1. Create application item <tt>ODP_CFG_BACKGROUND_ID</tt> to use as an image ID parameter for the ODP.
2. Create the <tt>ODP_CFG_BACKGROUND</tt> on-demand application process:declare l_background cfg_background.background%type; l_mimetype cfg_background.mimetype%type; l_filename cfg_background.filename%type; begin select bg.background , bg.mimetype , bg.filename into l_background , l_mimetype , l_filename from cfg_background bg where bg.id = :odp_cfg_background_id; owa_util.mime_header(l_mimetype, false); htp.p('Content-Length: ' || dbms_lob.getlength(l_background)); htp.p('Content-Disposition: filename="' || l_filename || '"'); owa_util.http_header_close(); wpg_docload.download_file(l_background); end;
3. Rewrite the PL/SQL region code to generate URLs to the ODP:begin htp.p('<style type="text/css">'); for bg in (select to_char(id, 'tm9') id from cfg_background) loop htp.p( '.slide_' || bg.id || ' { background: url(f?p=&APP_ID.:&APP_PAGE_ID.:&APP_SESSION.:APPLICATION_PROCESS=odp_cfg_background:N::odp_cfg_background_id:' || bg.id || ') 0 0 no-repeat; }'); end loop; htp.p('</style>'); end;
Note also that <tt>style</tt> is only valid within the page <tt>head</tt> element, so unless the page template contains a suitably placed region position a PL/SQL region may not be the best way to deliver the style sheet... -
thanks for the solution.
-
Hi Paul J MacMillan,
It works very well !
But it doesn't work for the login page.
I guess login page cann't call an application process... Is there a shorcut to get this ?
Thank you very much !
Edited by: mario1977 on Jan 17, 2013 11:20 AM
This discussion has been closed.