Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Oracle APEX and PL/SQL procedure to show image

Posted on 2013-01-14
9
Medium Priority
?
910 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
[X]
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
9 Comments
 
LVL 38

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 2000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and theā€¦
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

618 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