Sometimes we get requirements to display images in the report. Since most of the time images are of large size, displaying it using 'fnd_file.put_line' will not work as the size limit for fnd_file.put_line is 32K.
The solution for this is to use the below code.
Function getbase64 is used to convert BLOB to CLOB (which is posted in last post).
The solution for this is to use the below code.
Function getbase64 is used to convert BLOB to CLOB (which is posted in last post).
DECLARE
CURSOR emp_img_cur (p_person_id NUMBER)
IS
SELECT xxadnic_sshr_daily_rep_pkg.getbase64 (image) image1
FROM per_images
WHERE parent_id = p_person_id;
emp_img_rec emp_img_cur%rowtype;
l_length NUMBER (10);
l_xmlstr VARCHAR2 (32000);
l_offset NUMBER (10) := 32000;
l_retrieved NUMBER (10) := 0;
l_result CLOB;
BEGIN
OPEN emp_img_cur (4426);
FETCH emp_img_cur INTO emp_img_rec;
l_result := '<IMAGE>' ||emp_img_rec.image1 || '</IMAGE>';
l_length := NVL (DBMS_LOB.getlength (l_result), 0);
LOOP
EXIT WHEN l_length = l_retrieved;
IF (l_length - l_retrieved) < 32000
THEN
SELECT SUBSTR (l_result, l_retrieved + 1) INTO l_xmlstr FROM DUAL;
l_retrieved := l_length;
fnd_file.put_line (fnd_file.output, l_xmlstr);
ELSE
SELECT SUBSTR (l_result, l_retrieved + 1, l_offset)
INTO l_xmlstr
FROM DUAL;
l_retrieved := l_retrieved + l_offset;
fnd_file.put_line (fnd_file.output, l_xmlstr);
END IF;
END LOOP;
END;