Forum Stats

  • 3,770,906 Users
  • 2,253,180 Discussions
  • 7,875,653 Comments

Discussions

Oracle APEX PLSQL Dynamic Content - How to call procedure using html

Jasper Tanglib
Jasper Tanglib Member Posts: 68 Green Ribbon
edited Aug 16, 2021 6:21PM in APEX Discussions

Hi,

In Oracle APEX 20.2, I have a PL/SQL Dynamic Content that creates a Delete button. When the Delete button is clicked, I want it to execute a PLSQL procedure. This is how I did it based from other sites but it does not work.

    DECLARE

    CURSOR c_Forms IS

    SELECT DISTINCT TE.FORM_ID, TE.ENVIRONMENT_NAME, TE.ENVIRONMENT_TAGS, TE.PROJECT_ID

    FROM TC_ENVIRONMENT TE

    JOIN TC_DATABASE TD ON TE.FORM_ID = TD.FORM_ID

    WHERE TD.PROJECT_ID = :P13_PROJECT_ID

    AND TD.PROJECT_NAME = :P13_PROJECT_NAME

    ORDER BY TE.FORM_ID DESC;

BEGIN

FOR Rec_d IN c_forms 

        LOOP


-- Delete Button

        htp.p('<form action="dev_schema.delete_form_id('|| Rec_d.form_id ||')" method= "GET">

                    <button align="right" class="t-Button t-Button--hot lto30524678744651345_0" type="button" id="dynamic-delete">

                        <span class="t-Button-label">Delete</span>

                    </button>

                </form>

                ');


END LOOP;

END;

How to I call a procedure using html.

Any ideas or suggestions are appreciated.

- Jazz

Answers

  • fac586
    fac586 Senior Technical Architect Member Posts: 20,149 Red Diamond

    What "other sites" are you referring to? Always provide links to any resources you have consulted.

     DECLARE
    
      CURSOR c_Forms IS
      SELECT DISTINCT TE.FORM_ID, TE.ENVIRONMENT_NAME, TE.ENVIRONMENT_TAGS, TE.PROJECT_ID
      FROM TC_ENVIRONMENT TE
      JOIN TC_DATABASE TD ON TE.FORM_ID = TD.FORM_ID
      WHERE TD.PROJECT_ID = :P13_PROJECT_ID
      AND TD.PROJECT_NAME = :P13_PROJECT_NAME
      ORDER BY TE.FORM_ID DESC;
    
    BEGIN
    
    FOR Rec_d IN c_forms 
        LOOP
    -- Delete Button
        htp.p('<form action="dev_schema.delete_form_id('|| Rec_d.form_id ||')" method= "GET">
              <button align="right" class="t-Button t-Button--hot lto30524678744651345_0" type="button" id="dynamic-delete">
                <span class="t-Button-label">Delete</span>
              </button>
            </form>
            ');
    
    END LOOP;
    
    END;
    

    HTML does not allow form elements to be nested, and APEX does not support multiple form elements on a page. This is therefore the wrong approach in APEX.

    What problem are you really trying to solve?

    Is this related to the other issue you have posted on the APEX forum? If so, I suggest we consolidate the discussion there.

  • Jasper Tanglib
    Jasper Tanglib Member Posts: 68 Green Ribbon

    Hi fac586, Yes this is related to that other issue.

    The requirement was, for every time Table A has data, it should auto display those data, and I could do that through simple table reports, but I had to use PL/SQL Dynamic Content regions because the requirement had this specific UI I had to achieve.

    After being able to successfully customize the specific UI, and create a button that will redirect to another page, in PL/SQL Dynamic Content, I now have to create a Delete button. I have tried to achieve this as what I have posted above, but unfortunately since you mentioned APEX does not support that way of implementation, I had to try other ways. Another way I have tried was create a custom DA, that will execute the delete query when delete button is clicked.

    DA

    Code in PLSQL Dynamic Content

    DECLARE
      CURSOR c_Forms IS
      SELECT DISTINCT TE.FORM_ID, TE.ENVIRONMENT_NAME, TE.ENVIRONMENT_TAGS, TE.PROJECT_ID
      FROM TC_ENVIRONMENT TE
      JOIN TC_DATABASE TD ON TE.FORM_ID = TD.FORM_ID
      WHERE TD.PROJECT_ID = :P13_PROJECT_ID
      AND TD.PROJECT_NAME = :P13_PROJECT_NAME
      ORDER BY TE.FORM_ID DESC;
    BEGIN
    FOR Rec_d IN c_forms 
        LOOP
    -- Delete Button
        :P13_DYNAMIC_FORM_ID := Rec_d.form_id;
        htp.p('<button align="right" class="t-Button t-Button--hot lto30524678744651345_0" type="button" id="dynamic-delete">
                <span class="t-Button-label">Delete</span>
              </button>');
    END LOOP;
    END;
    

    Javascript that uses ID to trigger DA


    Unfortunately, this is not able to get the ID of the dynamically created Delete buttons.


    Another workaround I plan is I would use an interactive report and then customize the entire table template to fit the custom UI requirement.