简体   繁体   中英

How to reference a table column value from a foreign key in Page Designer - Source - SQL Expression - Oracle Apex 22.21

I have a table PRODUCTS which keeps all the product data. And I have a table ORDER_ITEMS which keeps all the order items data. ORDER_ITEMS has a column PRODUCT_ID which is a foreign key to PRODUCTS table referencing PRODUCT_ID .

I've created a MASTER DETAIL REPORT page on Apex which shows the ORDER_ITEMS table report.

Right now it's showing PRODUCT_ID . I need the PRODUCT_ID column to show PRODUCT_NAME

报告

MASTER DETAIL REPORT PAGE DESIGNER主从报表页面设计器

PRODUCTS TABLE 产品表

ORDER_ITEMS TABLE ORDER_ITEMS 表

I've tried changing the Source Type to SQL Expression and tried running below but I'm getting an error.

select PRODUCT_NAME from PRODUCTS
where PRODUCT_ID = PRODUCT_ID

ERROR: Ajax call returned server error ORA-01427: single-row subquery returns more than one row for ajax_dispatch_request.

在此处输入图像描述

-------UPDATE-------

Based on Koen's answer, option 1, I've tried the below query but I am still getting the same error.

SELECT PRODUCTS.PRODUCT_NAME
FROM PRODUCTS
INNER JOIN ORDER_ITEMS_LOCAL
ON ORDER_ITEMS_LOCAL.PRODUCT_ID = PRODUCTS.PRODUCT_ID 

在此处输入图像描述

There are many solutions to this question, here are a couple of options:

  1. Modify the source query (select "SQL Query" instead of "Table/View" in "Source Type") of the detail report. Join to the products table and add a the product_name column to the "SELECT" clause

  2. Set the column type to select list and in the query set product_id as return value and product_name as display value. Not that in this case you have a select list

  3. Set the column attributes "Settings > Based On" to "Display Value of List of Values". The List of values can be defined on the page or be a shared component. Now the column will just be text field.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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