PLSQL 申明和游标
--从键盘输入一个数
accept b prompt '请输入一个大于零的数字';
declare
anum number := &b;
begin
while anum>0
loop
dbms_output.put_line(anum);
anum:=anum-1;
end loop;
end; declare
v_num number;
begin
-- 从stsu表中选出id最大的值,并根据该值打印次数
select max(id) into v_num from stsu;
loop
dbms_output.put_line(v_num);
v_num := v_num-1;
exit when v_num=0;
end loop;
end; declare
cursor cur is select id,math from stsu;
begin
for cur in (select id,math from stsu)
loop
dbms_output.put_line(cur.id ||'编号学员的数学分数:'||cur.math);
end loop;
end; declare
cursor cursor_id is select id,math from stsu;
v_id stsu.id%type;
v_math stsu.math%type;
begin
--打开游标
open cursor_id;
loop
-- 抓取数据
fetch cursor_id into v_id,v_math;
exit when cursor_id%notfound;
dbms_output.put_line(v_id||' '||v_math);
end loop;
-- 关闭游标
close cursor_id;
end;
PLSQL 申明和游标的更多相关文章
- PLSQL实例(游标)
在PLSQL块中执行SQL语句 A. 数据定义DDL: create,drop,truncate,不能直接执行,truncate执行时只做数据删除,不写日起,不维护索引 在PLSQL块中执行字符串 ...
- plsql 显式游标
显式游标的处理过程包括: 声明游标,打开游标,检索游标,关闭游标. 声明游标 CURSOR c_cursor_name IS statement; 游标相当于一个查询结果集,将查询的结果放在游标里,方 ...
- PLSQL 几种游标的用法
分类: Oracle 1. PL/SQL里的游标可以分为显式和隐式两种,而隐式有分为select into隐式游标和for .. in 隐式游标两种.所以,我们可以认为,有3种游标用法: A. 显式游 ...
- Oracle PLSQL Demo - 17.游标查询个别字段(非整表)
declare Type ref_cur_variable IS REF cursor; cur_variable ref_cur_variable; v_empno scott.emp.empno% ...
- Oracle PLSQL Demo - 13.游标的各种属性[Found NotFound ISOpen RowCount CURSOR]
declare r_emp scott.emp%rowtype; cursor cur_emp is select t.* from scott.emp t; begin open cur_emp; ...
- SQL 游标使用实例
IF EXISTS(SELECT *FROM sysobjects WHERE name='sp_ContestSubmit') DROP PROC sp_ContestSubmit GO -- == ...
- MSSQLSERVER数据库- 游标
游标是属于级行操作,遍历一个表一行一行读,而SQL查询是基于数据集的,在数据量大的时候,使用游标会降低查询速度.这是很明显的.但是有些操作就用游标实现.所以游标又是不或缺少的.我很久都没用游标了,一时 ...
- sql 记录一次灾难 游标问题
起因:游标执行存储过程 下载begin 外面了.. ,造成一直触发存储过程 收获:定义变量统一在游标外部使用, 书写内容在begin 内部书写 alter PROCEDURE USP_dgd_wzh_ ...
- PL\SQL学习笔记
注释 单行--多行 一.declare一般用于做变量的申明.begin 程序体开始执行 end; 程序体结束exception .. dbms_output.put_line('绝对值'||v_ab ...
随机推荐
- 【转】TCP协议中的三次握手和四次挥手(图解)
http://blog.csdn.net/whuslei/article/details/6667471
- [IT新应用]存储入门-文件级存储及块级别存储的选择
http://www.techrepublic.com/blog/the-enterprise-cloud/block-level-storage-vs-file-level-storage-a-co ...
- HTTP 笔记与总结(3 )socket 编程:发送 GET 请求
使用 PHP + socket 模拟发送 HTTP GET 请求,过程是: ① 打开连接 ② 构造 GET 请求的数据:写入请求行.请求头信息.请求主体信息(GET 请求没有主体信息) ③ 发送 GE ...
- java字符串练习题
- 【翻译】CEDCE2010 制作魅力绘制而要知道的光学小知识
关于Silicon Studio 个人觉得他们的后处理技术在国际上还是有相对水准的,而且不少日系游戏也采用了他们的全平台YEBIS 3的中间件. YEBIS 3的特性可以看下这个 http:// ...
- he time that it takes to bring a block from disk into main memory
DATABASE SYSTEM CONCEPTS, SIXTH EDITION There is a trade-off that the system designer must make betw ...
- Mysql操作笔记(持续更新)
1.mysqldump备份导出 备份成sql mysqldump -hlocalIp -uuserName -p --opt --default-character-set=utf8 --hex-bl ...
- 取消svn关联
把下面这段文字保存成一个reg文件 Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\sh ...
- [Error Code: 1290. The MySQL server is running with the --secure-file-priv option so it cannot execute this statement]错误解决
1.配置文件中将这行注销“secure-file-priv="C:/ProgramData/MySQL/MySQL Server 5.7/Uploads" ”:很多人添加权限依然不 ...
- Spring @Resource、@Autowired、@Qualifier的区别
@Resource默认是按照名称来装配注入的,只有当找不到与名称匹配的bean才会按照类型来装配注入: @Resource注解是J2EE提供,而@Autowired是由Spring提供,故减少系统对s ...