Oracle%ignore_a_1%基本语法学习入门必备
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单步调试
青泥AI
青泥学术AI写作辅助平台
302 查看详情 
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1082819.html
微信扫一扫
支付宝扫一扫