存储过程语法结构

1.基本结构
CREATE OR REPLACE PROCEDURE 存储过程名字
(
<nobr οnmοusemοve="kwM(3);" οnmοuseοut="kwL(event, this);" οnmοuseοver="kwE(event,3, this);" οncοntextmenu="return false;" target="_blank" οnclick="return kwC();" style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" id="key2">参数</nobr>1 IN NUMBER,
参数2 IN NUMBER
) IS
变量1 INTEGER :=0;
变量2 DATE;
BEGIN

END <nobr οnmοusemοve="kwM(2);" οnmοuseοut="kwL(event, this);" οnmοuseοver="kwE(event,2, this);" οncοntextmenu="return false;" target="_blank" οnclick="return kwC();" style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" id="key1">存储</nobr>过程名字

<script type="text/javascript"><!-- google_ad_client = "pub-1572879403720716"; google_ad_width = 300; google_ad_height = 250; google_ad_format = "300x250_as"; google_ad_type = "text_image"; google_ad_channel ="0168087865"; google_alternate_ad_url ="http://www.qqread.com/0000js/google300.htm"; google_color_border = "F9FCFE"; google_color_bg = "F9FCFE"; google_color_link = "1F3A87"; google_color_url = "FF6666"; google_color_text = "000000" google_language = 'zh-CN'; //--></script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script> 2.SELECT INTO STATEMENT
将select查询的<nobr οnmοusemοve="kwM(0);" οnmοuseοut="kwL(event, this);" οnmοuseοver="kwE(event,0, this);" οncοntextmenu="return false;" target="_blank" οnclick="return kwC();" style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" id="key0">结果</nobr>存入到变量中,可以同时将多个列存储多个变量中,必须有一条
<nobr οnmοusemοve="kwM(4);" οnmοuseοut="kwL(event, this);" οnmοuseοver="kwE(event,4, this);" οncοntextmenu="return false;" target="_blank" οnclick="return kwC();" style="border-bottom: 0px dotted; text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" id="key3">记录</nobr>,否则抛出异常(如果没有记录抛出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;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值