蒙阴天气预报,李恒建陈晓楠生活照,江西财大许嘉丽
1.基本结构
create or replace procedure存储过程名字
(
参数1 in number,
参数2 in number
) is
变量1 integer :=0;
变量2 date;
begin
end 存储过程名字
2.select into statement
将select查询的结果存入到变量中,可以同时将多个列存储多个变量中,必须有一条记录,否则抛出异常(如果没有记录抛出no_data_found)
例子:
begin
select col1,col2 into 变量1,变量2 from typestruct where xxx;
exception
when no_data_found then
xxxx;
end;
...
3.if 判断
if v_test=1 then
begin
do something
end;
end if;
4.while 循环
while v_test=1 loop
begin
xxxx
end;
end loop;
5.变量赋值
v_test := 123;
6.用for in 使用cursor
...
is
cursor cur is select * from xxx;
begin
for cur_result in cur loop
begin
v_sum :=cur_result.列名1+cur_result.列名2
end;
end loop;
end;
7.带参数的cursor
cursor c_user(c_id number) is select name from user where typeid=c_id;
open c_user(变量值);
loop
fetch c_user into v_name;
exit fetch c_user%notfound;
do something
end loop;
close c_user;
8.用pl/sql developer debug
连接数据库后建立一个test window
在窗口输入调用sp的代码,f9开始debug,ctrl+n单步调试
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Oracle字符串函数length、upper、lower、initcap、 concat、instr、replace
网友评论