- 论坛徽章:
- 0
|
有一个表:
ID NAME
--------- --------------------------------------------------------------------------------
1 dinya
2 wjb
3 phs
4 tam
5 tl
我写了一个动态SQL语句查询,结果没总是打印“找不到相应数据!”,请问为什么?
create or replace procedure find_info(p_id number) as
v_id number;
v_name varchar2(20);
begin
execute immediate '
select id,name from dinya_test a
where a.id=:id'
using p_id
returning into v_id,v_name; --动态SQL为查询语句
dbms_output.put_line(v_name ||'的ID为:'||to_char(v_id));
exception
when others then
dbms_output.put_line('找不到相应数据!');
end find_info; |
|