如何维护 Oracle ApEx 表单中的状态
我遇到了障碍,并且不确定使用 Oracle ApEx 解决此问题的最佳方法是什么。
基本上我有一个基于 Table1 的表单,但同时,该表单中的一个部分/区域分支到另一个页面,然后将详细信息添加到 Table2 中。
为了用一个更好的例子来扩展这一点,假设我有一个名为 CUSTOMER 的表,其中包含客户的个人详细信息,例如 CUST_ID、FIRSTNAME、SURNAME、DOB,然后我还有另一个名为 PURCHASES 的表,其中包含以下列 PURCHASE_ID , CUST_ID, ITEM, ITEM_DESCR, COST,其中 CUST_ID 是 CUSTOMERS 表的外键。
我现在想要基于表 CUSTOMER 创建一个 Oracle Apex 表单,但在同一个表单中,在用户提交表单并将其提交到数据库之前,我还希望允许用户添加客户在以下位置购买的所有购买内容商店通过某种方式。一旦用户输入客户详细信息以及 5 条购买记录(以某种方式),所有内容都会提交并提交到 CUSTOMER 和 PURCHASES 表的数据库中。
有没有办法解决这种情况或可能有其他替代方案?
I have hit a snag and I'm unsure on what the best way to tackle this issue using Oracle ApEx.
Basically I have a form that is based off Table1 but at the same time, a section/region within this form branches to another page where it then adds details into Table2.
To expand on this with a better example, let's say that I have a table called CUSTOMER which holds personal details of the customer, such as CUST_ID, FIRSTNAME, SURNAME, DOB and then I also have another table called PURCHASES with the following columns, PURCHASE_ID, CUST_ID, ITEM, ITEM_DESCR, COST with CUST_ID being a foreign key to CUSTOMERS table.
I now want to create an Oracle Apex form based off the table CUSTOMER but within this same form, prior to the user submitting and committing the form to the database, I also want to allow the user to add all the purchases the customer was buying at the store by a means of some sort. Once the user has entered the customer details together with say 5 purchase records (in some way), all is submitted and committed to the database for both the CUSTOMER and PURCHASES tables.
Is there a way around this or possibly other alternatives around this type of situation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要提交第1页并分支到第2页,而不是重定向到第2页来输入表2信息。这将保存会话第 1 页的状态。您还不想将第 1 页的数据更新到 Table1 中,因此请确保此提交不会调用执行插入/更新的进程 - 例如,使其以“保存”按钮或其他方式为条件。
或者,也可以在一个页面上完成所有操作,如我的示例此处。感兴趣的页面是第 7 页,您可以通过“创建”按钮访问该页面。第 7 页有一种主/详细信息表单,但我没有使用 Apex 向导构建它 - 我不确定你是否可以,但我倾向于不使用向导和内置表格工具在我的工作中,所以我不确定。
这就是我对第 7 页所做的操作:
1) 创建一个空白页面
2) 添加 HTML 区域“新客户”,并添加姓氏文本项和出生日期日期项。
3) 使用以下 SQL 创建报表区域“Purchases”:
CONNECT BY 子句是从 DUAL 生成 5 个虚拟行的技巧。
apex_item
包生成表格表单项 - 在本例中是 item_desc 和 cost 的 2 个文本项,其中 '' 作为初始值。4)创建2个按钮:
提交 - 提交页面
取消 - 重定向到第 6 页
5) 创建了一个在提交时运行的 PL/SQL 流程,如下所示:
我使该流程以“提交”按钮为条件。
apex_application
包包含与表格形式列相对应的数组变量 g_f01、g_f02 等。6) 创建了一个分支,当按下“提交”按钮时,该分支会返回到第 6 页。
如果您想要偏离 Apex 页面和区域向导提供的“开箱即用”行为的功能,您必须编写更复杂的代码,如您所见。但几乎任何你想做的事情都可以通过这种方式完成。
Instead of redirecting to page 2 to enter the Table 2 info you need to submit page 1 and branch to page 2. This will save the session state for page 1. You don't want the page 1 data updated into Table1 yet, so ensure that the process that performs the insert/update is not invoked by this submit - e.g. make it conditional on the Save button or whatever.
Alternatively, do it all on one page like my example here. The page of interest is page 7 which you reach via the Create button. Page 7 has a kind of master/detail form, but I didn't build it using the Apex wizards - I'm not sure whether you could, but I tend not to use the wizards and built-in form-on-table tools in my work, so I am not sure.
This is what I did for page 7:
1) Created a blank page
2) Added an HTML region "New Customer" and added a text item for Surname and a date item for DOB.
3) Created a report region "Purchases" with the following SQL:
The CONNECT BY clause is a trick to generate 5 dummy rows from DUAL. The
apex_item
package generates tabular form items - in this case 2 text items for item_desc and cost, with '' as the initial value.4) Created 2 buttons:
SUBMIT - submits the page
CANCEL - redirects to page 6
5) Created a PL/SQL process to run on submit as follows:
I made that process conditional on the SUBMIT button. The
apex_application
package contains array variables g_f01, g_f02 etc. that correspond to the tabular form columns.6) Created a branch that goes back to page 6 when SUBMIT is pressed.
If you want functionality that deviates from the "out of the box" behaviour provided by Apex's page and region wizards you have to write more complex code, as you can see. But pretty much anything you want to do can by done this way.