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 ...
随机推荐
- backtrack5渗透 笔记
目录 1.信息收集 2.扫描工具 3.漏洞发现 4.社会工程学工具 5.运用层攻击msf 6.局域网攻击 ...
- The P4 Language Specification v1.0.2 Parser
<p4规范>解析器部分详解 p4解析器是根据有限状态机的思想来设计的. 解析器中解析的过程可以被一个解析图(parser graph)所表示,解析图中所表示的某一个状态(或者说,在P4语言 ...
- PHP 错误与异常 笔记与总结(1)错误(Deprecated,Notice,Warning)
[常见的错误类型] ① 语法错误 [例1]程序语句结尾少了';' <?php $username = "dee" //少了分号; echo $username; 输出: ( ...
- Cent OS 6.6 下安装mysql(5.5.20)和 PHP(5.3.10)
0.准备步骤(没有连接网络的 linux): 挂载光盘.让网络 yum 源失效.修改光盘 yum 文件.安装 c 语言编译器 gcc. 1.MySQL(5.5.20) 下载 mysql 5.5.20 ...
- win7系统安装FAQ
安装失败: 直接重启后进入原系统 蓝屏 提示失败 开机F1进入BIOS-〉config-〉Serial ATA-〉将硬盘模式从AHCI改为Compatibility.这项很重要的.可以解决以上问题:
- dom4j最常用最简单的方法
要使用dom4j读写XML文档,需要先下载dom4j包,dom4j官方网站在 http://www.dom4j.org/目前最新dom4j包下载地址:http://nchc.dl.sourceforg ...
- Jquery小例子:全选按钮、加事件、挂事件;parent()语法;slideToggle()语法;animate()语法;元素的淡入淡出效果:fadeIn() 、fadeOut()、fadeToggle() 、fadeTo();function(e):e包括事件源和时间数据;append() 方法
function(e): 事件包括事件源和事件数据,事件源是指是谁触发的这个事件,谁就是事件源(div,按钮,span都可以是事件源),时间数据是指比如点击鼠标的事件中,事件数据就是指点击鼠标的左建或 ...
- 从while(cin>>a)开始探讨cin
1. 首先cin>>a返回的是左操作数,也就是返回cin. cin的条件状态中: cin.eof() 判断流是否到达文件的结束符 cin.fail() 判断IO操作是否失败 在 ...
- node express 学习1
参考链接https://cnodejs.org/topic/55ece31004e2cdb230671c50 express-session connect-nongo mongoose 1.安装mo ...
- [LeetCode]题解(python):042-Trapping Rain Water
题目来源 https://leetcode.com/problems/trapping-rain-water/ Given n non-negative integers representing a ...