create table test1 (t_cloum varchar2(100));
insert into test1 values('123');CREATE OR REPLACE FUNCTION testszz(v_rybh VarChar2) Return VarChar2 As
tc_rysx VarChar2(100) Default NULL;
Begin
select t_cloum into tc_rysx from test1 where t_cloum = v_rybh;
if tc_rysx is not null then
RETURN '123';
else
RETURN '456';
end if;
End testszz;select testszz('789') from dual为什么不走else呢?
insert into test1 values('123');CREATE OR REPLACE FUNCTION testszz(v_rybh VarChar2) Return VarChar2 As
tc_rysx VarChar2(100) Default NULL;
Begin
select t_cloum into tc_rysx from test1 where t_cloum = v_rybh;
if tc_rysx is not null then
RETURN '123';
else
RETURN '456';
end if;
End testszz;select testszz('789') from dual为什么不走else呢?
解决方案 »
- oracle客户端导出服务器数据库的方法,寻解。
- oracl 11g install 问题
- mysql中的表转换成oracle里的
- 帮忙看一下这个ORACLE函数
- 怎样用一条SQL获取同期值和前期值
- 我想请教一下oracle数据升的问题!
- 跪求:SQL number转为Date 或者是相反
- 执行一个package中的存储过程,返回一个游标,怎样把游标当中的每个字段单独取出来?
- 高手请指点ORACLE的会话期系统参数设置问题
- 执行如下语句时:select dxm into ls_dxm_n from jh_gs where gcbh='2';
- 系统重装,怎样将原来的oradata文件恢复到新安装号的数据库
- ORA-27300: OS system dependent operation:CreateThread failed with status: 1455
when no_data_found then
return '789';然后你试试
-- 这种形式
declare
v_count int ;
begin
select count(*) into v_count from user_objects where object_id = 100;
if v_count > 0 then
dbms_output.put_line(100);
else
dbms_output.put_line(100);
end if ;
end ;
tc_rysx VarChar2(100) Default NULL;
Begin
select t_cloum into tc_rysx from test1 where t_cloum = v_rybh;
if tc_rysx is not null then
RETURN '123';
end if;
exception
when no_data_found then
return '456';
End testszz;
--在用select。。into。。给变量赋值时,如果没有返回数据,则会出现no_data_found 的预定义异常
如果返回多条数据, 则会出现too_many_rows 的预定义异常
在你的语句中,v_rybh除了赋值‘123’之外,其他的数值都会引发no_data_found 的预定义异常