我正在使用apex处理Oracle数据库驱动的Web应用程序。有一个P2_ROWS字段,其中包含从源sql查询中定义的数据表中选择的值列表。报表区域上有一个按钮,允许用户按特定顺序对值列表进行排序。为按钮分配动态操作。单击该按钮时,将执行带有查询顺序的PL / SQL,该查询应更改行的显示顺序。
源sql定义为:
select
"PRODUCT_ID",
"PRODUCT_NAME",
"PRODUCT_DESCRIPTION",
"PRICE",
"PRODUCT_LOCATION",
dbms_lob.getlength("THUMBNAIL") as "THUMBNAIL"
from "PRODUCTS"
where
(
instr(upper("PRODUCT_NAME"), upper(nvl(:P2_REPORT_SEARCH, "PRODUCT_NAME"))) > 0
)
分配给按钮的PL / SQL是:
SELECT PRODUCTS.PRODUCT_ID, PRODUCTS.PRODUCT_NAME, PRODUCTS.PRODUCT_DESCRIPTION, PRODUCTS.PRICE, PRODUCTS.PRODUCT_LOCATION, dbms_lob.getlength("THUMBNAIL") as "THUMBNAIL"
INTO :P2_ROWS
FROM PRODUCTS
INNER JOIN TEMP_DISTANCES ON TEMP_DISTANCES.PRODUCT_ID = PRODUCTS.PRODUCT_ID
ORDER BY DISTANCE ASC;
单击该按钮时,应用程序将返回错误" ORA-00947:没有足够的值ORA-06550"。
你会如何解决这个问题?请随时发表评论,并随时提出任何改进建议。感谢。
答案 0 :(得分:0)
正如@Scott所说,您尝试在一个标量变量中选择多个值。您应该定义几个变量或使用连接。
SELECT PRODUCTS.PRODUCT_ID, PRODUCTS.PRODUCT_NAME, PRODUCTS.PRODUCT_DESCRIPTION, PRODUCTS.PRICE, PRODUCTS.PRODUCT_LOCATION, dbms_lob.getlength("THUMBNAIL") as "THUMBNAIL"
INTO :P2_PROID_ID, :P2_PROD_NAME, ...
FROM PRODUCTS
INNER JOIN TEMP_DISTANCES
ON TEMP_DISTANCES.PRODUCT_ID = PRODUCTS.PRODUCT_ID
ORDER BY DISTANCE ASC;
或
SELECT PRODUCTS.PRODUCT_ID || ', ' || PRODUCTS.PRODUCT_NAME || ', ' || PRODUCTS.PRODUCT_DESCRIPTION || ', ' || PRODUCTS.PRICE ...
INTO :P2_ROWS
FROM PRODUCTS
INNER JOIN TEMP_DISTANCES
ON TEMP_DISTANCES.PRODUCT_ID = PRODUCTS.PRODUCT_ID
ORDER BY DISTANCE ASC;