« JOIN用法« »Oracle时间函数 »
oracle 存储过程语法例子
包的定义:
create or replace package myTest
is
type out_cur is ref cursor;
procedure writeCount(codeid in nvarchar2);
procedure testSandyInSert(codeid in nvarchar2,counts out number);
end myTest;

存储过程的定义:
create or replace package body myTest
is
procedure writeCount(codeid in nvarchar2)
is
m_count number;
begin m_count:=0;
select count(1) into m_count from code where code_id = codeid;
dbms_output.put_line('输入参数是'||codeid);
dbms_output.put_line('查询结果是'||m_count);
end;
procedure testSandyInSert(codeid in nvarchar2,counts out number)
is
m_cur out_cur;
m_code_sn nvarchar2(50);
m_code_id nvarchar2(50);
m_code_name nvarchar2(50);
m_insertstr nvarchar2(50);
m_for number:=0;
begin counts:=0;
open m_cur for select code_sn,code_id,code_name from code where code_id= codeid;
loop fetch m_cur into m_code_sn,m_code_id,m_code_name;
exit when m_cur %notfound;
case UPPER(m_code_sn) when 'SP_CTRL_L' then m_code_sn:='0';
when 'dld' then m_code_sn:='1';
else m_code_sn:='3';
end case;
if UPPER(m_code_sn) ='SP_CTRL_L' then dbms_output.put_line('条件成立执行,测试if语句的使用');
else dbms_output.put_line('条件不成立执行,测试if语句的使用');
end if;
m_insertstr:=''''||m_code_sn||''','''||m_code_id||''','''||m_code_name||'''';
begin execute immediate 'insert into sandytest(col1,col2,col3) values('||m_insertstr||')';
dbms_output.put_line('插入表成功!');
counts:=1;
exception when others then dbms_output.put_line('插入表失败!');
end;
end loop;
for m_for in 1..10 loop dbms_output.put_line('循环测试:'||m_for);
end loop;
close m_cur;
end;
end myTest;  


Tags: oracle数据库  sql编程  

原创文章如转载,请注明:转载自:飞扬部落编程仓库 : http://www.busfly.net/csdn/

本文链接地址:http://www.busfly.net/csdn/post/309.html

如果你喜欢本文,请顶一下,支持我,你的支持是我继续发好文章的最大动力。谢谢。
好东西需要分享,快把本文发给你的朋友吧~!~

     
相关文章:
JOIN用法  (2007-11-27 10:2:8)
经典连接查询示例  (2007-11-27 10:1:38)
精妙SQL语句整理  (2007-11-27 10:0:11)
全面接触SQL语法(7)  (2007-11-27 9:57:34)
全面接触SQL语法(6)  (2007-11-27 9:57:0)
全面接触SQL语法(5)  (2007-11-27 9:56:29)
全面接触SQL语法(4)  (2007-11-27 9:56:5)
全面接触SQL语法(3)  (2007-11-27 9:55:33)
全面接触SQL语法(2)  (2007-11-27 9:55:2)
全面接触SQL语法(1)  (2007-11-27 9:54:33)




◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
Feed订阅集
网站分类
勤劳致富^.^
最近发表
最新评论及回复
最近留言
随机推荐文章
Powered By Z-Blog   STYLE by busfly . FatMouse
Copyright © 2007 巴士飞扬技术博客. . 沪ICP备07027972号. 会员群1(VS为主):3769186.