首页 > 解决方案 > Oracle Apex 20 - 交互式报告中列上的 REST 源操作

问题描述

我正在尝试使用表格报告设置表单并仅使用 REST 源。

目前我有一个表单和交互式报告设置。它使用带有动态项目的休息源。IE:

http://source/asm/instances/:group

:group然后可以从表单中搜索到哪里。

现在返回的列都是与用户相关的,但我希望能够通过 REST API 设置一项。所以假设我进入了一个组并得到以下结果:

group | name | surname | status
ABC   | Dan  | Murray  | inactive
ABC   | Mary | Swanson | active

REST Source 具有status远程激活/停用工具的功能。IE

http://source/asm/instances/ABC/dan/activate

http://source/asm/instances/ABC/dan/deactivate

现在我需要将状态列修改为具有两个选项的列表形式,激活/停用。This is where the issue comes in. When either of the two items are selected, it needs to use the relevant REST source as posted above and post to the tool, meaning it will activate/deactivate on the fly. 我整个周末都在寻找和尝试,但我找不到办法做到这一点。

到目前为止,我最接近的是创建一个链接,但这只是将我路由到我不需要的 URL。

我真的希望有人能够在这里帮助我,因为我正在苦苦挣扎。

标签: restoracle-apex-20.1oracle-rest-data-services

解决方案


也许我解决了你的问题,试试看。:)

版本

Oracle Application Express 20.2.0.00.20

解决方案

我想您知道如何设置REST 数据源 (DS)并使用从 de DS 获取的数据创建交互式报告,因此我将跳过这些步骤。

  1. 转到您的交互式报告定义并在设置下找到本地后处理并设置值:
  • 类型:SQL 查询
  • SQL查询:
select 
    /*leave all the columns fetched from the DS*/
    --
    -- Add this column 
    '<a class="rest-button-status" data-id="'||<PRIMARY-KEY>||'">Link</a>' BUTTON
  from #APEX$SOURCE_DATA#
  1. 转到BUTTON列定义,在Security disable Escape special characters下。

  2. 添加一个新的隐藏项并将其命名为 P1_NEW。

  3. 运行应用程序,您应该会在最后一列中看到带有链接的交互式报告。

  4. 现在添加一个定义为的动态操作(随意命名):

在此处输入图像描述

  1. 向这个 DA 添加两个 True 动作:
  • 第一 - 设定值

在此处输入图像描述

// copy paste code
$(this.triggeringElement).attr('data-id')

  • 第二 - 执行服务器端代码 (PL/SQL)

编辑要提交的页面项目 - P1_NEW


-- code
DECLARE
    l_clob  CLOB;
    -- I added a parameter PK
    v_url VARCHAR2(2000) := 'http://xxxxx:8080/ords/xxxx/xxxxxx/test-apex/deactivate?PK=';
BEGIN
    L_CLOB := APEX_WEB_SERVICE.MAKE_REST_REQUEST(
        -- I added a parameter PK
        p_url                  => v_url||:P1_NEW,
        p_http_method          => 'POST' -- or GET or other
    );
END;

切换系统(激活/停用)取决于您,也许最好的解决方案是拥有一个端点,然后 DS 控制状态。

编辑 - 基于评论 以下是第二个 DA 的一些屏幕截图:

  1. 向 DA 添加另一个操作。

在此处输入图像描述

  1. 定义一个Execute Server-side CodeExecute PL/SQL Code(操作的名称取决于您拥有的 Oracle APEX 版本)

在此处输入图像描述


推荐阅读