oracle 我得到错误:06550. 00000-"第% s行,第% s列:\n % s"* 原因:通常是PL/SQL编译错误

qpgpyjmq  于 2023-03-01  发布在  Oracle
关注(0)|答案(1)|浏览(195)

我是甲骨文的新手。我有三个表。我想从连接tbl_ledger,tbl_ledger_分支插入到表tbl_ledger_branch我的代码是:

DECLARE 
STARTDATE DATE := MIN (EFF_DATE );
ENDDATE  DATE  := MAX (EFF_DATE ) ;
i DATE ;

BEGIN

for  i  in  SATARTDATE .. ENDDATE  LOOP

insert  into   tbl_ledger_branch (ledger_code , name , depth , parent_code , balance , ref_cur_id , eff_date , ref_branch , cur_balance , number_date ) 

select  a.ledger_code  ,  max( b.name ) name  ,  max(b.depth)  depth  , max(CONCAT(SUBSTR(b.LEDGER_CODE,1,9),'00')) PARENT_CODE  ,  sum(a.balance) balance  ,

i  eff_date , a.ref_branch , a.cur_balance   

from   tbl_ledger_input  a  inner join  tbl_ledger b 

on   a.ledger_code = b.ledger_code

where  eff_date <= i 

group by  a.ref_branch ,a.ref_cur_id ,a.ledger_code  , a.cur_balance ;

END LOOP ;

END ;

但我得到了一个错误

06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.

请帮帮我。

rjee0c15

rjee0c151#

根据你的数据,我想出了下面,它不是完美的,但至少你可以开始与此SQL。

insert into tbl_ledger_branch
      (ledger_code,
       name,
       depth,
       parent_code,
       balance,
       ref_cur_id,
       eff_date,
       ref_branch,
       cur_balance,
       number_date)
      with dates as
       (SELECT max(EFF_DATE) start_date, max(EFF_DATE) end_date
          from tbl_ledger_input a)
      
      select a.ledger_code,
             max(b.name) name,
             max(b.depth) depth,
             max(CONCAT(SUBSTR(b.LEDGER_CODE, 1, 9), '00')) PARENT_CODE,
             sum(a.balance) balance,
             a.ref_cur_id,
             a.eff_date,
             a.ref_branch,
             a.cur_balance,
             a.eff_date
        from tbl_ledger_input a, tbl_ledger b, dates c
       where a.ledger_code = b.ledger_code
         AND a.eff_date >= c.start_date
         AND a.eff_date <= c.end_date
       group by a.ref_branch,
                a.ref_cur_id,
                a.ledger_code,
                a.cur_balance,
                a.eff_date;

相关问题