1.首先创建包头:
create or replace package pa_test_cursor is
-- Author : ADMINISTRATOR
-- Created : 2012-8-30 下午 02:52:24
-- Purpose :
-- Public type declarations
function getCall return varchar2;
procedure caculateCallFee(cur_in_call in sms_temp%rowtype,result out varchar );
end pa_test_cursor;
2.然后是包体
create or replace package body pa_test_cursor is
-- Function and procedure implementations
function getCall return varchar2 is
temp_cur sms_temp%rowtype;
result varchar2(20);
cursor cur_sms_temp is
select * from SMS_TEMP;
begin
open cur_sms_temp;
fetch cur_sms_temp into temp_cur;
while cur_sms_temp%found
loop
caculateCallFee(temp_cur,result);
fetch cur_sms_temp into temp_cur;
result:='success';
end loop;
close cur_sms_temp;
return result;
end;
procedure caculateCallFee(cur_in_call in sms_temp%rowtype,result out varchar )
is
begin
dbms_output.put_line(cur_in_call.id||';'||cur_in_call.msg_content);
end;
end pa_test_cursor;
本文介绍了一个Oracle PL/SQL包的创建及其使用过程,包括包头与包体的定义。通过具体示例展示了如何利用游标进行数据检索及处理,特别是针对SMS_TEMP表中的数据进行操作。
2616

被折叠的 条评论
为什么被折叠?



