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 过程已成功完成。
解决方案 »
- 求助, 这个sqlserver语句用oracle怎么写??
- 这样的sql怎么写?
- 使用loader 为什么第一行的数据导不进去表中?
- 在线等啊``快来帮我!关于分页
- ora-01219数据库未打开:仅允许在固定表/视图中查询
- 怎么使用C/C++开发Oracle的存储过程?
- 关于日期格式的问题
- 如何在以system 连接后,创建其他用户,然后在创建的其他用户地下建表?
- 安装oracle9的时候,为什么总是出现”加载数据库时出错“的对话框??急急急急!!
- oracle805 建立用户出现的问题,帮忙
- ====救命啊===,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时出错了。这大概可以解释你遇到的现象?