简体   繁体   English

在 Oracle Apex 中显示或插入 SQL 结果

[英]Show or insert a SQL result in Oracle Apex

I have the next code我有下一个代码

select
  MULTIMEDIA_COMPONENTES_HMI.COSTO * :P4_CANTIDAD,
  MULTIMEDIA_COMPONENTES_HMI.COSTO * :P4_CANTIDAD as COSTO
from MULTIMEDIA_COMPONENTES_HMI 
where num=:P4_COSTO;

I want to show in a textbox the result or directly insert the result in the database when the create button is press.我想在文本框中显示结果或在按下创建按钮时直接将结果插入到数据库中。 How can I do this or what type of element should I use to show the result?我该怎么做或者我应该使用什么类型的元素来显示结果?

There are more than one Solution for this question.这个问题有不止一种解决方案。 If you want to load the values to the textbox as the Query is executet, and display the result immediately for the user, you have to use a Dynamic Action, triggered by a Button or a value Change Event on the Items you referred to: P4_CANTIDAD or P4_COSTO.如果要在执行查询时将值加载到文本框,并立即为用户显示结果,则必须使用动态操作,由您引用的项目上的按钮或值更改事件触发:P4_CANTIDAD或 P4_COSTO。 This Dynamic Action could have a TRUE Trigger with a execute PL/SQL Code Action.此动态操作可以有一个带有执行 PL/SQL 代码操作的 TRUE 触发器。

The PL/SQL Query could do Something like display all the changed data, and insert the new information in the database. PL/SQL 查询可以做一些事情,比如显示所有更改的数据,并在数据库中插入新信息。

select
  MULTIMEDIA_COMPONENTES_HMI.COSTO * :P4_CANTIDAD into :P4_TEXTBOX
from MULTIMEDIA_COMPONENTES_HMI 
where num=:P4_COSTO;

Insert into MULTIMEDIA_COMPONENTES_HMI 
(COSTO)
values
(:P4_COSTO);

When you create a Dynamic Action, you have to enter the Items to Submit and Items to Return below the PL/SQL Code Textarea, to set the correct Session State without submitting the complete page.创建动态操作时,必须在 PL/SQL 代码文本区域下方输入要提交的项目和要返回的项目,以设置正确的会话状态,而无需提交完整页面。

Another solution without the Dynamic Action would be to simply create a Page process after Submit and Insert your Data to The Database.另一个没有动态操作的解决方案是在提交数据并将数据插入数据库后简单地创建一个页面进程。 Then create a Page Process After Header an refil your Items with the new values from the Database, or defining the Select Into statement in the Source Region of your Item.然后在页眉后创建一个页面处理,使用数据库中的新值重新填充您的项目,或者在您的项目的源区域中定义 Select Into 语句。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM