日期:2014-05-17 浏览次数:20937 次
EXECUTE IMMEDIATE '(select * from table where code =abc)union all(select * from table where code =bcd)union all(select * from table where code =cde)'
------解决方案--------------------
这条是找括号位置的:
SELECT INSTR('(SELECT * FROM A WHERE CODE IN (SELECT CODE FROM B))', ')') AS POINTLEFT FROM DUAL)
------解决方案--------------------
用存储过程吧:
传入存储过程一个参数:你的SQL语句字符串!
存储过程输出一个结果:游标
------解决方案--------------------
没太看懂你要的结果,给出个过程的结构,自己把逻辑填写在
/*sql处理代码*/这个地方吧。
create or replace procedure test(result_message OUT VARCHAR2) is result_sum varchar2(10); result_avg varchar2(10); result_sqrt varchar2(10); begin /*sql处理代码*/ result_message:=result_sum+result_avg+result_sqrt; end test;
------解决方案--------------------
整个游标
select substrb(rn,instr(rn,'(',1)+1)from (select regexp_substr('sum(abc)+avg(bcd)+sqrt(cde)','[^)]+',1,rownum) rn from dual connect by rownum<=length(regexp_replace('sum(abc)+avg(bcd)+sqrt(cde)','[^)]+')) )
------解决方案--------------------
这个直接一条语句不就返回了吗?加 UNION ALL 啊?
(select * from table where code =abc) UNION ALL (select * from table where code =bcd) UNION ALL (select * from table where code =cde)
------解决方案--------------------
给来个最简单的
select instr('1111112','1',-1) from dual