ORACLE中使用動(dòng)態(tài)游標(biāo)的例子
create or replace function get_ope_popedom(sta_id varchar2) return varchar2
/*
* NAME:
* get_ope_popedom
*
* PARAMETER:
* sta_id - 車站編號(hào),多個(gè)站時(shí)以逗號(hào)分隔
*
* RETURN:
* --對(duì)應(yīng)車站編號(hào)的車站名稱,多個(gè)站時(shí)以逗號(hào)分隔
*
* AUTHOR:
* 舵手
*
* DESCRIPTION:
* --根據(jù)傳入的車站編號(hào)返回相應(yīng)的車站名稱
*
*/
as
Result varchar2(1000);
name_temp varchar2(40);
type cursor_t is ref cursor;
emp_cur cursor_t ;
begin
OPEN emp_cur FOR 'SELECT sta_name FROM station_code where sta_code =:1'
using sta_id;
LOOP
FETCH emp_cur INTO name_temp;
If (emp_cur%NOTFOUND) Then
EXIT;
End if;
Result := Result || name_temp || ',';
end loop;
close emp_cur;
Result := substr(Result,1,(length(Result)-1));
return(Result);
end get_ope_popedom;
/
/*
* NAME:
* get_ope_popedom
*
* PARAMETER:
* sta_id - 車站編號(hào),多個(gè)站時(shí)以逗號(hào)分隔
*
* RETURN:
* --對(duì)應(yīng)車站編號(hào)的車站名稱,多個(gè)站時(shí)以逗號(hào)分隔
*
* AUTHOR:
* 舵手
*
* DESCRIPTION:
* --根據(jù)傳入的車站編號(hào)返回相應(yīng)的車站名稱
*
*/
as
Result varchar2(1000);
name_temp varchar2(40);
type cursor_t is ref cursor;
emp_cur cursor_t ;
begin
OPEN emp_cur FOR 'SELECT sta_name FROM station_code where sta_code =:1'
using sta_id;
LOOP
FETCH emp_cur INTO name_temp;
If (emp_cur%NOTFOUND) Then
EXIT;
End if;
Result := Result || name_temp || ',';
end loop;
close emp_cur;
Result := substr(Result,1,(length(Result)-1));
return(Result);
end get_ope_popedom;
/
posted on 2006-03-14 11:02 舵手 閱讀(3581) 評(píng)論(0) 編輯 收藏