Slider plug-in with images from table

Von Tobias Arnhold 1.22.2012
I added a new example for the slider plug-in:
http://apex.oracle.com/pls/apex/f?p=65560:12


In the new example I show the slider selecting the image from a table column.
This is the select I use:
select
IMG_ID as id,
'#OWNER#.aaw_img_display?p_img_id=' || to_char(IMG_ID) as img,
IMG_FILENAME as text,
IMG_DESCRIPTION as description,
'bottom' as position
from AAW_IMAGES

I also show how the dynamic action refresh looks like if you swith the value inside the select list.

Instructions about the table solution
Denes Kubiceks Example: http://apex.oracle.com/pls/otn/f?p=31517:64
Hil&Co: http://blog.hilandco.com/2010/05/how-to-show-blob-type-column-as-image.html

Here is the DDL code I used:
CREATE SEQUENCE   "AAW_IMG_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE  NOORDER  NOCYCLE ;
/
CREATE TABLE  "AAW_IMAGES" 
   ( "IMG_ID" NUMBER NOT NULL ENABLE, 
 "IMG_FILENAME" VARCHAR2(100), 
 "IMG_DESCRIPTION" VARCHAR2(500), 
 "IMG_MIMETYPE" VARCHAR2(100), 
 "IMG_FILE" BLOB NOT NULL ENABLE, 
 "IMG_TIME_STAMP" DATE NOT NULL ENABLE, 
 "IMG_UPD_USER" VARCHAR2(50) NOT NULL ENABLE, 
 "IMG_CHARACTER_SET" VARCHAR2(100), 
 "IMG_BLOB_TIME_STAMP" DATE, 
 "IMG_CLASS" VARCHAR2(100), 
 "IMG_TEXT" VARCHAR2(500), 
  CONSTRAINT "PK_IMG_ID" PRIMARY KEY ("IMG_ID") ENABLE
   ) ;


CREATE OR REPLACE TRIGGER  "AAW_IMG_TRG" 
   BEFORE INSERT OR UPDATE
   ON AAW_IMAGES
   REFERENCING NEW AS NEW OLD AS OLD
   FOR EACH ROW
DECLARE
BEGIN
   IF :NEW.IMG_ID IS NULL
   THEN
      SELECT AAW_IMG_SEQ.NEXTVAL
        INTO :NEW.IMG_ID
        FROM DUAL;
   END IF;
   IF INSERTING
   THEN
      :NEW.IMG_TIME_STAMP := SYSDATE;
      :NEW.IMG_UPD_USER := NVL (v('APP_USER'), USER);
   END IF;
   IF UPDATING
   THEN
      :NEW.IMG_TIME_STAMP := SYSDATE;
      :NEW.IMG_UPD_USER := NVL (v('APP_USER'), USER);
   END IF;
EXCEPTION
   WHEN OTHERS
   THEN
      raise_application_error (-20101,
                               'Error Trigger LOG_FIL_TRG: ' || SQLERRM
                              );
END AAW_IMG_TRG;
/
ALTER TRIGGER  "AAW_IMG_TRG" ENABLE;
/
create or replace PROCEDURE aaw_img_display( p_img_id IN NUMBER)
AS
     
 l_mime        VARCHAR2 (255);
   l_length      NUMBER;
   l_file_name   VARCHAR2 (2000);
   lob_loc       BLOB;
BEGIN
 
         SELECT IMG_MIMETYPE, IMG_FILE, DBMS_LOB.getlength (IMG_FILE)
         INTO l_mime, lob_loc, l_length
         FROM aaw_images
         WHERE img_id = p_img_id;   
 
 
   OWA_UTIL.mime_header (NVL (l_mime, 'application/octet'), FALSE);
   HTP.p ('Content-length: ' || l_length);
   OWA_UTIL.http_header_close;
   WPG_DOCLOAD.download_file (lob_loc);
    
END aaw_img_display;
/
GRANT EXECUTE ON aaw_img_display TO PUBLIC;

About the images: http://www.freedigitalphotos.net
I used them from prozac1, Ron Bird, Jennifer Ellison, xedos4

Post Tags:

2 Comments " Slider plug-in with images from table "

Joe Frizko

you are so remarkable .. We are fans :)

Reg Brink 19 January, 2014 20:33

Any idea why I'd be getting a 403 error (Forbidden)? I think it's because it's unable to call the procedure from APEX (4.2) but since I've granted the proc to public, I'm at a loss. Any clue what I may have missed?