oracle form隐藏字段从显示项

oracle form hidden field from the display item

我正在尝试显示或隐藏扩展价格(显示项目)中的减号

table

Transaction Portfolio_Number    PK  Number (7,0)        FK  Not Null
    Stock_Code      Varchar2 (10)       FK  Not Null
    Transaction_Date        Date    Not Null
    Exchange_Code       Varchar2 (4)        FK  Not Null
    Broker_Number       Number (7,0)        FK  Not Null
    Buy_Sell        Char (1)    Not Null
    Quantity        Number (7,0)    Not Null
    Price_Per_Share     Number (6,2)    Not Null

我的显示项目是数量*price_per_share。

如果是买入,则扩展价格将带有减号。 如果是卖出,则扩展价格将带有减号(隐藏该字段?) 一件事是减号意味着它是负面的。因为我会用它来计算扩展总价。 如果你有其他工作方式。也请与我分享。

我不确定我明白你在说什么;示例肯定会有所帮助。

同时:你说:

  • if buy_sell = buy then price_per_share 为负值
  • if buy_sell = sell then...什么?我不知道你写的句子是什么意思:

    then the extended price will be have the minus sign(which hidden the field?)

    在我看来,这与 "buy" 一样。

另外,"extended price total"是什么?

正如我所说:示例和 - 可能 - 改写问题会有所帮助。


同时,看看这是否有帮助:

:block.display_item := case when :block.buy_sell = 'B' then -1
                            when :block.buy_seel = 'B' then  1
                       end * :block.quantity * abs(:block.price_per_share);

表示:不要介意 price_per_share 的符号是什么(正数或负数)- 始终取其绝对值(这就是 abs 函数的作用)。乘以 quantity。通过检查 buy_sell 值来决定使用哪个符号(我假设买入意味着 负值 ,而卖出意味着 正值 )。


如果涉及到两个表,将它们连接起来并select成一个块项(假设上面的代码有意义);像这样:

select sum(case when t.buy_sell = 'B' then -1
                when t.buy_sell = 'S' then  1
           end * t.quantity * abs(t.price_per_share)
          )
into :block.display_item
from transaction t join portfolio p on p.portfolio_number = t.portfolio_number
where t.portfolio_number = :block.portfolio_number;