Solved

Oracle APEX and PL/SQL procedure to show image

Posted on 2013-01-14
9
831 Views
Last Modified: 2014-05-29
Experts,

I need for a PL/SQL procedure to show an image in an HTML region when a date selector holds a certain value.

I am confused on how to go about this.

This is what I came up with so far.

DECLARE
vGood   varchar2(100)    := 'http://www.url.com/goodol.jpg';
vBad    varchar2(100)    := 'http://www.url.com/badeu.jpg';
BEGIN
IF :P0_DATE = '09-JAN-13' THEN htp.img ('vGOOD');
ELSE htp.img ('vBad');
END IF;
END
/

Open in new window

0
Comment
Question by:futureDBA
9 Comments
 
LVL 36

Expert Comment

by:Geert Gruwez
ID: 38776264
make sure you have both parameters as a date

DECLARE
vGood   varchar2(100)    := 'http://www.url.com/goodol.jpg';
vBad    varchar2(100)    := 'http://www.url.com/badeu.jpg';
BEGIN
IF :P0_DATE = TO_DATE('09-JAN-13', 'DD-MMM-YY') THEN htp.img ('vGOOD');
ELSE htp.img ('vBad');
END IF;
END
/
0
 
LVL 16

Expert Comment

by:Swadhin Ray
ID: 38777218
The date format should be : TO_DATE('09-JAN-13', 'DD-MON-YY')  
not

TO_DATE('09-JAN-13', 'DD-MMM-YY')
0
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 total points
ID: 38778624
don't put quotes around your variables inside the htp.img
don't use '/' as the block terminator inside the html region source
do end the block with a semicolon

DECLARE
vGood   varchar2(100)    := 'http://www.url.com/goodol.jpg';
vBad    varchar2(100)    := 'http://www.url.com/badeu.jpg';
BEGIN
IF :P0_DATE = '09-JAN-13' THEN htp.img (vGOOD);
ELSE htp.img (vBad);
END IF;
END;


Also, assuming your bind variable is the APEX page item (probably a date picker), it should be a string as you had in your question, it should NOT be converted to a date.

Attached is a simple APEX page you can import into your app that demonstrates what you're trying to do

Note, I replicated the same format you used, but you might want to consider a 4-digit YYYYY mask to ensure you're not reinventing the y2k bug.


I'm assuming the snippet above is just for testing; for best practices you may want to consider writing your real code as pl/sql package and simply pass the values to your packaged procedures rather than embedding the code directly within the page definition.
f102-page-1.sql
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40084693
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 40084694
The example script includes a working example demonstrating the requested functionality.
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 40095476
I recommend http:#a38778624 for accept.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now