【发布时间】:2020-09-14 20:50:03
【问题描述】:
如果今天的日期在表 ABC 的 start_date 和 end_date 之间,我需要编写一个过程来更新表 Xyz 的列。
table ABC
fin_cycle start_date end_date account_class
----------------------------------------------------
F2018 27-05-2020 29-05-20 2003
table xyz
account_no account_class ac_no_dr
1234 2003 Y
当我今天运行程序时,如果今天的日期在表 ABC 的 start_date 和 end 日期之间,那么程序会将列 ac_no_dr 更新为 Y,否则它将更新列为 N。我已经准备了这个框架。
Create Or Replace PROCEDURE pr_no_debit
Cursor c_Today(start_date, end_Date) is
Select Today from sttm_branch where today between start_Date and end_Date;
l_No_Debit_List ABC%ROW_TYPE;
Begin
For c_Today(l_No_Debit_List.start_Date,l_No_Debit_List.end_Date) Loop
Update XYZ set ac_no_DR='Y' where account_class=l_No_Debit_List.account_class;
End Loop;
-- At the end of the period Change No_Debit to 'N'
End pr_no_debit;
【问题讨论】:
-
这段代码没有意义。 l_No_Debit_List 没有值。
-
那么我该如何编写这个程序..请帮助..
-
update XYZ x set ac_no_DR='Y' where (select count(*) from ABC a where a.account_class=x.account_class and trunc(sysdate) between a.start_date and a.end_date) > 0