This discussion is archived
10 Replies Latest reply: Feb 14, 2013 10:15 PM by 991253 RSS

apex_ replacement for htmldb_get() and where is the documentation?

Klabautermann Newbie
Currently Being Moderated
Hello,

In Application Express API Reference Release 4.1 there is this note:

-------
Note:
In release 2.2, Oracle Application Express APIs were renamed using the prefix APEX_.
Note that API's using the previous prefix HTMLDB_ are still supported to provide backward
compatibility. As a best practice, however, use the new API names for new applications
unless you plan to run them in an earlier version of Oracle Application Express.+
-------

Ok fine, but what is the apex_ replacement for htmldb_get()? I've looked high and low on the net. I can find all kinds of examples and tutorials for using htmldb_get(), but I can't seem to find a reference page for htmldb_get() syntax. I also can't seem to fine an apex_ replacement for it in the the 4.1 API reference manual. Any help is appreciated.

Edited by: Klabautermann on Oct 3, 2012 3:27 PM
  • 1. Re: apex_ replacement for htmldb_get() and where is the documentation?
    Udo Guru
    Currently Being Moderated
    Hello Dan,

    I think the note you've quoted referes to the PL/SQL API's, whereas htmldb_get is part of the JS API. Unfortunately, it (still) seems to be undocumented...
    Basically, it can be used to get an APEX page using an AJAX call.
    Available parameters (as of APEX 4.1) are
    <ul>
    <li>obj - (DOM node | String) object to put in the partial page (may be empty)
    <li>flow - (String) application id
    <li>req - (String) request
    <li>page - (String) page number
    <li>instance - (String) parameter p_instance (for partial page refresh)
    <li>proc - (String) process to call
    <li>queryString - (String) holder for queryString (=>passing f?-syntax)
    </ul>

    There is no "apex_"-style replacement for this function (yet).

    -Udo
  • 2. Re: apex_ replacement for htmldb_get() and where is the documentation?
    fac586 Guru
    Currently Being Moderated
    Udo wrote:

    There is no "apex_"-style replacement for this function (yet).
    And with the inclusion of jQuery in APEX 4.x there's not likely to be. Use the documented jQuery APEX methods instead. Search the forum for examples of doing this in APEX.
  • 3. Re: apex_ replacement for htmldb_get() and where is the documentation?
    TobiP Explorer
    Currently Being Moderated
    I was also searching for this and I found a small but usefull example on Stack Overflow with a bit of description.
  • 4. Re: apex_ replacement for htmldb_get() and where is the documentation?
    Tom Petrus Expert
    Currently Being Moderated
    That is my answer :-) You can find another here.

    Not that i'm that much an advocate of htmldb_get though. I agree with Paul that you're better off using jQuery's ajax function, or the shorthands such as post and get.
    You just have much more control over your requests with the jQuery methods. But the htmldb_get functions will not go away, i'm sure many and more applications would be instantly broken.
  • 5. Re: apex_ replacement for htmldb_get() and where is the documentation?
    Joni Vandenberghe Pro
    Currently Being Moderated
    Yeah there isn't much documentation yet, I have heard about changes to the API library from Apex, I'm sure we will see proper documentation once Apex 4.2 is in production.
    While I'm sure html_db.. will still work with Apex 4.2, I never like using an undocumented function, so I prefer $.ajax, the now build-in Apex jQuery Ajax function that is pretty well documented on the jQuery site.
  • 6. Re: apex_ replacement for htmldb_get() and where is the documentation?
    TobiP Explorer
    Currently Being Moderated
    Hey Tom,
    What you need to make it work: an ajax callback process, with the following line:
    apex_util.set_session_state('P2_PAR_ENAME', apex_application.g_x01);
    Where exactly do you define that? I am working on a similar example, but I cant get it to work. The on-demand procces is just not starting.
    And if you use jQuery, how exactily do you bind it to apex or oracle? Can you give me a link, where this is described in more detail?

    Thanks!

    tobi
  • 7. Re: apex_ replacement for htmldb_get() and where is the documentation?
    Joni Vandenberghe Pro
    Currently Being Moderated
    A small example:
    Call it from javascript using:
    $.ajax({type: "POST"
           , url: "wwv_flow.show"
           , data: {  p_flow_id:$('#pFlowId').val()
                    , p_flow_step_id:$('#pFlowStepId').val()
                    , p_instance: $('#pInstance').val()
                    , x01: 'Succes message'
                    , xNN ........
                    , p_request: 'APPLICATION_PROCESS=MY_AJAX_PROCESS'
                    }
    , success: function(data){
    alert(data);
    }
    });

    Replace my_ajax_process by the name of your AJAX on demand process
    x01-x.. are your variables, they arive in your pl/sql function as wwv_flow.gx01
    Example vvar1 := TO_NUMBER(wwv_flow.gx01);

    You can return values using HTP.P(mystringvar);


    More info about the jQuery ajax function can be found here:
    http://api.jquery.com/jQuery.ajax/
  • 8. Re: apex_ replacement for htmldb_get() and where is the documentation?
    Tom Petrus Expert
    Currently Being Moderated
    Tobi,
    In the linked example that line of code is in an AJAX Callback Process on that page, and the name of the process is
    set_session_state
    As for jquery stuff, in this answer i put a short example of an ajax process

    And sure, you can use $.ajax(), and it'll give you even more control. But usually i use $.post, which is a shorthand.
             $.post('wwv_flow.show', 
                    {"p_request"      : "SOME_APPLICATION_PROCESS",
                     "p_flow_id"      : $v('pFlowId'),
                     "p_flow_step_id" : $v('pFlowStepId'),
                     "p_instance"     : $v('pInstance'),
                     "x01"            : some_js_variable,
                     "x02"            : another_js_variable}, 
                     function(data){
                        var jsonobj = $.parseJSON(data); 
                        //do something with it...
                    }
                   );
    This would call a process (SOME_APPLICATION_PROCESS) on the page it is called from (since p_flow_step_id is specified - if this is null it would call an application process).
    <ul>
    <li>p_flow_id : application id</li>
    <li>p_flow_step_id : page id</li>
    <li>p_instance: session</li>
    <li>The x## variables are temp variables you can use, and are accessible in plsql through apex_application.g_x##.</li>
    </ul>
  • 9. Re: apex_ replacement for htmldb_get() and where is the documentation?
    TobiP Explorer
    Currently Being Moderated
    Wow! Tom, Joni, thank you guys so much! This is really cool :) The rest of the possibilities I will find out, I'll have a look around on the jQuery page.

    btw, Joni, there is a "_" missing wwv_flow.g_x1
  • 10. Re: apex_ replacement for htmldb_get() and where is the documentation?
    991253 Newbie
    Currently Being Moderated
    This is great info! Very difficult to find this stuff anywhere. It does bring up a question though:

    What is the scope of these global variables (eg: apex_application.g_x01)? Are they truly 'global', or are the session-scoped or request-scoped?

    I did some tests and my findings seem to be these variables are global are within request scope (ie: other requests in the same session and other requests in different sessions get their own copies of the global variables), but I'd like to confirm my findings are correct.

    Thanks!

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points