oracle 在 APEX 中创建表单以在交互式报表的查询中设置变量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7798449/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 00:23:00  来源:igfitidea点击:

Creating a Form in APEX to set Variables in a Query for an Interactive Report

oracleoracle-apex

提问by Rob

I am a relative APEX noob.

我是一个相对的 APEX 菜鸟。

I'm running APEX 4.0 against a 10gR2 database.

我正在针对 10gR2 数据库运行 APEX 4.0。

I've written a query that takes a few inputs (two date fields, for start and end, and a text field for further filtering) and created a dynamic report out of it that works when I pull the input variables (:START_DATE, :END_DATE, :OFFICE) out of it or replace them with static values.

我编写了一个查询,它接受一些输入(两个日期字段,用于开始和结束,以及一个用于进一步过滤的文本字段),并从中创建了一个动态报告,当我提取输入变量 (:START_DATE, : END_DATE, :OFFICE) 或用静态值替换它们。

I want to create a form on a page that submits those values to the dynamic report page for use in the query to filter the results the user sees when he or she hits the report.

我想在页面上创建一个表单,将这些值提交到动态报告页面,以便在查询中使用,以过滤用户点击报告时看到的结果。

I'm not having much luck finding a good step-by-step example of this. I created a blank page with two Date Pickers and a LOV select dropdown, but am unsure how to best translate those values into the dynamic report.

我没有太多运气找到一个很好的分步示例。我创建了一个带有两个日期选择器和一个 LOV 选择下拉列表的空白页面,但我不确定如何最好地将这些值转换为动态报告。

Can somebody point me at the right documentation for this?

有人可以指出我正确的文档吗?

回答by Ian Carpenter

The following was developed using Apex 4.1 but apart from some cosmetic changes the principles should be the same.

以下内容是使用 Apex 4.1 开发的,但除了一些外观变化外,原则应该是相同的。

The data comes from the standard scott.emp schema.

数据来自标准的 scott.emp 模式。

Overview

概述

This is page 1, the user can enter an empno and\or a hiredate.

这是第 1 页,用户可以输入 empno 和/或受雇人员。

enter image description here

在此处输入图片说明

When submit is pressed the following report on a different page is displayed:

当按下提交时,将在不同页面上显示以下报告:

enter image description here

在此处输入图片说明

How it works

这个怎么运作

On page 1 I have created the three items shown. The text items are called them P1_EMPNO, and P1_HIREDATE. The action for the button is "Submit Page"

在第 1 页上,我创建了显示的三个项目。文本项称为 P1_EMPNO 和 P1_HIREDATE。该按钮的操作是“提交页面”

Still on page 1, create a branch with the following values:

仍然在第 1 页上,使用以下值创建一个分支:

enter image description here

在此处输入图片说明

This branch navigates to page 2 (which is yet to be developed) and sets the values of items on page 2 with the values from page 1.

此分支导航到第 2 页(尚未开发)并使用第 1 页中的值设置第 2 页上的项目的值。

Create a new page, in this example this will be referred to page 2.

创建一个新页面,在本例中将参考第 2 页。

On page 2 create a new interactive report using the following query:

在第 2 页上,使用以下查询创建一个新的交互式报告:

select e.* 
from emp e

Next create two text items in the same region as the report and call these :P2_EMPNO and :P2_HIREDATE. I have found it useful to show these items during development so you can see that the correct values are being passed through to the page. You can always set them as hidden once you happy with the report.

接下来在与报告相同的区域中创建两个文本项,并调用它们:P2_EMPNO 和 :P2_HIREDATE。我发现在开发过程中显示这些项目很有用,因此您可以看到正确的值正在传递到页面。一旦您对报告感到满意,您可以随时将它们设置为隐藏。

Finally amend the query used by the interactive report to use the values supplied by page 1

最后修改交互式报告使用的查询以使用第 1 页提供的值

enter image description here

在此处输入图片说明

Run the application.

运行应用程序。

回答by Tom

You want to reference your page items in your query, which means you'll have to submit your page before your query will pick up the session state of them. What I do when I provide a small parameter form, is to put a button up there as well (i.e. labeled 'Query'), which does a submit.

您希望在查询中引用您的页面项目,这意味着您必须在查询获取它们的会话状态之前提交您的页面。当我提供一个小的参数表单时,我所做的就是在那里放一个按钮(即标记为“查询”),它执行提交。

In your report you can then reference your items. If for example you have 2 items P1_DATE_STARTand P1_DATE_END, your query could look like:

在您的报告中,您可以参考您的项目。例如,如果您有 2 个项目P1_DATE_STARTP1_DATE_END,则您的查询可能如下所示:

SELECT firstname, lastname, job
  FROM employees
 WHERE employment_start BETWEEN to_date(:P1_DATE_START) AND to_date(:P1_DATE_END);