Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Oracle APEX and PL/SQL procedure to show image

Posted on 2013-01-14
9
859 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 74

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 143

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 74

Expert Comment

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

Expert Comment

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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

840 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