[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 939
  • Last Modified:

Oracle APEX and PL/SQL procedure to show image

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
futureDBA
Asked:
futureDBA
1 Solution
 
Geert GruwezOracle dbaCommented:
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
 
Swadhin RaySenior Technical Engineer Commented:
The date format should be : TO_DATE('09-JAN-13', 'DD-MON-YY')  
not

TO_DATE('09-JAN-13', 'DD-MMM-YY')
0
 
sdstuberCommented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Not enough information to confirm an answer.
0
 
sdstuberCommented:
The example script includes a working example demonstrating the requested functionality.
0
 
sdstuberCommented:
I recommend http:#a38778624 for accept.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now