Search code examples
oracle-apexoracle-apex-5

How to get feedback id when a new feedback is created using apex_util.submit_feedback procedure


I am trying to create a feedback using apex_util.submit_feedback procedure within APEX application.

apex_util.submit_feedback (
p_comment         => :P102_FEEDBACK,
p_type            => :P102_FEEDBACK_TYPE,
p_application_id  => :P102_APPLICATION_ID,
p_page_id         => :P102_PAGE_ID,
p_email           => null);

My query is how can I refer to the newly created feedback record?

Is there any out parameter which returns feedback Id? I have searched on oracle documentation but no info about how to get feedback id.


Solution

  • Looking at APEX 4.2 (I don't have 5.0 installed) the feedback table WWV_FLOW_FEEDBACK has a trigger WWV_FLOW_FEEDBACK_T1 that does this:

    if inserting and :new.id is null then
        :new.id := wwv_flow_id.next_val;
    end if;
    

    So it may be that you can get the ID of the feedback immediately after you call apex_util.submit_feedback like this:

    new_feedback_id := wwv_flow_id.curr_val; 
    

    However, it is possible that apex_util.submit_feedback sets the ID explicitly from some other sequence, in which case the trigger will not set it. It should be easy to test a few times and check.

    Bear in mind that even if this does work now, there is no guarantee that Oracle won't change the way it works in a future release of APEX and break your code!