我正在编写一个存储过程来从表 add_files_tables 中检索匹配的文件位置。我正在使用带有 ref 光标的 case 语句来获取结果集,然后将打印文件名。我已经创建了包,但它总是给我空集。问题出在哪里 。
create or replace package search_cur as
type my_cursor is ref cursor;
function search_File(FILE_NAME varchar2,opt number) return my_cursor;
end search_cur;
/
create or replace package body search_cur as
function search_File(FILE_NAME varchar2,opt number) return my_cursor is
ret my_cursor;
begin
Case opt
when 1 THEN
OPEN ret FOR
select file_location
from add_files_details
where upper(username) like '%'||file_Name||'%'
;
return ret;
when 2 THEN
OPEN ret FOR
select file_location
from add_files_details
where upper(EXTENSION) like '%'||file_name||'%'
;
return ret;
WHEN 3 THEN
OPEN ret FOR
select file_location
from add_files_details
where upper(UPLOAD_DATE) like '%'||file_name||'%'
;
return ret;
WHEN 4 THEN
OPEN ret FOR
select file_location
from add_files_details
where upper(FOLDER_ID) like '%'||file_name||'%';
return ret;
when 5 then
open ret for
select file_location
from add_files_details
where upper(file_name) like '%'||file_name||'%';
return ret;
end case;
end search_file;
end search_cur;
/