Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQL Text Result with chr(10) (newline) NOT carried over to HTP.P Javascript Mailto

TanPApr 14 2015 — edited Apr 15 2015

[Application Express 4.2.1.00.08.]

Hello, Super Gurus!

Maybe I'm still not able to wrap my head around quotes and concatenations yet, as in this post , I'd like to ask for your help again. 

I can't seem to get a NEW LINE character to work in my htp.p & javascript.

Full story: it's an extension to what I've been working on, as noted in the link above.  This time around, I'm calling a similar query, as shown below, from my "After Submit PL/SQL anonymous block" process:

DECLARE
    TYPE emp_aat IS TABLE OF emp%ROWTYPE;
    l_employees emp_aat;
     v_result varchar2(5000) := '';
BEGIN
    SELECT *
    BULK COLLECT INTO l_employees
    FROM emp
    ORDER BY ename;

FOR i IN 1 .. l_employees.COUNT
LOOP
  v_result := v_result || l_employees (i).ename || ' -  '
                                 || 'Job: ' || l_employees (i).job || ' ';
                                 || chr(10);
END LOOP;
    DBMS_OUTPUT.put_line (v_result);
END;

The above works nicely with the CHR(10), where each result starts on a new line:

ADAMS - Job: CLERK

ALLEN - Job: SALESMAN

BLAKE - Job: MANAGER

CLARK - Job: MANAGER

Further down on my PL/SQL block process, the problem I'm having is that I cannot get the v_result to show up as desired, with the new line:

htp.p('<body>');

    htp.p('<script type="text/javascript">');

    HTP.p('window.location.href="mailto:' || v_logged_on_user_email || ';'

          ||'?subject=Salary Raise Request'

          ||'&cc='

          ||v_hr_email

          ||';'

          ||'&body= '
          ||'\n'

          ||'Two hundred % raise for these luck folks!'

          ||'\r\n'

          ||v_result

          ||'";'

         );

    htp.p('</script>');

    htp.p('</body>');

As a matter of fact, those '\n' and '\r\n' above don't seem to work at all.  And the body of my email just has 1 big lump:

ADAMS - Job: CLERK ALLEN - Job: SALESMAN BLAKE - Job: MANAGER CLARK - Job: MANAGER

Questions:

- Should I replace "CHR(10)" in my SQL query with something so that javascript would recognize?

- How come '\n' is not working, as expected?

Please let me know if I've done something incorrectly with the above, and what should be done to correct it.

Thank you very much!

This post has been answered by Scott Wesley on Apr 14 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 13 2015
Added on Apr 14 2015
3 comments
1,782 views