我写了个存贮过程,其中有个隐式游标
for curl in (Select repo_code,repo_module,repo_name,sts From repo_tm
Where sts='A' And repo_code = nrepo_kind1
and repo_module =nrepo_kind2
Order By repo_code )
其中nrepo_Kind1,nrepo_kind2是存贮过程中的变量,如果要实现查询条件动态,如实现结果为 repo_module in('11','12') and repo_code Not In ('9901','9902','9977'),也就是说实现nrepo_kind1,nrepo_kind2动态,可能有时为in 有时为= 有时为like ,在存贮过程中应该如何编写呢?
请大大们多多指教!
for curl in (Select repo_code,repo_module,repo_name,sts From repo_tm
Where sts='A' And repo_code = nrepo_kind1
and repo_module =nrepo_kind2
Order By repo_code )
其中nrepo_Kind1,nrepo_kind2是存贮过程中的变量,如果要实现查询条件动态,如实现结果为 repo_module in('11','12') and repo_code Not In ('9901','9902','9977'),也就是说实现nrepo_kind1,nrepo_kind2动态,可能有时为in 有时为= 有时为like ,在存贮过程中应该如何编写呢?
请大大们多多指教!
解决方案 »
- 存储过程_错误
- 关于触发器,这个要求能实现吗?
- 索引使用问题
- 求助啊,谁有OCI函数的文档啊,能不能给我一份看看啊
- 郁闷中!!如何把数据添加到LONG类型定义的字段中??????????
- SQL> startup mountORA-12514: TNS: 监听进程不能解析在连接描述符中给出的 SERVICE_NAME
- 谁有Oracle10g的文档?
- 求ORACLE的函数集,不要什么超星的,希望能够方便查看查询的
- CENTOS6.7安装 11个乱码,求解决!
- PL/SQL Developer 连接不上,求助
- 急!!!!!!!!
- oracle数据库里如何关闭ResultSet 、preparedStatement、Statement
and instr(nrepo_kind2,repo_module)>0;
...
sqlstr:='Select repo_code,repo_module,repo_name,sts ';
sqlstr:=sql||'From repo_tm ';
sqlstr:=sql||'Where sts=:v1 ';
sqlstr:=sql||'And repo_code '||condition_str1; -- 修改此处的查询条件
sqlstr:=sql||'and repo_module'||condition_str2;-- 修改此处的查询条件
sqlstr:=sql||'Order By repo_code';open curl for sqlstr using xxx;
loop
fetch cur1 into xxx,xxx,...;
exit when cur1%notfound;
...
end loop;
close cur1;
...
njhart2003() 兄的方法可以试试!
----------
1已用时间: 00: 00: 00.31
SQL> select 1 from dual where instr('''111'',''222''','''111''')>0; 1
----------
1已用时间: 00: 00: 00.10
SQL>
效果相同,但是只有第二种才可以用于动态sql中达到in语句同样的效果。
njhart2003() 兄的方法也可行,谢谢!