Solved

Oracle APEX and PL/SQL procedure to show image

Posted on 2013-01-14
9
851 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 37

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

777 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