存储过程中判断变量是否含有一个字符,没有就加入
牧牛人软件 2006-07-27 04:23:51 V_Title Varchar2(200);
V_caption Varchar2(200);
........................
V_Title :='Who are ';
select V_Title || ' you' into V_caption
from dual
where instr(V_Title,'you')=0;
..............................................................................
以上SQL的意思是当V_Title中没有字符'you'时,在V_Title后面加入'you'给 V_caption.
===============================================================================
我要问的是:
1. select V_Title from dual 可行吗? (因为提问时我手头没有ORACLE环境)
2.在存储过程中可以这样用instr()函数.
if instr(V_Title,'you')<0 then -- V_Title中没有'you'
V_caption:= V_Title || ' you'; -- ◆◆为什么始终不到这里来?
end if
3.如果您有其他办法,请您提供。