- 浏览: 362064 次
- 性别:
最新评论
-
天使建站:
这里这篇文章更详细 还有完整的实例演示:js跳出循环:brea ...
js跳出循环的方法区别(break,continue,return) -
jahentao:
我觉得Jcreator和eclipse中的列出属性和方法,很多 ...
反射原理 -
T240178168:
相互交流下吧
ie9以下都有这个问题(ajax) -
blackproof:
试了一下,的确第一种写法oracle优化了,效率比第二种快多了 ...
Oracle分页sql语句 -
杨白白:
进程与线程
select * from employees emp where emp.salary = 3000
if语句
begin
if (10>50) then
dbms_output.put_line('da yu');
else
dbms_output.put_line('bu da yu');
end if;
end;
select * from employees emp where emp.employee_id=119
where
emp.department_id=30 and
salary < 250
DECLARE
v_sal number(10);
v_empid number(4);
BEGIN
v_empid := &nid ;
SELECT emp.salary into v_sal
FROM employees emp
WHERE emp.employee_id=v_empid;
IF v_sal <= 2500 THEN
UPDATE employees set salary=salary+200 WHERE employee_id=v_empid;
ELSIF v_sal>2500 and v_sal<3000 then
UPDATE employees set salary=salary+100 WHERE employee_id=v_empid;
ELSE
dbms_output.put_line('没有在加薪范围');
END IF;
EXCEPTION
WHEN no_data_found THEN
dbms_output.put_line('没有找到改员工!');
END;
------------case 单值 等值比较----------------------
declare
str number;
begin
str:=&str;
case str
when 60 then
dbms_output.put_line('不及格');
when 70 then
dbms_output.put_line('优良');
when 80 then
dbms_output.put_line('优秀');
else
dbms_output.put_line('其他');
end case;
end;
------------case 范围 条件比较----------------------
declare
num number(6,2);
begin
num:=#
case
when num<60 then
dbms_output.put_line('不及格');
when num<80 then
dbms_output.put_line('优良');
when num<100 then
dbms_output.put_line('优秀');
end case;
exception
when case_not_found then
dbms_output.put_line('没有符合要求的case 语句:'||sqlerrm);
end;
--------------case 表达式---------------------------
--用在赋值语句中
declare
num number(5);
val varchar2(50);
begin
num:=#
val:=case num
when 1 then '第一组'
when 2 then '第二组'
when 3 then '第三组'
end || '是好样的' ;
dbms_output.put_line(val);
end;
--用在select 语句当中
select * from employees where employee_id=109
declare
str varchar2(200);
begin
select case
when salary between 2000 and 3000 then
'普通白领'
when salary between 6000 and 10000 then
'公司金领'
else
'职员'
end kkk into str from employees where employee_id=109;
dbms_output.put_line(str);
end;
select emp.first_name,emp.phone_number, case
when emp.salary between 2000 and 3000 then
'普通白领'
when emp.salary between 6000 and 10000 then
'公司金领'
else
'职员'
end as 职员类型
from employees emp
--------------------goto null---------------------------
declare
num number(5):=10;
begin
if num>5 then
goto label1;
else
-- dbms_output.put_line('nothing');
null;--不做任何事,其主要目的是为了确保程序结构的完整性。
end if;
dbms_output.put_line('welcome to you!');
<<label1>>
dbms_output.put_line('大于5');
end;
--------------------loop ------------------------------------
/*
特点:循环至少运行一次
循环语句的共同点: 都是有 loop end loop;构成
*/
create table tmp
(
tid number(6) primary key,
tname varchar2(10)
)
declare
i number(6):=1;
begin
loop
insert into tmp values(i,'值'||i);
exit when i!=0; --循环终止语句
i:=i+1;
end loop;
dbms_output.put_line('数据入库完毕');
end;
select * from tmp
--------------------while ---------------------------------
create table tmp
(
tid number(6) primary key,
tname varchar2(10)
)
delete from tmp;
declare
i number(6):=1;
begin
while i<=10
loop
insert into tmp values(i,'值'||i);
i:=i+1;
end loop;
commit;
end;
---------------------for----------------------------------
/*
循环次数是确定的
*/
declare
i number(5);
j number(5);
begin
for i in reverse 1..10
loop
for j in 1..i
loop
dbms_output.put('*');
end loop;
dbms_output.put_line('');
end loop;
end;
----------------------预定义异常-------------------------------
不需要定义,不需要手动抛出
select *
from employees emp
where emp.employee_id=1
declare
sal char(1);
e_integrity EXCEPTION;
PRAGMA EXCEPTION_INIT(e_integrity,-01422);
begin
select emp.salary into sal
from employees emp
where emp.employee_id<10000;
exception
when e_integrity then
dbms_output.put_line('值太多:'||sqlerrm);
when no_data_found then
dbms_output.put_line('没有值:'||sqlerrm);
-- when others then
-- dbms_output.put_line('赋值出错'||sqlerrm);
end;
----------------------非预定义------------------------
declare
e_integrity EXCEPTION;
PRAGMA EXCEPTION_INIT(e_integrity,-2291);
BEGIN
UPDATE employees SET employees.department_id=10
WHERE employees.employee_id=101;
EXCEPTION
WHEN e_integrity THEN
dbms_output.put_line('该部门不存在!'||sqlerrm);
when others then
dbms_output.put_line('该部门不存在--!'||sqlcode||' '||sqlerrm);
END;
select * from departments
----------------------自定义---------
--手动定义,手动抛出
select * from employees where employees.employee_id=1111
declare
ex exception;
begin
update employees set employees.salary=10000
where employees.employee_id=1111 ;
if sql%notfound then
raise ex;--注意:自定义异常一定要手动抛出
end if;
exception
when ex then
dbms_output.put_line('没有此条数据:'||sqlerrm);
--抛出自定义异常
--raise_application_error(-20001,'该雇员不存在!');
when others then
dbms_output.put_line('赋值出错');
end;
begin
raise_application_error(-20001,'该雇员不存在!');
end;
create or replace procedure Pro_test_exep
as
ex exception;
begin
update employees set employees.salary=10000
where employees.employee_id=1111 ;
if sql%notfound then
raise ex;
end if;
exception
when ex then
dbms_output.put_line('没有此条数据:'||sqlerrm);
--抛出自定义异常
raise_application_error(-20001,'该雇员不存在!');
when others then
dbms_output.put_line('赋值出错');
end;
declare
e_integrity EXCEPTION;
PRAGMA EXCEPTION_INIT(e_integrity,-20001);
begin
Pro_test_exep;
exception
when e_integrity then
dbms_output.put_line('该雇员不存在');
end;
发表评论
-
DML、DDL、DCL区别
2017-01-22 22:32 870DML(data manipulation languag ... -
DDL与DML问题
2017-01-22 22:30 790因为DML需要提交 而truncate是自动提交的 你要分清哪 ... -
oracle锁表,kill
2015-08-26 18:41 909select sess.SID, sess.SE ... -
ROW_NUMBER() OVER函数的基本用法
2014-09-23 00:27 1163简单的说row_number()从1开始,为每一条分组记录返回 ... -
在oracle中一个汉字,一个字母,一个数字分别占多少个字符
2014-01-08 22:01 2261都是一个字符,如果是字节数的话,就要看你的数据库使用的是什么字 ... -
oracle hint有什么缺点?
2013-11-03 22:37 718有意思的问题。hint本质上就是修改默认优化器计算执行计划的一 ... -
Oracle Hint的用法
2013-11-03 22:36 8581. /*+ALL_ROWS*/ 表明对语句块选择基于开销的优 ... -
谈GROUP BY 中的ROLLUP函数
2013-09-05 22:55 2206rollup(a,b)的特点是,先安(a,b)一起汇总统计,然 ... -
group by后加rollup子句的用法
2013-09-05 22:54 1156group by后带rollup子句的用法(真是丑死人了,接触 ... -
ORACLE CASE WHEN 及 SELECT CASE WHEN的用法
2013-09-05 22:47 1979CASE 语句 CASE selector WHEN v ... -
oracle 日期比较
2013-05-30 17:42 3003案例1 select To_Date('19-01-01', ... -
Oracle--------Decode()
2012-09-23 20:52 1913DECODE函数的作用:它可以将输入数值与函数中的参数列 ... -
flashback——oracle
2012-09-19 19:52 2491oracle10g的回闪包括以下 ... -
oracle存储过程语法
2012-09-08 15:14 31841.基本结构 CREATE OR REPLACE PROCE ... -
Oracle的递归
2012-09-03 22:39 3267Oracle的递归查询 收集的几条在oracle中通过con ... -
oracle常用函数
2012-09-03 22:27 22471. ASCII 返回与指定的字符对应的十进制数; SQL ... -
Oracle经验技巧收集集锦
2012-09-03 22:14 24351.删除表空间 DROP TABLESPACE TableS ... -
Oracle分页sql语句
2012-09-01 21:37 2734Oracle的分页查询语句基本上可以按照本文给出的格式来进行 ... -
oracle 函数,包,存储过程简单实例
2012-09-01 21:34 2019/* 存储过程 参数类型: in 表示入参 out 表示出 ... -
ORACLE创建表空间
2012-09-01 21:24 1031ORACLE中,表空间是数据管理的基本方法,所有用户的对象要 ...
相关推荐
初学者 练习 oracle loop while
oracle中case的用法介绍,里面有case使用的一些实例
说明:注册CSDN用户可得20资源分)JSP+Oracle数据库组建动态网站经典实例对JSP数据库编程学习是个不错的参考,里面有很多具体实例。
oracle删除和重建实例
Oracle用三种循环方法输出乘法表,比如loop的用法: m := 1; loop n := 1; loop dbms_output.put(m||'*'||n||'='||m*n||' '); n := n + 1; exit when n > m; end loop; dbms_output.put_line(''); ...
oracle冷备份实例forwindows
在Oracle中的三种循环模式:Loop、For、While 希望对大家有帮助,更多资料请访问:Http://blog.sina.com.cn/livelouis
修改oracle数据库的实例名,修改oracle数据库的实例名
docke安装oracle,删除实例
C#调用oracle存储过程 最简单的实例C#调用oracle存储过程 最简单的实例
目录 2 第一章 准备工作 4 1.1 系统硬件和软件环境检查 4 1.2 修改/etc/hosts文件 6 1.3 创建用户和组并赋予权限 6 1.4 修改/etc/security/limits.conf 6 1.5 修改/etc/pam.d/login 7 ...2、创建实例 25
ASP.NET连接Oracle数据库实例程序,根据sql.txt创建数据表后,更改WEB.config文件中Oracle字符串连接符中的数据库UID及PASSWORD,或许还需要再次引入System.Data.OracleClient,有问题可留言我
oracleRAC集群如何删除实例
在linux手动新建oracle实例,或多个实例。基本步骤: 1) 指定一个SID 2) 创建所需的文件目录 3) 创建初始化参数文件pfile 4) 确定数据库认证方式,如果给予口令认证,创建口令文件 5) 编写创建数据库脚本 6) ...
JSP+Oracle数据库组建动态网站经典实例,包括论坛系统, 人事管理系统,网上订票系统,新闻发布系统,留言板系统。 要想学习oracle数据库编程,这些实例值得你参考哦!!
oracle 11g 环境下,通过一个监听,对应多个实例的配置。
一个oracle用户,创建多个实例图解。
oracle数据库触发器实例 oracle数据库触发器实例 oracle数据库触发器实例 oracle数据库触发器实例 oracle数据库触发器实例 oracle数据库触发器实例 oracle数据库触发器实例 oracle数据库触发器实例
oracle 存储过程实例 oracle存储过程实例
NULL 博文链接:https://vernonchen163.iteye.com/blog/1908053