表结构:
id name re
---------------------
a ha 标记
a wo null
a me null
d co null
--------------------
存储过程:
create or replace procedure Get
(
Ids IN VARCHAR2,
Out_Cursor OUT sys_refcursor
)
as
begin
open Out_Cursor FOR
select * from table where id=ids;
end;
------------------------------------
测试结果:ids-〉a
id name re
---------------------
a ha 标记
a wo null
a me null
d co null
-------------------
为什么会出现这样的结果呢?明明参数传人的是a却把id为d的也查出来了,请问这是怎么回事?
id name re
---------------------
a ha 标记
a wo null
a me null
d co null
--------------------
存储过程:
create or replace procedure Get
(
Ids IN VARCHAR2,
Out_Cursor OUT sys_refcursor
)
as
begin
open Out_Cursor FOR
select * from table where id=ids;
end;
------------------------------------
测试结果:ids-〉a
id name re
---------------------
a ha 标记
a wo null
a me null
d co null
-------------------
为什么会出现这样的结果呢?明明参数传人的是a却把id为d的也查出来了,请问这是怎么回事?
(
ID VARCHAR2(20),
NAME VARCHAR2(20),
re VARCHAR2(20)
);INSERT INTO T192 VALUES('a', 'ha', '标记');
INSERT INTO T192 VALUES('a', 'wo', NULL);
INSERT INTO T192 VALUES('a', 'me', NULL);
INSERT INTO T192 VALUES('d', 'co', NULL);
COMMIT;
存储过程:create or replace procedure Get
(
Ids IN VARCHAR2,
Out_Cursor OUT sys_refcursor
)
as
begin
open Out_Cursor FOR select * from T192 where id = ids;
end;
测试代码:DECLARE
vCur SYS_REFCURSOR;
r T192%ROWTYPE;
begin
-- Call the procedure
get(ids => :ids, Out_Cursor => vCur);
LOOP
FETCH vCur INTO r;
EXIT WHEN vCur%NOTFOUND;
dbms_output.put_line(r.id || ', ' || r.name || ', ' || r.re);
END LOOP;
dbms_output.put_line('');
end;
测试结果: