CREATE or replace PROCEDURE wa_input_init
AS
lmonth varchar(4);
strsql varchar(5000);
BEGIN
Delete Input;
Delete Input_Audi;
Select const_value into lmonth from const_data where to_number(const_id) = 121;Update input
Set WaterAvg = nvl(( SELECT AVG( to_number(tb1.waterreal)) From ( SELECT waterpay.waterreal FROM WATERPAY,input Where WATERPAY.UserID = input.userid and rownum<=3 AND WATERPAY.WaterReal > '0' ORDER BY year DESC, UseMonth DESC )tb1 ), 0 );update input
set waterbegin=nvl((select waterpay.waterend from waterpay,input where waterpay.userid=input.userid and rownum<=1 order by year desc,usemonth desc),0)
where input.waterbegin=0;update input
set upwaterreal=nvl((select waterpay.waterreal from waterpay,input where waterpay.userid=input.userid and rownum<=1 order by year desc,usemonth desc),0);update input
set waterend=nvl((select waterpay.waterend from waterpay,input where userid=input.userid and rownum<=1 order by year desc,usemonth desc),0)
where input.waterend=0 and input.audi=-1;
End;
这段程序为什么总是报缺少右括号,为什么?请大家帮忙!!
)和tbl之间加一个空格
楼上说的空格没有这个必要.nvl(( SELECT AVG( to_number(tb1.waterreal)) From ( SELECT waterpay.waterreal FROM WATERPAY,input Where WATERPAY.UserID = input.userid and rownum<=3 AND WATERPAY.WaterReal > '0' ORDER BY year DESC, UseMonth DESC )tb1 ), 0 );
改为
( SELECT NVL(AVG( to_number(tb1.waterreal)),0) From ( SELECT waterpay.waterreal FROM WATERPAY,input Where WATERPAY.UserID = input.userid and rownum<=3 AND WATERPAY.WaterReal > '0' ORDER BY year DESC, UseMonth DESC )tb1 )
这种写法试试!