一个单独可执行的SQL语句没有错误:如下计算月变化率的语句在存储过程中就不能使用,first_value或sum() over(...) 等分析函数,有什么原因,有谁知道?(如果去掉 into l_chg_scale_buffer ,放到sql*plus就可以使用)
select f_month,
(end_value-begin_value)/begin_value as chg_scale
into l_chg_scale_buffer
from
(
select distinct
to_char(fdate,'yyyymm') as f_month,
first_value(fclose) over (partition by to_char(fdate,'yyyymm') order by fdate asc rows between unbounded preceding and unbounded following) as begin_value,
last_value(fclose) over (partition by to_char(fdate,'yyyymm') order by fdate asc rows between unbounded preceding and unbounded following) as end_value
from R_ZX_HYZSB
where fhydm='998000'
)
where f_month='200405'
analytic functions (such as CORR and LAG) are not built into PL/SQL, you can use
them in SQL statements (but not in procedural statements).