oracle pl/sql 1
来源:互联网 发布:php new class 返回值 编辑:程序博客网 时间:2024/06/11 03:08
/*create table temp_tab(
id number(11) primary key
);*/
--使用for xx in xxxlower..xxxheight loop [xxxxxx] end loop;
/*declare
v_id number(2);
begin
for v_id in 2..10 loop
insert into temp_tab values(v_id);
end loop;
end;*/
--CASE 语句
/*declare
v_num number:=1;
v_result varchar2(64);
begin
case v_num
when 1 then v_result:='星期1';
when 2 then v_result:='星期2';
when 3 then v_result:='星期3';
when 4 then v_result:='星期4';
end case;
dbms_output.put_line(v_result);
end;*/
--动态执行 DDL数据定义语言 (reate ,drop ,alter)
/*declare
begin
execute immediate 'create table temp_table(id number(11),name varchar2(20))';
end;*/
/*select * from temp_table*/
--动态执行sql 赋值 into 变量名
/*declare
v_time varchar2(20);
begin
select to_char(sysdate,'dd_mm_dd_ day') into v_time from dual;
dbms_output.put_line('当前日期是:' || v_time);
end; */
--使用变量 (占位符 :x,:y)
/*declare
id number;
plsql varchar2(100);
begin
id:=11;
plsql:='insert into temp_tab values(:1)';
execute immediate plsql using id;
end;*/
--自定义 异常 处理
/*declare
temp_ex exception;--定义异常
t_num number;
begin
select count(1) into t_num from temp_tab where id=1;
if t_num=0 then
--触发异常 (跳到执行处理异常)
raise temp_ex;
end if;
dbms_output.put_line('该用户不存在'||t_num);
--处理异常
exception
when temp_ex then
dbms_output.put_line('该用户已经存在');
end;*/
--使用 游标 抓获 select 结果 【声明游标,开启游标,提取游标,关闭游标】
/*declare
id number;
--声明游标
cursor t_cursor is select id from temp_tab where id=1;
begin
--打开游标
open t_cursor;
--判断游标是否开启
if t_cursor%notfound then
dbms_output.put_line('没有找到相应的记录');
else
--从游标中读取记录
fetch t_cursor into id;
dbms_output.put_line('id = '||id);
end if;
end;*/
--游标的循环读取(for xx in xx loop xxxxxx end loop;)游标开启,关闭会自动进行
/*
declare
id number;
cursor id_cursor is select * from temp_tab;
begin
for tid in id_cursor loop
id:=tid.id;
dbms_output.put_line('id : '||id);
end loop;
end;*/
--游标的循环读取2(for xx in xx loop xxxxxx end loop;)游标开启,关闭会自动进行
declare
id number;
cursor id_cursor is select id from temp_tab;
begin
for tid in id_cursor loop
id:=tid.id;
dbms_output.put_line('id : '||id);
end loop;
end;
- oracle pl/sql 1
- Oracle PL/SQL编程(1)
- Oracle PL/SQL语言基础 (1)
- 1 Oracle PL/SQL 编程手册
- 1 Oracle PL/SQL 编程手册
- oracle pl/SQL函数大全(1)
- Oracle PL/SQL 学习笔记(1)
- oracle pl/sql编程(1 )
- oracle-pl/sql基本操作1
- 【Oracle】PL/SQL编程简介1
- ORACLE PL/SQL 基础
- Oracle PL/SQL入门
- oracle pl/sql
- Learning Oracle PL/SQL
- ORACLE的PL/SQL
- ORACLE PL/SQL 基础
- Oracle PL/SQL入门
- ORACLE PL/SQL入门
- 世界最小晶体管问世:仅由7个原子构成
- 两年的工作经历觉得需要学习的还很多啊
- 系统调用4
- pHP CMS 列表
- linux资料库
- oracle pl/sql 1
- oracle 过程,函数 语法等
- 云计算对产业的影响
- eclipse cdt + mingw 使用第三方 STL库
- linux内核源码下载及启动
- rac节点时间同步方法 !!!
- SDK升级后 模拟器图标异常或者模拟器无法启动解决方案
- 超链接css
- 根据当前系统日期求出本周,本月,本年,上周,上月,上年的第一天