原来的存储过程如下:
create or replace procedure rpt.prc_js006_tiao
(
year_month varchar2
)
as
do_date varchar(6);
do_year_month varchar2(6);
user_num int;
do_month varchar(2);
begin
do_year_month := to_char(year_month);
do_month := substr(year_month,5,2);
select to_char(sysdate,'yyyymm') into do_date from dual;select count(*) into user_num
from a_02 a where to_char(b.begin_date,'yyyymmdd') <= do_year_month||'31'
and to_char(b.end_date,'yyyymmdd') >= do_year_month||'01';
.....编译成功.现在要将02改成变量do_month
这个select count(*) into user_num
from a_02 a where to_char(b.begin_date,'yyyymmdd') <= do_year_month||'31'
and to_char(b.end_date,'yyyymmdd') >= do_year_month||'01';
这么拼接阿 ?
麻烦给出SQL代码 谢谢哈
create or replace procedure rpt.prc_js006_tiao
(
year_month varchar2
)
as
do_date varchar(6);
do_year_month varchar2(6);
user_num int;
do_month varchar(2);
begin
do_year_month := to_char(year_month);
do_month := substr(year_month,5,2);
select to_char(sysdate,'yyyymm') into do_date from dual;select count(*) into user_num
from a_02 a where to_char(b.begin_date,'yyyymmdd') <= do_year_month||'31'
and to_char(b.end_date,'yyyymmdd') >= do_year_month||'01';
.....编译成功.现在要将02改成变量do_month
这个select count(*) into user_num
from a_02 a where to_char(b.begin_date,'yyyymmdd') <= do_year_month||'31'
and to_char(b.end_date,'yyyymmdd') >= do_year_month||'01';
这么拼接阿 ?
麻烦给出SQL代码 谢谢哈
解决方案 »
- 求解高手,oracle存储过程执行查询的性能
- oracle如果采用表垂直分区的话,是不是可以突破表的1000个字段数的限制?
- RAC中,为什么使用 crs_stat -t 看到的状态 不断变化?
- PLSQL问题,急!
- 关于TOAD添加 TNSNames Editor
- 急急,windows server 2003下,oracle 9i的OracleOraHome92ManagementServer服务启动后又停止了。
- 求一Oracle SQL语句,如果表中的某个字段(char或varchar2型)的所有字符都是些空格,就将它设为NULL,以节省空间
- 多表清空问题
- 为什么我的oracle装不起来?
- ORCALE数据库报表问题--
- 帮忙看看问题
- 我使用oracle 10g数据库,目前我想备份一个叫LAU的数据库
EXECUTE IMMEDIATE
'select count(*)
from a_'||do_month||' a where to_char(b.begin_date,''yyyymmdd'') <='''||do_year_month||'31''
and to_char(b.end_date,''yyyymmdd'') >='''|| do_year_month||'01''' into user_num;
(
year_month varchar2
)
as
do_date varchar(6);
do_year_month varchar2(6);
user_num int;
do_month varchar(2);
sql varchar2(2000);
begin
do_year_month := to_char(year_month);
do_month := substr(year_month,5,2);
select to_char(sysdate,'yyyymm') into do_date from dual;sql:='select count(*) into user_num
from a_'||do_month||' a where to_char(b.begin_date,'''yyyymmdd''') <= 'do_year_month||'''31'''
and to_char(b.end_date,'''yyyymmdd''') >=' do_year_month||'''01''';
.....