求各位数据库的高手帮忙注解一下,我是新手才开始学习的!非常感谢!!!
declaresqltext varchar2(8000);
begin
/* sqltext := 'drop table dcl_temp45';
execute immediate sqltext;*/
sqltext := 'create table dcl_temp45 as select acct_id as ' || 'acct_id';
for r_acct_month in (select distinct acct_month from dcl_temp44) loop
sqltext := sqltext || ' , sum(case acct_month when ''' || r_acct_month.acct_month|| ''' then charge else 0 end) as A' || r_acct_month.acct_month|| '';
end loop;
sqltext := sqltext || ' from dcl_temp44 group by acct_id order by acct_id';
-----dbms_output.put_line(sqltext);
execute immediate sqltext;
end;
/