11 Replies Latest reply: Nov 13, 2012 5:04 PM by teedub RSS

    Why does this PL/SQL not redirect?

    teedub
      Why does the following PL/SQL in a dynamic action attached to a button return "Error processing request"? And not redirect?

      declare
      l_url varchar2(255);
      begin
      l_url := apex_util.host_url('SCRIPT')|| v('HOME_LINK');
      :P2_URL := l_url;
      apex_util.redirect_url (p_url => l_url );
      end;

      I have reproduced the issue at
      http://apex.oracle.com/pls/apex/f?p=4550:1:13286116143024:::::

      w/s tmw and all users &pwds are 'redirect'

      Go to page 2 and click the GoHome button.

      cheers
      trev
        • 1. Re: Why does this PL/SQL not redirect?
          Jeff E
          Don't think it will work from a dynamic action. Call it from a page process.
          • 2. Re: Why does this PL/SQL not redirect?
            teedub
            Well, I cannot get the process to work either. I am getting a data not found message.

            All I really want to do is to click a button in order to run some PLSQL and then redirect to the home page.

            My application currently works fine using a button wired to a dynamic action, except for the re-direct bit. But I suspect using a process wired to the button might work in a similar way. So it would be nice to get the process to redirect successfully.
            • 3. Re: Why does this PL/SQL not redirect?
              fac586
              teedub wrote:

              All I really want to do is to click a button in order to run some PLSQL and then redirect to the home page.
              The basic approach to this in APEX is to use conditions:

              1. Create a button that submits the page.
              2. Execute a page process on submission when this button is clicked.
              3. Create a conditional branch to the home page using the same condition.
              • 4. Re: Why does this PL/SQL not redirect?
                Jeff E
                In some places APEX doesn't like APP_ID in the HOME_LINK; use APP_ALIAS in the home link instead of APP_ID

                Re: APP_ID does not resolve in HOME_LINK
                • 5. Re: Why does this PL/SQL not redirect?
                  Patrick Wolf-Oracle
                  Hi Trev,

                  the URL you posted links to the APEX Builder and not to your application, so I'm unable to have a look at your app. But I think you just have to create an additional action in your dynamic action of type "Execute JavaScript" with the following code.
                  apex.navigation.redirect("&HOME.");
                  This would action fire after your "Execute PL/SQL" action and trigger the redirect as soon as the PL/SQL execution comes back.

                  Regards
                  Patrick
                  -----------
                  My Blog: http://www.inside-oracle-apex.com
                  APEX Plug-Ins: http://apex.oracle.com/plugins
                  Twitter: http://www.twitter.com/patrickwolf
                  • 6. Re: Why does this PL/SQL not redirect?
                    jariola
                    Hi Patrick,

                    I can not see that apex.navigation.redirect is documented function
                    http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35127/javascript_api.htm#CDEEIGFH

                    Will this be included to document near future?

                    Regards,
                    Jari
                    -----
                    My Blog: http://dbswh.webhop.net/htmldb/f?p=BLOG:HOME:0
                    Twitter: http://www.twitter.com/jariolai
                    • 7. Re: Why does this PL/SQL not redirect?
                      Patrick Wolf-Oracle
                      Hi Jari,

                      yes it will be included and documented. We are currently working on an update for our JavaScript API documentation to document all the new namespaced JavaScript functions.

                      Regards
                      Patrick
                      -----------
                      My Blog: http://www.inside-oracle-apex.com
                      APEX Plug-Ins: http://apex.oracle.com/plugins
                      Twitter: http://www.twitter.com/patrickwolf
                      • 8. Re: Why does this PL/SQL not redirect?
                        jariola
                        Hi Patrick,

                        Great, Thanks

                        Regards,
                        Jari
                        -----
                        My Blog: http://dbswh.webhop.net/htmldb/f?p=BLOG:HOME:0
                        Twitter: http://www.twitter.com/jariolai
                        • 9. Re: Why does this PL/SQL not redirect?
                          teedub
                          Hi Patrick

                          I tried your solution and it does not do what I expected. Sends me back to the logon page. Obviously I am missing something.
                          I gave the logon credentioals for the builder (tmw/redirect/redirect), but if you want to go directly to the application:
                          http://apex.oracle.com/pls/apex/f?p=56064:2 (redirect/redirect)

                          The GoHome button invokes the GoHome dynamic action onClick:

                          action1: PL/SQL
                          action2: Javascript apex.navigation.redirect("&HOME.");

                          ~trev
                          • 10. Re: Why does this PL/SQL not redirect?
                            Patrick Wolf-Oracle
                            Hi Trev,

                            turned out that I made a copy&paste error
                            apex.navigation.redirect("&HOME.");
                            should actually have been
                            apex.navigation.redirect("&HOME_LINK.");
                            After changing the substitution variable to HOME_LINK the output looked already better, but HOME_LINK contains a substitution variable (&APP_ID.) itself
                            f?p=&APP_ID.:1:6602469592607
                            That's why I have modified the default clause of your P2_URL and referenced that page item in the dynamic action. If that is getting to complicated, you can also just change your dynamic action to a hard coded page#, which might be more straight forward.
                            apex.navigation.redirect("f?p=&APP_ID.:1:&APP_SESSION.");
                            Regards
                            Patrick
                            -----------
                            My Blog: http://www.inside-oracle-apex.com
                            APEX Plug-Ins: http://apex.oracle.com/plugins
                            Twitter: http://www.twitter.com/patrickwolf
                            • 11. Re: Why does this PL/SQL not redirect?
                              teedub
                              Hi Patrick

                              Thank you very much for your solution.
                              apex_application.do_substitutions(:HOME_LINK) - especially as the default value for P2_URL - never even apeared on the radar.

                              I actually added P2_URL just so I could see where the redirect might be trying to go. I am more than happy to do without it. Your plan B using the hard coded home page number works fine too, and is simpler.

                              Thank you again
                              ~Trev