oracle存储过程中怎么把参数传入表名中
createorreplaceprocedureSZ_YM_HWLTJHZ(s_dateinvarchar2)asv_datevarchar2(6);v_dayvarch...
create or replace procedure SZ_YM_HWLTJHZ (s_date in varchar2)
as
v_date varchar2(6);
v_day varchar2(2);
v_month varchar2(2);
v_sql varchar2;
begin
v_date:=substr(s_date,1,6);
v_day:=substr(s_date,7,2);
v_month:=substr(s_date,5,2);
v_sql:='insert into sz_ym_hwltj_'||v_date||
'(
-----市话
select 'sh','朔州新局D1',start_date,count(distinct msisdn),count(*),sum
(discount_cfee)/1000,sum(trunc((call_duration+59)/60)) from
(select * from ucr_sz1.tg_cdr||v_month_fix@dblnk_ngbil
union all
select * from ucr_sz2.tg_cdr||v_month_fix@dblnk_ngbil)
where msc in ('34917','34918')
and reserver1 in
(110,112,113,114,115,123,125,128,129,160,161,163,164,165,170,172,173,178,
350,352,354,356,358,311,312,314,316,304)
and trunk_groupin in ('0203','0205') and
partition_id=v_day
group by start_date
)';
EXECUTE IMMEDIATE V_SQL;
commit;
end SZ_YM_HWLTJHZ;
高手给看看哪里有问题,怎么改,我想把参数传入表名中 展开
as
v_date varchar2(6);
v_day varchar2(2);
v_month varchar2(2);
v_sql varchar2;
begin
v_date:=substr(s_date,1,6);
v_day:=substr(s_date,7,2);
v_month:=substr(s_date,5,2);
v_sql:='insert into sz_ym_hwltj_'||v_date||
'(
-----市话
select 'sh','朔州新局D1',start_date,count(distinct msisdn),count(*),sum
(discount_cfee)/1000,sum(trunc((call_duration+59)/60)) from
(select * from ucr_sz1.tg_cdr||v_month_fix@dblnk_ngbil
union all
select * from ucr_sz2.tg_cdr||v_month_fix@dblnk_ngbil)
where msc in ('34917','34918')
and reserver1 in
(110,112,113,114,115,123,125,128,129,160,161,163,164,165,170,172,173,178,
350,352,354,356,358,311,312,314,316,304)
and trunk_groupin in ('0203','0205') and
partition_id=v_day
group by start_date
)';
EXECUTE IMMEDIATE V_SQL;
commit;
end SZ_YM_HWLTJHZ;
高手给看看哪里有问题,怎么改,我想把参数传入表名中 展开
1个回答
展开全部
这样试试:
v_sql:='insert into sz_ym_hwltj_'||v_date||
'(
-----市话
select ''sh'',''朔州新局D1'',start_date,count(distinct msisdn),count(*),sum
(discount_cfee)/1000,sum(trunc((call_duration+59)/60)) from
(select * from ucr_sz1.tg_cdr||v_month_fix@dblnk_ngbil
union all
select * from ucr_sz2.tg_cdr||v_month_fix@dblnk_ngbil)
where msc in (''34917'',''34918'')
and reserver1 in
(110,112,113,114,115,123,125,128,129,160,161,163,164,165,170,172,173,178,
350,352,354,356,358,311,312,314,316,304)
and trunk_groupin in (''0203'',''0205'') and
partition_id=v_day
group by start_date
)';
v_sql:='insert into sz_ym_hwltj_'||v_date||
'(
-----市话
select ''sh'',''朔州新局D1'',start_date,count(distinct msisdn),count(*),sum
(discount_cfee)/1000,sum(trunc((call_duration+59)/60)) from
(select * from ucr_sz1.tg_cdr||v_month_fix@dblnk_ngbil
union all
select * from ucr_sz2.tg_cdr||v_month_fix@dblnk_ngbil)
where msc in (''34917'',''34918'')
and reserver1 in
(110,112,113,114,115,123,125,128,129,160,161,163,164,165,170,172,173,178,
350,352,354,356,358,311,312,314,316,304)
and trunk_groupin in (''0203'',''0205'') and
partition_id=v_day
group by start_date
)';
更多追问追答
追问
不好意思,我没看出来改了哪里,而且替换以后依旧不行
追答
把你的 字符中的 一个单引号,改成了 2个单引号,
保证你 的 最后的sql语句 的 字符值 是用单引号引起来的。
光点科技
2023-08-15 广告
2023-08-15 广告
通常情况下,我们会按照结构模型把系统产生的数据分为三种类型:结构化数据、半结构化数据和非结构化数据。结构化数据,即行数据,是存储在数据库里,可以用二维表结构来逻辑表达实现的数据。最常见的就是数字数据和文本数据,它们可以某种标准格式存在于文件...
点击进入详情页
本回答由光点科技提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询