SQL> begin
2 if ' 2 ' = 2 then
3 dbms_output.put_line('hoooooooo');
4 end if;
5 end;
6 /
hooooooooPL/SQL 过程已成功完成。
2 if ' 2 ' = 2 then
3 dbms_output.put_line('hoooooooo');
4 end if;
5 end;
6 /
hooooooooPL/SQL 过程已成功完成。
解决方案 »
- Oracle round函数使用
- 紧急求助,再发一贴,谢谢!
- EA建模工具导出的SQL语句有问题
- 这个top sql的脚本是什么意思呐?
- 求救大牛:安装oracle11gr2_64出现问题,按到85%就开始出错,导致后面安装完成,不能启动。
- ORACLE 的循环语句
- 请问如何进行两个数据库的复杂查询
- 请教这样一个oracle的存储过程怎样写?在jsp/servlet中怎样调用
- 我怎么不能用svrmgrl这个命令?
- 紧急求救!高手请进!
- ====救命啊===,500分求此问题的解决,一次只能开100分 -- SOS
- 存放表结构(字段长度,类型等等)的系统表是什么?另外有没有好的调试SQL存储过程的工具?
2 if ' 2 ' = 2 then
3 dbms_output.put_line('hoooooooo');
4 end if;
5 end;
6 /
hoooooooo
这个也是同样的道理,oracle在编译运行该语句时,把‘ 2 ‘作为字符处理,而不是字符串,所以自动去除多余的空格
x integer;
y integer;
z varchar2(3);
begin
x := 1;
y := 2;
select decode(x,1,decode(y,1,11,'2','12f',3,'13',0),0)
into z
from dual;
dbms_output.put_line(x);
dbms_output.put_line(y);
dbms_output.put_line(z);
end;以上语句中,x是integer型,那理想当然不能符字符型给它.
decode(x,1,decode(y,1,11,'2','12f',3,'13',0),0)
其实相当于:
if x=1 then
x:='12f';
else
x:=0;
end if;而其它也不感奇怪,oracle数据类型是弱类型,可以稳式转换数字型与字符型。
以你的说法那么x 应该等于12而不是1啊
if x =1 then
if y = 1 then
z := 11;
elsif y = 2 then
z := 12;
...
end if
else
z := 0 ;
end if;
如果是那么z := '12f' 应该不报错我主要是这个想不通别的都好理解
相当于:
if x=1 then
if y=1 then
y:=11;
elsif y=2 then
y:='12';
elsif y=3 then
y:='13';
else
y:=0
end if;
x:=y; --函数不是赋值给y,只是理解方便
else
x:=0;
end if;
以你的说法那么x 应该等于12y 也应该等于12而不是1和2啊
to: beckhambobo(beckham)
x:=y; --函数不是赋值给y,只是理解方便看来也只能这么理解了真不知道oracle是怎么实现decode函数的
只有select into 和 = 会改变变量的值,所以x和y不会变
,decode 语句当然不会做这件事2. 隐式类型转换
ORACLE支持隐式类型转换,所以你的字符串可以被数值型变量接受. '12' --> 12
'12Adfd' --> error (那时自然,ORACLE 也不是神仙吗)
要改变列值还是用update语句.
9 into z
10 from dual;
z 是varchar2z := '12f'不应报错的
so '12f' can not be convert to numberic value . (note although the value is not stored in x )
decode(2,1,11,2,'bb')就会出错原因就是根据第三个参数(11)确定了decode的返回值是number型,在把'bb'转换成number时出错了。这大概可以解释你遇到的现象?