PLSQL相关

来源:互联网 发布:计算机培训内容c语言 编辑:程序博客网 时间:2024/05/17 16:57

--为单行注释


单个=为比较,是否相等;

:=为赋值语句


for 变量 in 集合 loop

--循环执行逻辑

end loop;

for循环中,变量自动定义;集合仅限于是数字或游标.

如:

for 1 in 1..5 loop

dbms_output.put_line(i);

end loop;


/*游标*/

用于查询多行结果的记录

declare

--声明定义游标

cursor 游标名 is SQL语句;

begin

--使用方法

--打开游标 

open 游标名

--循环从游标取数据

fetch 游标名 into 变量

--关闭游标

close 游标名


如:

declare

cursor c_tablestu 

is select id from tablestu;

id number(5);

begin

open c_tablestu;

loop

fetch c_tablestu into id;

exit when c_tablestu%notfound;

dbms_output.put_line(id);

end loop;

close c_tablestu;

end;


0 0