APEX: Accessing the the page URL in PL/SQL

Posted on 2012-09-05
Last Modified: 2012-09-25
I have an APEX app that I am wanting to have a procedure that handles the process errors, PL/SQL errors.
In the proc I am using OWA_UTIL.GET_CGI_ENV() to get env values.
I would like to get the URL of the page that has the process error.
How do I do that? or do you have error handling that may help.

Also, I take it I will have to use a PRAGMA AUTONOMOUS_TRANSACTION; to be able to send the email and then call raise_application_error() which rollsback.. doesn't it?

  ls_errmsg :='Get Browser Type';
  IF ls_browser_type LIKE '%Chrome%' THEN  
      ln_start:= instr(ls_browser_type,'Chrome/');
      ln_end  := instr(ls_browser_type,'Safari/');
      ls_browser_type := substr(ls_browser_type,ln_start,ln_end -ln_start);  
  ELSIF ls_browser_type LIKE '%MSIE 9.0%' THEN  
   ls_browser_type := 'Internet Explorer 9.0';  
  ELSIF ls_browser_type LIKE '%MSIE 8.0%' THEN  
   ls_browser_type := 'Internet Explorer 8.0';  
  ELSIF ls_browser_type LIKE '%MSIE 7.0%' THEN  
   ls_browser_type := 'Internet Explorer 7.0';  
  ELSIF ls_browser_type LIKE '%MSIE 6.0%' THEN  
   ls_browser_type := 'Internet Explorer 6.0';  
  ELSIF ls_browser_type LIKE '%Firefox/3%' THEN  
   ls_browser_type := 'Firefox v3.0';  
  ELSIF ls_browser_type LIKE '%Firefox/2%' THEN  
   ls_browser_type := 'Firefox v2.0';  
  ELSIF ls_browser_type LIKE '%Firefox/1%' THEN  
   ls_browser_type := 'Firefox v1.0';  
   ls_browser_type := 'UNKNOWN['||ls_browser_type||']';  
  END IF;  

  ls_errmsg :='Get HTTP_REFERER';

  ls_errmsg :='Get HTTP_CONTENT_LENGTH';

  ls_errmsg :='Get HTTP_HOST';

    lc_clob_loc := 'Passed ErrCode['||p_sqlcode||']'
          ||ls_newline||'ERROR: ['||p_errmsg||']'||ls_newline
    lb_continue:= APP_UTIL.SEND_MAIL(
Question by:bcarlis

    Expert Comment

    Is this process part of the login page or page zero?

    I guess you just want to make sure that IE lower 8 is not used, since it most likely causes problems with the UI, right?

    If so, then couldn't you just make your login button, password and user item conditional depending on the value of another page item (lets call it P101_Browser_Check), which applies your OWA_UTIL.GET_CGI_ENV() routine as source?

    You could add a html region that is displayed or hidden depending on P101_Browser_Check.
    If the browser version is detected as IE 7, IE 6 and so on then hide the login area and display the info area. Otherwise do it vice versa.

    Maybe it's after all not at all what you want. But Apex offers quite good error handling at least in version 4.1.1. Thus, I don't know why you want to send emails with your sql error codes and respective URL.
    LVL 2

    Author Comment

    no, this is a procedure in db schema that all others use for error handling.

    RE: I don't know why you want to send emails with your sql error codes and respective URL.
    At the time of error I want to receive an email with all the info possible... say can I access all the debug info at that time?
    the url would give me app, page, args, etc

    Accepted Solution

    Hi. I just found this on OTN, which should work for you:

    1. Create a new html region at the bottom of your page (page region depends on your template and theme you use).

    2. Paste the following code into the html bottom region.

    3. Replace MY_URL_ITEM with the page item's name.

    <script type="text/javascript">
    document.getElementById("MY_URL_ITEM").value = document.URL;

    Open in new window

    Now you can use your new Item in your code!

    Hope it helps!



    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    trigger 5 39
    Access Required to Import Oracle Database Table 3 34
    Oracle Database creation fails 5 20
    Oracle Pivot 2 21
    How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
    Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
    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.
    Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now