首页 > 解决方案 > oracle Form Alert syntax

问题描述

I want show alert when the Investor has not any transaction

Tables:

Investor    
Investor_Number PK  Number (7,0)    Not Null
    First_Name      Varchar2 (25)   Not Null
    Last_Name       Varchar2 (30)   Not Null
    Account_Number      Number (7,0)        FK  Not Null

Portfolio   
    Portfolio_Number    PK  Number (7,0)    Not Null
    Investor_Number     Number (7,0)        FK  Not Null
    Portfolio_Description       Varchar2 (50)   Null

Transaction 
    Portfolio_Number    PK  Number (7,0)        FK
    Stock_Code      Varchar2 (10)       FK
    Transaction_Date        Date
    Exchange_Code       Varchar2 (4)        FK
    Broker_Number       Number (7,0)        FK
    Buy_Sell        Char (1)

DECLARE

    V_count number;
BEGIN

select count(portfolio_number)
into V_count
FROM Transaction
where portfolio_number = :PORTFOLIO.portfolio_number;

    If  V_count = null then 
        Message('No Transaction');
    End if;
END;

The code above not work, i don't know the syntax.

now I am using post-query at block level, when the Investor have not any Transaction will show an alert. Two block display "Investor" and "Portfolio". How it work is when click the next record, the record if has not any transaction, it will pop up an alert.

标签: oraclealertoracleforms

解决方案


假设您编写的查询正常工作,则需要进行两项更改:

  • COUNT不会回来NULL;即使它会,你会使用if v_count is null,而不是if v_count = null
  • 连续两次MESSAGE调用将强制 Forms 在屏幕上的弹出窗口中显示消息;如果您只使用一个MESSAGE,它将显示在屏幕底部的状态行中
    • 或者,看看真正的警报是如何工作的;但是是的 - 2 MESSAGEs 更简单

DECLARE
  V_count number;
BEGIN
  select count(portfolio_number)
    into V_count
    FROM Transaction
    where portfolio_number = :PORTFOLIO.portfolio_number;

  If  V_count = 0 then           --> COUNT never returns NULL
     Message('No Transaction');  --> 2 consecutive MESSAGE calls to "simulate" an alert
     Message('No Transaction');   
  else
     Message('Number of transactions = ' || to_char(v_count));   
     Message('Number of transactions = ' || to_char(v_count));   
  End if;
END;

推荐阅读