strsql:='select a.user_name from fnd_user a where a.user_id=:p_id';
open rc for strsql using p_id;参考这个修改你的语句strsql:='Select vc_itemno,
sum(decode(vc_xun||''''||vc_month,''a''||''''||''||:basemonths||'',nu_salenum,Null)) 销售数量,
Sum(decode(vc_month,''||:lastmonths||'',nu_salesum,Null)) 上月合计
From t_middle_trans_basemonthsale
Group By vc_itemno';
open p_rc for strsql using lastmonths,basemonths;
end get;
end pack_daili
open rc for strsql using p_id;参考这个修改你的语句strsql:='Select vc_itemno,
sum(decode(vc_xun||''''||vc_month,''a''||''''||''||:basemonths||'',nu_salenum,Null)) 销售数量,
Sum(decode(vc_month,''||:lastmonths||'',nu_salesum,Null)) 上月合计
From t_middle_trans_basemonthsale
Group By vc_itemno';
open p_rc for strsql using lastmonths,basemonths;
end get;
end pack_daili
sum(decode(vc_xun||vc_month,''a''||:basemonths,nu_salenum,Null)) 销售数量,
Sum(decode(vc_month,:lastmonths,nu_salesum,Null)) 上月合计
From t_middle_trans_basemonthsale
Group By vc_itemno';
CREATE OR REPLACE PACKAGE Body pack_daili_monthsale
as
procedure get(lastmonths Varchar2,basemonths Varchar2,p_rc Out mycur)
Is
strsql varchar2(8000);
begin
strsql:='Select vc_itemno,
sum(decode(vc_xun||vc_month,''a''||:basemonths,nu_salenum,Null)) 上旬销售数量,
sum(decode(vc_xun||vc_month,''a''||:basemonths,nu_salesum,Null)) 上旬销售金额,
sum(decode(vc_xun||vc_month,''a''||:basemonths,nu_salesum,Null))/sum(decode(vc_xun||vc_month,''c''||:lastmonths,nu_salesum,Null)) As 增长比,
sum(decode(vc_xun||vc_month,''b''||:basemonths,nu_salenum,Null))中旬销售数量,
sum(decode(vc_xun||vc_month,''b''||:basemonths,nu_salesum,Null)) 中旬销售金额,
sum(decode(vc_xun||vc_month,''b''||:basemonths,nu_salesum,Null))/sum(decode(vc_xun||vc_month,''a''||:basemonths,nu_salesum,Null)) As 增长比,
sum(decode(vc_xun||vc_month,''c''||:basemonths,nu_salenum,Null)) 下旬销售数量,
sum(decode(vc_xun||vc_month,''c''||:basemonths,nu_salesum,Null)) 下旬销售金额,
sum(decode(vc_xun||vc_month,''c''||:basemonths,nu_salesum,Null))/sum(decode(vc_xun||vc_month,''b''||:basemonths,nu_salesum,Null)) As 增长比,
Sum(decode(vc_month,:basemonths,nu_salesum,Null)) 本月合计,From t_middle_trans_basemonthsale
Group By vc_itemno';
open p_rc for strsql using lastmonths,basemonths;
end get;
end pack_daili_monthsale;
using后面的参数要与SQL中的参数一一对应。
sum(decode(vc_xun||vc_month,''a''||:basemonths,nu_salenum,Null)) 销售数量,
Sum(decode(vc_month,:lastmonths,nu_salesum,Null)) 上月合计
From t_middle_trans_basemonthsale
Group By vc_itemno';过客,最后一个问题了,我的basemonths是varchar2型的,要是找你这种写法,能够运行通过,可是执行的时候没有数据。我总是拼接不对,能不能看看到底应该怎么拼接啊?