oracle 根据参数设置APEX选择列表默认值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13497495/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:16:37  来源:igfitidea点击:

Setting APEX select list default value based on parameter

oracleoracle-apexselectlist

提问by Marcus Culver

I have an Apex page with a select list item populated from a SQL query that should default to the product of the item passed through from another page, however it always selects the first item in the list.

我有一个 Apex 页面,其中有一个从 SQL 查询填充的选择列表项目,该项目应该默认为从另一个页面传递的项目的产品,但是它总是选择列表中的第一个项目。

We need to set it so it selects the current category however I can't see where this setting is. The version of APEX is 3.2.

我们需要对其进行设置,以便它选择当前类别,但是我看不到此设置的位置。APEX 的版本是 3.2。

采纳答案by Jeffrey Kemp

Firstly, I suspect (correct me if I'm wrong) that your item is selecting the first item because the item is defined with Display Null Valueset to No; internally, however, the item is probably NULL, but the list item cannot show it so it just shows the first list value. But I probably wouldn't change this setting.

首先,我怀疑(如果我错了,请纠正我)您的项目正在选择第一个项目,因为该项目定义为Display Null Valueset No; 然而,在内部,该项目可能是NULL,但列表项目无法显示它,因此它只显示第一个列表值。但我可能不会改变这个设置。

To set the default value for a Select List item, set Default Value Typeto PL/SQL Function Body, then enter your SQL query (that returns a single value) in the Defaultattribute for the item, with suitable PL/SQL around it, e.g.:

要为 Select List 项设置默认值,设置Default Value TypePL/SQL Function Body,然后在该项的Default属性中输入您的 SQL 查询(返回单个值),并在其周围使用合适的 PL/SQL,例如:

DECLARE
  v_value VARCHAR2(<your data max length>);
BEGIN
  SELECT <yourcolumn>
  INTO v_value
  FROM <yourquery>;
  RETURN v_value;
END;