我写了一个存储过程 传入4个变量 A , B, C ,D
A 开始时间
B 结束时间
C 账单类型
D 是时间点 就是 传入的是2,3,4,5 这样的 时间点字符串 在后面存储过程中我用动态绑定变量。A B C三个变量都能使用。 但是问题出来了
D 的变量采用动态判定结构 a.hour in (:4)
传入后 没有报错 但是 结构结合是 这个 变量没有起作用
最后我没有办法采用的的是拼接的方法
a.hour in ('||D||')
采用这种方式。
不知道大家有没有遇到过这样的问题
为什么动态绑定会出错了
有心得得人 希望能说下 意见。。 谢谢
A 开始时间
B 结束时间
C 账单类型
D 是时间点 就是 传入的是2,3,4,5 这样的 时间点字符串 在后面存储过程中我用动态绑定变量。A B C三个变量都能使用。 但是问题出来了
D 的变量采用动态判定结构 a.hour in (:4)
传入后 没有报错 但是 结构结合是 这个 变量没有起作用
最后我没有办法采用的的是拼接的方法
a.hour in ('||D||')
采用这种方式。
不知道大家有没有遇到过这样的问题
为什么动态绑定会出错了
有心得得人 希望能说下 意见。。 谢谢
create or replace procedure test
as
v_count int;
begin
execute immediate 'select count(*) from emp where deptno in (:1,:2)' into v_count using 10,20;
dbms_output.put_line(v_count);
end;
create or replace procedure test
as
v_count int;
begin
execute immediate 'select count(*) from emp where deptno in (:1,:2)' into v_count using 10,20;
dbms_output.put_line(v_count);
end;
a.s_hour as "时间段",
substr(b.level_cell_dn, 5,20) "小区号" ,
b.zh_label "小区名称",
where a.ne_id =b.ne_cell_id
and a.s_hour in (:1)';
execute immediate sql_select into hours ;--hours 是 1,2,3,4,5这样写 是不能执行正确的
改成 sql_select := 'select to_char(a.START_TIME,''yyyy-mm-dd '') "时间",
a.s_hour as "时间段",
substr(b.level_cell_dn, 5,20) "小区号" ,
b.zh_label "小区名称",
where a.ne_id =b.ne_cell_id
and a.s_hour in ('||hours ||')';
execute immediate sql_select;
格式不能错,引号不能掉。