在 pl/sql 过程中实现水平分段表

implementing horizontally fragmented tables in pl/sql procedure

我在服务器上有两个tables.account,在站点上有两个tables.account,它们具有相同的属性但不同的数据。

创建 TABLE 帐户(
国际会计准则, 余额, 账户类型 varchar2(20), Accbranch varchar2(20), 主键(Accno));

创建 TABLE 帐户 1 (
国际会计准则, 余额, 账户类型 varchar2(20), Accbranch varchar2(20), 主键(Accno));

现在我想制作一个程序,使提款银行 transaction.user 将输入一个帐号,该帐号可能来自帐户 table 或帐户 1 table 和提款金额。然后程序将更新特定 table 中的余额,其中包含用户输入的帐号。 我的代码适用于一个 table.but 无法理解如何处理两个水平分散的 table(account 和 account1)。 谁能建议我找到解决方案的更好方法。 这是我的程序

CREATE OR REPLACE  PROCEDURE test(x IN number, y IN number)
AS
    cur_balance number;
    new_balance number;

BEGIN
    select Balance into cur_balance
    from Account  
    where Accno = x;

if (cur_balance < y)then
    dbms_output.put_line('Insufficient balance');
else
    new_balance:=cur_balance-y;
    update Account
    set Balance = new_balance
    where Accno = x;

end if; 
    dbms_output.put_line('Money has been withdrawn successfully');
    dbms_output.put_line('Current Balance:' || new_balance);
commit;
END;
/ 

检查两个表;如果 accno 不存在,我认为 no_data_found 被引发了。然后检查另一个。

这是一个例子:

CREATE OR REPLACE  PROCEDURE test(x IN number, y IN number)
AS
    cur_balance number;
    new_balance number;
    which_table varchar2(20);
BEGIN
  begin
    select Balance 
      into cur_balance
      from Account 
      where Accno = x;

    which_table := 'account';
  exception
    when no_data_found then
      -- ACCNO wasn't found in ACCOUNT, so - check ACCOUNT1
      select balance
        into cur_balance
        from account1
        where accno = x;

      which_table := 'account1';        
  end;

  if (cur_balance < y)then
     dbms_output.put_line('Insufficient balance');
  else
     new_balance := cur_balance - y;

     if which_table = 'account' then
        update Account
          set Balance = new_balance
          where Accno = x;
     else
        update account1
          set balance = new_balance
          where accno = x;
     end if;

     dbms_output.put_line('Money has been withdrawn successfully');
     dbms_output.put_line('Current Balance:' || new_balance);

     commit;
  end if;  
END;
/