简体   繁体   English

Oracle APEX-交互式网格设置

[英]Oracle APEX - Interactive Grid Set-Up

I am using Oracle APEX 18.2.0.00.12 on Google Chrome and I have a question regarding the best/preferred way to set up an Interactive Grid using the following requirements: 我在Google Chrome上使用Oracle APEX 18.2.0.00.12,并且对使用以下要求来设置交互式网格的最佳/首选方式有疑问:

Note: To simplify the question, I will use fake table names and table column names to represent the problem. 注意:为简化问题,我将使用伪造的表名和表列名来表示问题。

I have an EMP table that looks something like the following: 我有一个EMP表,看起来像以下内容:

First_Name Last_Name Dept_Code Dept_Name 名字姓氏部门代码部门名称

John                Smith

Jane                 Doe            

In this table, there are several rows of data, but there is only data in the First_Name and Last_Name columns. 在此表中,有几行数据,但是First_Name和Last_Name列中只有数据。 There is no data in the Dept_Code and Dept_Name columns. Dept_Code和Dept_Name列中没有数据。

I also have a DEPT table that looks something like the following: 我还有一个DEPT表,看起来像下面这样:

Dept_Code Dept_Name 部门代码部门名称

1234 Finance 1234金融

5678 Logistics 5678物流

In this table, there are several rows of data, and the data exists in both columns. 在此表中,有几行数据,并且这两列中都存在数据。

I want to set up an Interactive Grid based on the EMP table that contains all of the columns in that table, but the Dept_Name column would be Display Only. 我想基于包含该表中所有列的EMP表设置一个交互式网格,但是Dept_Name列将是“仅显示”。 So, the query for the IG would be something like 因此,对IG的查询将类似于

SELECT *  
FROM EMP;  

The problem: I want the user to be able to enter the department code of the employee in the Dept_Code column of the IG. 问题:我希望用户能够在IG的Dept_Code列中输入员工的部门代码。 When the user clicks save, I want the Department Code to be saved in the Dept_Code column of the EMP table for that row and the Dept_Name column of the IG for that row to auto-populate with the corresponding Department Name from the DEPT table. 当用户单击“保存”时,我希望将部门代码保存在该行的EMP表的Dept_Code列中,并将该行的IG的Dept_Name列保存为DEPT表中的相应部门名称。 Then I want that Department Name to be saved in the Dept_Name column of that row of the EMP table. 然后,我希望将该部门名称保存在EMP表的该行的Dept_Name列中。

For example, the IG would look like: 例如,IG看起来像:

First_Name Last_Name Dept_Code Dept_Name 名字姓氏部门代码部门名称

John                Smith

Jane                 Doe    

If the user inputs 5678 as the Dept_Code for John Smith in the IG and then clicks save, I want 5678 to be saved in the Dept_Code column for that that row in the EMP table, then I want the Dept_Name column of that row in the IG to auto-populate with Logistics (this data is pulled from the DEPT table) and also for the Dept_Name column of that row in the EMP table to contain Logistics. 如果用户在IG中输入5678作为John Smith的Dept_Code,然后单击“保存”,我希望将5678保存在EMP表中该行的Dept_Code列中,那么我希望IG中该行的Dept_Name列以自动填充后勤(此数据是从DEPT表中提取的),也用于EMP表中该行的Dept_Name列以包含后勤。

So the final result would be: 因此最终结果将是:

EMP table: EMP表:

First_Name Last_Name Dept_Code Dept_Name 名字姓氏部门代码部门名称

John                Smith              5678              Logistics

Jane                 Doe   

IG: IG:

First_Name Last_Name Dept_Code Dept_Name 名字姓氏部门代码部门名称

John                Smith              5678              Logistics

Jane                 Doe 

Does anyone know the best way to set this up? 有谁知道最好的设置方法?

Thank you. 谢谢。

One option is to create a function which will return department name (code would be the parameter), eg 一种选择是创建一个函数,该函数将返回部门名称(代码将是参数),例如

create or replace function f_dept_name (par_dept_code in dept.dept_code%type)
  return dept.dept_name%type
is
  retval dept.dept_name%type;
begin
  select dept_name
    into retval
    from dept
    where dept_code = par_dept_code;

  return retval;
end;

Then create an interactive grid using such a query: 然后使用这样的查询创建一个交互式网格:

select first_name, 
       last_name,
       dept_code, 
       f_dept_name(dept_code) dept_name
from emp

Go to columns' properties and - for dept_name (which is returned by a function) - set query only property to yes (you'll find it within the "Source" group of properties). 转到列的属性,然后-对于dept_name (由函数返回),将only query属性设置为yes (您可以在“ Source”属性组中找到它)。

That should do it. 那应该做。

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

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